-
Notifications
You must be signed in to change notification settings - Fork 97
feat(auth): add subject to grant #3440
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
Open
cozminu
wants to merge
32
commits into
main
Choose a base branch
from
cozmin/raf-996
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
6b05778
feat(auth): add subject to grant
cozminu c6a310e
feat(auth): add subject to grant
cozminu ed8411d
fix(auth): grant access when is undefined
cozminu fdfbba3
feat(auth): subject id validation
cozminu 03b1ec5
fix(auth): fix tests
cozminu 9b224b2
Update packages/auth/src/graphql/schema.graphql
cozminu d9d7982
feat(auth): throw GrantError instead of Error
cozminu 7a7d8e6
fix(auth): description for subIdFormat
cozminu efd3042
fix(auth): trx in tests is knex
cozminu 454195e
Merge branch 'main' into cozmin/raf-996
cozminu 99e11b9
fix: grant service to throw only grant errors
cozminu a2db4d6
fix(auth): address change requests
cozminu 223e69e
fix(auth): address change requests
cozminu eb28179
fix tests
cozminu bc07cae
access token optional in grant response
cozminu 1b89c37
fix(auth): move accessErrorsMap to grant
cozminu 7b0fe22
Merge branch 'main' into cozmin/raf-996
cozminu b823bbf
fix(auth): fix test for grant access
cozminu 523da68
fix(auth): changed interaction generic error message
cozminu 86a0618
use main OpenAPI spec for Auth
cozminu cfb3ca8
fix(auth): approved grant does not return subject
cozminu bc22b5b
fix(auth): remove unused import
cozminu 8127553
fix(auth): make access_token optional in response
cozminu 108cb6e
fix(deps): sha.js critical update
cozminu e9a8f08
fix(deps): critical update
cozminu 6c735a0
Update package.json
cozminu 69ad04f
update pnpm lock file
cozminu 805795b
Merge branch 'main' into cozmin/raf-996
cozminu 4b6f81c
change op specs version
cozminu 4f7babc
feat(auth): update idp openapi spec
cozminu f5e9ddf
feat(auth): make idp standalone
cozminu 763a2e9
chore(deps): update axios
cozminu 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
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
Submodule open-payments-specifications
updated
4 files
+1 −1 | VERSION | |
+87 −18 | openapi/auth-server.yaml | |
+1 −1 | openapi/resource-server.yaml | |
+1 −1 | openapi/wallet-address-server.yaml |
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
26 changes: 26 additions & 0 deletions
26
packages/auth/migrations/20250509114109_create_subject_table.js
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,26 @@ | ||
/** | ||
* @param { import("knex").Knex } knex | ||
* @returns { Promise<void> } | ||
*/ | ||
exports.up = function (knex) { | ||
return knex.schema.createTable('subjects', function (table) { | ||
table.uuid('id').primary() | ||
|
||
table.uuid('grantId').notNullable() | ||
table.foreign('grantId').references('grants.id').onDelete('CASCADE') | ||
|
||
table.string('subId').notNullable() | ||
table.string('subIdFormat').notNullable() | ||
|
||
table.timestamp('createdAt').defaultTo(knex.fn.now()) | ||
table.timestamp('updatedAt').defaultTo(knex.fn.now()) | ||
}) | ||
} | ||
|
||
/** | ||
* @param { import("knex").Knex } knex | ||
* @returns { Promise<void> } | ||
*/ | ||
exports.down = function (knex) { | ||
return knex.schema.dropTableIfExists('subjects') | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { HttpStatusCode } from 'axios' | ||
import { GNAPErrorCode } from '../shared/gnapErrors' | ||
import { AccessError } from '../access/errors' | ||
|
||
export enum GrantErrorCode { | ||
InvalidRequest, | ||
OnlyOneAccessAmountAllowed | ||
} | ||
|
||
export class GrantError extends Error { | ||
code: GrantErrorCode | ||
constructor(code: GrantErrorCode, message: string) { | ||
super(message) | ||
this.name = 'GrantError' | ||
this.code = code | ||
} | ||
} | ||
|
||
export function isGrantError(error: unknown): error is GrantError { | ||
return error instanceof GrantError | ||
} | ||
|
||
export const errorToHTTPCode: { | ||
[key in GrantErrorCode]: number | ||
} = { | ||
[GrantErrorCode.InvalidRequest]: HttpStatusCode.BadRequest, | ||
[GrantErrorCode.OnlyOneAccessAmountAllowed]: HttpStatusCode.BadRequest | ||
} | ||
|
||
export const errorToGNAPCode: { | ||
[key in GrantErrorCode]: GNAPErrorCode | ||
} = { | ||
[GrantErrorCode.InvalidRequest]: GNAPErrorCode.InvalidRequest, | ||
[GrantErrorCode.OnlyOneAccessAmountAllowed]: GNAPErrorCode.InvalidRequest | ||
} | ||
|
||
export const errorToMessage: { | ||
[key in GrantErrorCode]: string | ||
} = { | ||
[GrantErrorCode.InvalidRequest]: 'Invalid request', | ||
[GrantErrorCode.OnlyOneAccessAmountAllowed]: 'only one access amount allowed' | ||
} | ||
|
||
export const accessErrorToGrantError: { | ||
[key in AccessError]: GrantErrorCode | ||
} = { | ||
[AccessError.OnlyOneAccessAmountAllowed]: | ||
GrantErrorCode.OnlyOneAccessAmountAllowed | ||
} |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should remove the
import { Knex } from 'knex'
import