Skip to content

Commit

Permalink
refactor: rename config options to authenticateIntrospect & authentic…
Browse files Browse the repository at this point in the history
…ateRevoke
  • Loading branch information
jasonraimondi committed Aug 11, 2024
1 parent eedd548 commit 2612f5e
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions docs/docs/authorization_server/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ The authorization server has a few optional settings with the following default
| `notBeforeLeeway` | number | 0 | Implementers MAY provide for some small leeway, usually no more than a few minutes, to account for clock skew. Its value MUST be a number containing a NumericDate value. |
| `tokenCID` | "id" or "name" | "id" | Sets the JWT `accessToken.cid` to either the `client.id` or `client.name`.<br /><br />In 3.x the default is **"id"**, in v2.x the default was **"name"**. [[Learn more]][token-cid] |
| `issuer` | string \| undefined | undefined | Sets the JWT `accessToken.iss` to this value. |
| `introspectWithClientCredentials` | boolean | false | Authorize [the /introspect endpoint](../endpoints/introspect.mdx) using `client_credentials`, this requires users to pass in a valid client_id and client_secret (or Authorization header) |
| `revokeWithClientCredentials` | boolean | false | Authorize [the /revoke endpoint](../endpoints/revoke.mdx) using `client_credentials`, this requires users to pass in a valid client_id and client_secret (or Authorization header) |
| `authenticateIntrospect` | boolean | false | Authorize [the /introspect endpoint](../endpoints/introspect.mdx) using `client_credentials`, this requires users to pass in a valid client_id and client_secret (or Authorization header) |
| `authenticateRevoke` | boolean | false | Authorize [the /revoke endpoint](../endpoints/revoke.mdx) using `client_credentials`, this requires users to pass in a valid client_id and client_secret (or Authorization header) |

```ts
type AuthorizationServerOptions = {
Expand All @@ -25,8 +25,8 @@ type AuthorizationServerOptions = {
notBeforeLeeway: 0;
tokenCID: "id" | "name";
issuer: undefined;
introspectWithClientCredentials: boolean;
revokeWithClientCredentials: boolean;
authenticateIntrospect: boolean;
authenticateRevoke: boolean;
};
```

Expand Down
4 changes: 2 additions & 2 deletions src/authorization_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export interface AuthorizationServerOptions {
tokenCID: "id" | "name";
issuer?: string;
scopeDelimiter: string;
introspectWithClientCredentials: boolean;
revokeWithClientCredentials: boolean;
authenticateIntrospect: boolean;
authenticateRevoke: boolean;
}

export type EnableableGrants =
Expand Down
2 changes: 1 addition & 1 deletion src/grants/auth_code.grant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ export class AuthCodeGrant extends AbstractAuthorizedGrant {
async respondToRevokeRequest(req: RequestInterface): Promise<ResponseInterface> {
req.body["grant_type"] = this.identifier;

if (this.options.revokeWithClientCredentials) await this.validateClient(req);
if (this.options.authenticateRevoke) await this.validateClient(req);

const token = this.getRequestParameter("token", req);

Expand Down
4 changes: 2 additions & 2 deletions src/grants/client_credentials.grant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class ClientCredentialsGrant extends AbstractGrant {
async respondToIntrospectRequest(req: RequestInterface): Promise<ResponseInterface> {
req.body["grant_type"] = this.identifier;

if (this.options.introspectWithClientCredentials) await this.validateClient(req);
if (this.options.authenticateIntrospect) await this.validateClient(req);

const { parsedToken, oauthToken, expiresAt, tokenType } = await this.tokenFromRequest(req);

Expand Down Expand Up @@ -60,7 +60,7 @@ export class ClientCredentialsGrant extends AbstractGrant {
async respondToRevokeRequest(req: RequestInterface): Promise<ResponseInterface> {
req.body["grant_type"] = this.identifier;

if (this.options.revokeWithClientCredentials) await this.validateClient(req);
if (this.options.authenticateRevoke) await this.validateClient(req);

let { oauthToken } = await this.tokenFromRequest(req);

Expand Down
4 changes: 2 additions & 2 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ export const DEFAULT_AUTHORIZATION_SERVER_OPTIONS: AuthorizationServerOptions =
tokenCID: "id",
issuer: undefined,
scopeDelimiter: " ",
introspectWithClientCredentials: false,
revokeWithClientCredentials: false,
authenticateIntrospect: false,
authenticateRevoke: false,
};
8 changes: 4 additions & 4 deletions test/e2e/authorization_server.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,15 +361,15 @@ describe("authorization_server", () => {
inMemoryDatabase.clients[client.id] = client;
});

describe("without option introspectWithClientCredentials=false", () => {
describe("without option authenticateIntrospect=false", () => {
it("does not require client credentials", async () => {
authorizationServer = new AuthorizationServer(
inMemoryClientRepository,
inMemoryAccessTokenRepository,
inMemoryScopeRepository,
new JwtService("secret-key"),
{
introspectWithClientCredentials: false,
authenticateIntrospect: false,
},
);

Expand Down Expand Up @@ -556,15 +556,15 @@ describe("authorization_server", () => {
inMemoryDatabase.clients[client.id] = client;
});

describe("without option revokeWithClientCredentials=false", () => {
describe("without option authenticateRevoke=false", () => {
it("does not require client credentials", async () => {
const authorizationServer = new AuthorizationServer(
inMemoryClientRepository,
inMemoryAccessTokenRepository,
inMemoryScopeRepository,
new JwtService("secret-key"),
{
revokeWithClientCredentials: false,
authenticateRevoke: false,
},
);

Expand Down

0 comments on commit 2612f5e

Please sign in to comment.