-
Notifications
You must be signed in to change notification settings - Fork 6
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
add bearer token on signout #201
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.
LGTM. Thanks for this!
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.
Would it be better to ensure the credentialed superagent singleton has the access token setup all the time as well vs injecting it on this action? Longer term that means less changes to the client if we need this behaviour on other actions.
Similar to how we do that here?
panoptes-javascript-client/lib/auth.js
Lines 51 to 52 in 87f1d17
this._bearerToken = response.access_token; | |
apiClient.headers.Authorization = 'Bearer ' + this._bearerToken; |
That api client is the same under the hood pretty much, e.g.
panoptes-javascript-client/lib/api-client.js
Lines 4 to 8 in 87f1d17
var apiClient = new JSONAPIClient(config.host + '/api', { | |
'Content-Type': 'application/json', | |
'Accept': 'application/vnd.api+json; version=1', | |
}, { | |
params: config.params, |
That said if we don't need it then this change looks fine to me but i'd like a review from someone else to confirm it's acceptable longer term.
The agents themselves aren’t exposed publicly by Does the panoptes-javascript-client/lib/oauth.js Lines 129 to 132 in 87f1d17
|
If we wanted to set One thing I'm unsure of is when grabbing a new token: |
Ages since I've looked at this code, so I'm not sure, but I think it refreshes the bearer token if the existing token is within five minutes of expiring. If you've cleared the stored token, then it should always fetch a new one from Panoptes. |
I already reviewed this, last week. Still looks good to me, so I'm happy for it to be merged as-is. |
Apologies @eatyourgreens , Mondays at Adler are tricky since meetings are stacked together. I wanted to test around with setting the header somewhere higher on chain. Will ping you again for another review if needed. Otherwise, I'll go with original fix (and update oauth client with a similar fix) and get this merged. Thanks! |
No worries, just wanted to make sure I'm not holding this up. |
Hey @eatyourgreens , do you mind re-reviewing? I ended up reverting the change on auth.js and did the set of token on deleteHeaders. |
I'm not 100% sure how |
if (this._tokenDetails && this._tokenDetails.access_token) { | ||
deleteHeaders['Authorization'] = 'Bearer ' + this._tokenDetails.access_token | ||
} |
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.
Similar comment here. This code is absolutely fine but if the token details are missing, then you aren't logged in anyway (I think.)
Related: zooniverse/panoptes#4134
https://github.com/zooniverse/how-to-zooniverse/issues/319
Edit: Add missing Bearer Authorization Header on Signout