-
Notifications
You must be signed in to change notification settings - Fork 12
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
OpenID #149
OpenID #149
Conversation
Removed token for authManager Renamed token to accessToken for continuity Clone response to avoid calling body twice
Ly @netlob |
Ly2bb @idiidka |
Super nice! I totally ship you guys too. |
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.
I agree that it is cleaner to keep authentication in a separate repository. I didn't test if everything works, but if you say that your tests all pass I think it's fine. It looks good to me!
@@ -72,13 +71,15 @@ class Http { | |||
* @param {Object} obj | |||
* @returns {Request} | |||
*/ | |||
makeRequest(obj) { | |||
async makeRequest(obj) { |
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.
Does this (the function now being async) create any issues?
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.
Nope, I fixed all the refrences
const init = { | ||
method: obj.method, | ||
timeout: this._requestTimeout, | ||
headers: { | ||
...obj.headers, | ||
Authorization: 'Bearer ' + this._token, | ||
Authorization: `Bearer ${accessToken}`, |
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.
Much cleaner.
Removed token for authManager Renamed token to accessToken for continuity Clone response to avoid calling body twice
Okay, the login function now throws AuthErrors and the tests are updated to support that! Hopefully that`s enough for a merge ;) |
I love this! |
Great to hear all this work wasn't for nothing! :) |
Rebased on top of master with some squashes! |
Switch to my magister-openid package to support proper OpenID authentication and token management.
Where you could locally store the token variable, (that would expire after an hour xd), you should now save the tokenSet. This is an object containing the access and refresh tokens. You can initialize MagisterJS with this token set, tokens are automatically checked and refreshed if necessary. This negates the saving of plaintext passwords!
My package is a wrapper around the openid-client library. It just adds support for Magister.
I think it's a lot more maintainable and clean to keep the authentication code and main library code separate. So that's why I created the package.
All tests pass on my end, and the code is linted to spec.
CREDIT TO @Sj3rd FOR HELPING ME FIGURE THIS OUT, COULDN'T HAVE DONE IT WITHOUT HIM (en z'n papa is pliesie dus deze credit moet wel)
x idiidk