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

Use sub from JWT #134

Merged
merged 1 commit into from
Aug 26, 2024
Merged

Use sub from JWT #134

merged 1 commit into from
Aug 26, 2024

Conversation

kyle1morel
Copy link
Collaborator

Description

JWT now provides the correct sub. Now using that over preffered_username. Update code, and database to accurately reflect this change.

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

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 22, 2024

Coverage Report (Application)

Totals Coverage
Statements: 44.49% ( 1005 / 2259 )
Methods: 32.94% ( 140 / 425 )
Lines: 54.99% ( 656 / 1193 )
Branches: 32.61% ( 209 / 641 )

@@ -151,11 +151,11 @@ const service = {
* @param {string} [defaultValue=undefined] An optional default return value
* @returns {string} The current userId if applicable, or `defaultValue`
*/
getCurrentUserId: async (identityId: string, defaultValue: string | undefined = undefined) => {
getCurrentUserId: async (sub: string | undefined, defaultValue: string | undefined = undefined) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type: There should never be a situation where a subject is undefined in a JWT.
JSDoc: Don't forget to update the JSDoc param names too.

@@ -4,7 +4,7 @@ import { generateCreateStamps, generateUpdateStamps } from '../db/utils/utils';
import { activityService, enquiryService, noteService, userService } from '../services';
import { Initiative } from '../utils/enums/application';
import { ApplicationStatus, IntakeStatus, NoteType, SubmissionType } from '../utils/enums/housing';
import { getCurrentIdentity, getCurrentTokenUsername } from '../utils/utils';
import { getCurrentTokenSub, getCurrentTokenUsername } from '../utils/utils';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional Style: It might be possible to rename to getCurrentSubject and getCurrentUsername as this information will always be inferred to have come from the JWT token.

JWT now provides the correct sub. Now using that over preffered_username. Update database and models to accuractely reflect this change.
@kyle1morel kyle1morel merged commit 857f98f into release/rbac Aug 26, 2024
16 of 17 checks passed
@kyle1morel kyle1morel deleted the feature/jwt-sub branch August 26, 2024 16:48
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