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

Made changes so auth on openapi schema works. #143

Merged
merged 3 commits into from
Aug 27, 2020
Merged

Conversation

thai-truong
Copy link
Collaborator

Now requests that require BE to check token will be sent with
Bearer JWT from FE as a token.

Now requests that require BE to check token will be sent with
Bearer JWT from FE as a token.
@thai-truong thai-truong added bug Something isn't working enhancement New feature or request labels Aug 26, 2020
@thai-truong thai-truong requested a review from a team August 26, 2020 23:52
@thai-truong thai-truong self-assigned this Aug 26, 2020
@netlify
Copy link

netlify bot commented Aug 26, 2020

Deploy preview for hkn-ucsd-portal-dev ready!

Built with commit 39eeaab

https://deploy-preview-143--hkn-ucsd-portal-dev.netlify.app

Copy link
Collaborator

@godwinpang godwinpang left a comment

Choose a reason for hiding this comment

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

1 small thing but overall looks good

@@ -52,7 +52,7 @@
"storybook": "start-storybook -p 6006 -s public",
"build-storybook": "build-storybook -s public",
"precodegen": "rimraf src/api/*",
"codegen": "npx openapi-generator generate -i http://dev.api.hknucsd.com/api/docs/json -g typescript-fetch --additional-properties=typescriptThreePlus=true -o src/api/"
"codegen": "npx openapi-generator generate -i http://dev.api.hknucsd.com/api/docs/json -g typescript-fetch --additional-properties=typescriptThreePlus=true -o src/services/api"
Copy link
Collaborator

Choose a reason for hiding this comment

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

oof sorry if this caused issues it's mb :(

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

np it didn't

const { claims } = tokenResult;
const { claims, token } = tokenResult;

ApiConfigStore.setToken(token);
Copy link
Collaborator

Choose a reason for hiding this comment

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

might also have to call this in setClaims

Copy link
Collaborator

Choose a reason for hiding this comment

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

we could have a state field that's token instead of userRoles - what do you think

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

setClaims doesn't have access to tokenResult.token though. Also, I use userRoles for the RBAC HOCs so I'd rather it still be there. We can always just have a userToken state field in addition to the other two.

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah i see ur point about the userRoles, but after a user logins you should be able to get their token

Copy link
Collaborator

Choose a reason for hiding this comment

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

so then we can add the userToken as a state field

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes that's fine. What about the calling setToken() in setClaims that you said in your first comment of this thread?

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah cuz after someone signs in we should set the token in setClaims instead of waiting for the firebase authListener to do it

Copy link
Collaborator

Choose a reason for hiding this comment

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

i ran into some weird issues before doing this

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Should I put userToken into userClaims then, since it's an object? Also, if I were to call setToken in setClaims, do I just get the token from this.state.userClaims?

@godwinpang
Copy link
Collaborator

godwinpang commented Aug 27, 2020 via email

@thai-truong
Copy link
Collaborator Author

Okay so token will be its own state field then got it.

@thai-truong thai-truong merged commit 6c5e7fa into dev Aug 27, 2020
@godwinpang godwinpang deleted the openapiFunctions branch September 5, 2020 21:45
godwinpang pushed a commit that referenced this pull request Sep 20, 2020
* Made changes so auth on openapi schema works.

Now requests that require BE to check token will be sent with
Bearer JWT from FE as a token.

* Made changes based on review on PR #143

* Okay actual changes reflecting review on PR #143.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants