-
Notifications
You must be signed in to change notification settings - Fork 1
OIDC example using openid-client and @apostrophecms/passport-bridge version 1.5.0-beta.1 #130
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
base: develop
Are you sure you want to change the base?
Conversation
| }, | ||
| strategies: [ | ||
| { | ||
| async factory(params, fn) { |
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.
New factory option allows us to pass our own async function that returns a fully initialized strategy object. This allows us to use OIDC discovery
| strategies: [ | ||
| { | ||
| async factory(params, fn) { | ||
| const issuer = new URL(process.env.OIDC_ISSUER); |
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.
Because of discovery, all we need is a URL to the provider site (OIDC_ISSUER), OIDC_CLIENT_ID, and OIDC_CLIENT_SECRET.
| } = params; | ||
| const s = new Strategy({ | ||
| config, | ||
| scope: 'openid email', |
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.
You can beef this up if you have other scopes of interest.
| options: {}, | ||
| // Use the user's email address as their identity | ||
| match: 'email', | ||
| // Strategy-specific options that must be passed to the authenticate middleware. |
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.
Actually you should be able to skip this "authenticate" property because it is covered by the factory function.
| <h1>User Info</h1> | ||
| <ul> | ||
| {% for name, value in data.user %} | ||
| <li>{{ name }}: {{ value }}</li> |
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.
Just showing we get access.
Hi Luiz,
Here is a draft PR to show you the changes I made to our assembly essentials starter kit in order to permit login via OIDC in the dashboard.
For test purposes, I used keycloak as an OIDC identity provider.
To obtain HTTPS URLs for local testing, I ran both apostrophe and keycloak behind ngrok. Strict OIDC forbids HTTP URLs.
Note the use of the new passport-bridge
factoryfeature which allows us to initialize the passport strategy in a completely custom way, adapt the function signature of the verify function, and adapt the profile property names in one place.Note also we are using a specific beta release of passport-bridge here.
Please let me know your findings. If this works for your needs I anticipate it will be released under a stable version number on Wednesday.