-
Notifications
You must be signed in to change notification settings - Fork 0
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
Automatically grant COMS permissions for new users #130
Conversation
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.
Some minor edge cases to consider but structurally looks good otherwise. 👍
app/src/services/coms.ts
Outdated
async getObject(bearerToken: string | null | undefined, objectId: string) { | ||
const { status, headers, data } = await comsAxios({ | ||
responseType: 'arraybuffer', | ||
headers: { Authorization: incomingHeaders.authorization } | ||
headers: { Authorization: `Bearer ${bearerToken}` } | ||
}).get(`/object/${objectId}`); | ||
return { status, headers, data }; | ||
}, |
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.
Safety: There should be a conditional if here to drop the Authorization header completely if bearerToken
is either null or undefined.
async getObjects(incomingHeaders: IncomingHttpHeaders, objectIds: Array<string>) { | ||
const { data } = await comsAxios({ headers: { Authorization: incomingHeaders.authorization } }).get('/object', { | ||
async getObjects(bearerToken: string | null | undefined, objectIds: Array<string>) { | ||
const { data } = await comsAxios({ headers: { Authorization: `Bearer ${bearerToken}` } }).get('/object', { |
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.
Safety: There should be a conditional if here to drop the Authorization header completely if bearerToken
is either null or undefined.
@@ -22,7 +22,7 @@ afterEach(() => { | |||
jest.resetAllMocks(); | |||
}); | |||
|
|||
const CURRENT_CONTEXT = { authType: 'BEARER', tokenPayload: null, userId: 'abc-123' }; | |||
const CURRENT_CONTEXT = { authType: 'BEARER', bearerToken: 'sometoken', tokenPayload: null, userId: 'abc-123' }; |
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.
Test coverage: Consider testing scenarios where the bearerToken
has a falsy value (null and/or undefined) and making sure that your code is still behaving as anticipated.
7ad5bbd
to
5bc339e
Compare
Description
Using the updated COMS API, this implementation allows the system to impersonate the current user and grant themselves access to the PCNS bucket based on their given group in the RBAC.
https://apps.nrs.gov.bc.ca/int/jira/browse/PADS-239
Types of changes
New feature (non-breaking change which adds functionality)
Checklist
Further comments