Skip to content
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

Merged
merged 5 commits into from
Aug 26, 2024

Conversation

kyle1morel
Copy link
Collaborator

@kyle1morel kyle1morel commented Aug 19, 2024

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

  • I have read the CONTRIBUTING doc
  • I have checked that unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

Copy link

github-actions bot commented Aug 19, 2024

Coverage Report (Frontend)

Totals Coverage
Statements: 30.08% ( 1477 / 4911 )
Methods: 26.43% ( 254 / 961 )
Lines: 34.74% ( 919 / 2645 )
Branches: 23.3% ( 304 / 1305 )

Copy link

github-actions bot commented Aug 19, 2024

Coverage Report (Application)

Totals Coverage
Statements: 44.55% ( 1018 / 2285 )
Methods: 32.86% ( 140 / 426 )
Lines: 54.83% ( 659 / 1202 )
Branches: 33.33% ( 219 / 657 )

@kyle1morel kyle1morel requested a review from jujaga August 19, 2024 21:53
Copy link
Member

@jujaga jujaga left a 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. 👍

Comment on lines 56 to 62
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 };
},
Copy link
Member

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', {
Copy link
Member

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' };
Copy link
Member

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.

@wilwong89 wilwong89 merged commit 657429d into release/rbac Aug 26, 2024
16 of 17 checks passed
@wilwong89 wilwong89 deleted the feature/coms-perms branch August 26, 2024 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants