-
Notifications
You must be signed in to change notification settings - Fork 89
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
feat(backend): start of handling grant token rotation more gracefully #2887
Merged
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a16e8fa
feat(backend): add grantService.getOrCreate method
mkurapov 96a1d7c
feat(backend): update grant lookup call
mkurapov c913df5
feat(backend): add deletedAt to grants table
mkurapov 27fc5aa
feat(backend): add migrations for grants table
mkurapov c192197
chore(backend): separating into functions
mkurapov af51d1b
chore(backend): adding authServerService to list of services
mkurapov b21d89e
test(backend): adding tests for getOrCreate and getExistingGrant func…
mkurapov 8e49521
chore(backend): merge migrations
mkurapov 4bff426
feat(backend): add subset actions if present
mkurapov 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
21 changes: 21 additions & 0 deletions
21
packages/backend/migrations/20240820101201_add_deleted_at_grants.js
This file contains 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,21 @@ | ||
/** | ||
* @param { import("knex").Knex } knex | ||
* @returns { Promise<void> } | ||
*/ | ||
exports.up = function (knex) { | ||
return knex.schema.alterTable('grants', (table) => { | ||
table.dropUnique(['authServerId', 'accessType', 'accessActions']) | ||
table.timestamp('deletedAt').nullable() | ||
}) | ||
} | ||
|
||
/** | ||
* @param { import("knex").Knex } knex | ||
* @returns { Promise<void> } | ||
*/ | ||
exports.down = function (knex) { | ||
return knex.schema.alterTable('grants', (table) => { | ||
table.unique(['authServerId', 'accessType', 'accessActions']) | ||
table.dropColumn('deletedAt') | ||
}) | ||
} |
This file contains 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 |
---|---|---|
|
@@ -98,6 +98,8 @@ import { | |
} from './open_payments/wallet_address/middleware' | ||
|
||
import { LoggingPlugin } from './graphql/plugin' | ||
import { GrantService } from './open_payments/grant/service' | ||
import { AuthServerService } from './open_payments/authServer/service' | ||
export interface AppContextData { | ||
logger: Logger | ||
container: AppContainer | ||
|
@@ -232,6 +234,8 @@ export interface AppServices { | |
incomingPaymentService: Promise<IncomingPaymentService> | ||
remoteIncomingPaymentService: Promise<RemoteIncomingPaymentService> | ||
receiverService: Promise<ReceiverService> | ||
grantService: Promise<GrantService> | ||
authServerService: Promise<AuthServerService> | ||
Comment on lines
+237
to
+238
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. weren't included before, adding here so we get proper types There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. easy to miss this |
||
streamServer: Promise<StreamServer> | ||
webhookService: Promise<WebhookService> | ||
quoteService: Promise<QuoteService> | ||
|
This file contains 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 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,8 @@ | ||
export enum GrantError { | ||
GrantRequiresInteraction = 'GrantRequiresInteraction', | ||
InvalidGrantRequest = 'InvalidGrantRequest' | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types | ||
export const isGrantError = (o: any): o is GrantError => | ||
Object.values(GrantError).includes(o) |
This file contains 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.
nit: why not combine this migration with
drop_unique_grants
?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.
Yup, makes sense for this one, let me do that