-
Notifications
You must be signed in to change notification settings - Fork 0
feat: OAuth 2.0 Client Credentials grant for M2M auth #150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
ea21522
feat: OAuth 2.0 Client Credentials grant for M2M auth (ISSUE-110)
GitAddRemote 7bae5c6
fix: address code review findings on OAuth Client Credentials (ISSUE-…
GitAddRemote 836089f
fix: unblock CI e2e failures on /auth/token endpoint
GitAddRemote 4673280
fix: address code review findings on OAuth client credentials grant
GitAddRemote 66ea72f
fix: normalize Authorization header before string operations
GitAddRemote 34ea496
fix: add OauthClient entity and migration to data-source.ts
Copilot 7f69970
Potential fix for pull request finding
GitAddRemote e1628c8
Potential fix for pull request finding
GitAddRemote 2033946
fix: address review items on OAuth client credentials grant
GitAddRemote 23b7311
fix: address review items on OAuth client credentials grant (round 3)
GitAddRemote 21c5678
fix: address review items on OAuth client credentials grant (round 4)
GitAddRemote 43b1ab3
fix: address review items on OAuth client credentials grant (round 5)
GitAddRemote 2d57349
fix: address review items on OAuth client credentials grant (round 6)
GitAddRemote File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
backend/src/migrations/1777647814618-CreateOauthClientsTable.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
|
||
| export class CreateOauthClientsTable1777647814618 | ||
| implements MigrationInterface | ||
| { | ||
| async up(queryRunner: QueryRunner): Promise<void> { | ||
| await queryRunner.query(` | ||
| CREATE TABLE "oauth_clients" ( | ||
| "id" UUID NOT NULL DEFAULT uuid_generate_v4(), | ||
| "clientId" VARCHAR NOT NULL, | ||
| "clientSecretHash" VARCHAR NOT NULL, | ||
| "scopes" TEXT NOT NULL, | ||
| "isActive" BOOLEAN NOT NULL DEFAULT true, | ||
| "createdAt" TIMESTAMP NOT NULL DEFAULT now(), | ||
| CONSTRAINT "PK_oauth_clients" PRIMARY KEY ("id"), | ||
| CONSTRAINT "UQ_oauth_clients_clientId" UNIQUE ("clientId") | ||
| ) | ||
| `); | ||
| } | ||
|
|
||
| async down(queryRunner: QueryRunner): Promise<void> { | ||
| await queryRunner.query(`DROP TABLE "oauth_clients"`); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
backend/src/modules/auth/decorators/require-scopes.decorator.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import { SetMetadata } from '@nestjs/common'; | ||
|
|
||
| export const REQUIRE_SCOPES_KEY = 'requiredScopes'; | ||
|
|
||
| export const RequireScopes = (...scopes: string[]) => | ||
| SetMetadata(REQUIRE_SCOPES_KEY, scopes); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import { ApiProperty } from '@nestjs/swagger'; | ||
| import { IsString, IsNotEmpty, IsOptional, Equals } from 'class-validator'; | ||
|
|
||
| export class TokenRequestDto { | ||
| @ApiProperty({ example: 'client_credentials' }) | ||
| @IsString() | ||
| @Equals('client_credentials', { | ||
| message: 'grant_type must be "client_credentials"', | ||
| }) | ||
| grant_type!: string; | ||
|
|
||
| @ApiProperty({ example: 'station-bot', required: false }) | ||
| @IsOptional() | ||
| @IsString() | ||
| @IsNotEmpty() | ||
| client_id?: string; | ||
|
|
||
| @ApiProperty({ example: 'super-secret-value', required: false }) | ||
| @IsOptional() | ||
| @IsString() | ||
| @IsNotEmpty() | ||
| client_secret?: string; | ||
|
|
||
| @ApiProperty({ example: 'bot:api', required: false }) | ||
| @IsOptional() | ||
| @IsString() | ||
| scope?: string; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.