-
Notifications
You must be signed in to change notification settings - Fork 7k
auth-backend: refactor to split lib, move types closer to home, update docs, renaming things #2268
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
Conversation
…ve env config to be a provider concern
freben
left a comment
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.
Great stuff! Much clearer
| clientID: options.clientId, | ||
| clientSecret: options.clientSecret, | ||
| callbackURL: options.callbackUrl, | ||
| passReqToCallback: false as true, |
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 mean...
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.
TS support in passport is not great ^_>. It's tricky to wrap it up more than this though, since providers are different. May be that we should just create our own type definitions, but then that would be part of adding providers too, which is a bit meh
| logout?(): Promise<any>; | ||
| start( | ||
| req: express.Request, | ||
| options: Record<string, string>, |
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.
Really?
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.
This is just moved, so followup PR
| !state.nonce || | ||
| !state.env || | ||
| state.nonce?.length === 0 || | ||
| state.env?.length === 0 |
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.
Either those question marks can be left out, or just check if (!state.nonce?.length ||...
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.
and this
|
|
||
| const clientId = envConfig.getString('clientId'); | ||
| const clientSecret = envConfig.getString('clientSecret'); | ||
| const tenantID = envConfig.getString('tenantId'); |
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.
Id
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.
and this
| const providerId = 'gitlab'; | ||
| const clientId = envConfig.getString('clientId'); | ||
| const clientSecret = envConfig.getString('clientSecret'); | ||
| const audience = envConfig.getString('audience'); |
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.
Optional?
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.
and this
| }; | ||
|
|
||
| export type OAuthState = { | ||
| /* A type for the serialized value in the `state` parameter of the OAuth authorization flow |
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.
Two asterisks?
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.
and this
Most of this is just renaming and moving, and removing a bunch of unused types.
One larger changes is that environments are now an OAuth thing, as in we don't assume that other providers support them. That way we could simplify the setup a bit and move the responsibility for setting up the different envs to the provider factory functions.
Docs are updated so they should reflect the changes too.
Also adds a 404 for when trying to use missing auth providers.