-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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 authentik oauth provider #1377
Add authentik oauth provider #1377
Conversation
tools/auth/authentik.go
Outdated
|
||
func NewAuthentikProvider() *Authentik { | ||
return &Authentik{&baseProvider{ | ||
scopes: []string{"profile"}, |
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.
Correct me if I am wrong please, but I feel that scopes can be preconfigured on provider side. If that's the case, it might make sense to not request specific scopes, as it will override the provider's configuration (while pocketbase request scopes are not configurable atm).
What do you think?
Ref: https://goauthentik.io/docs/providers/oauth2/#scope-authorization
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 are partially correct. This default implementation just requests a scope that is enabled by default in Authentik, but ofc this could be configured in any way on the provider side.
I am struggling at the moment to find where the frontend settings are passed into this class. If someone could give me a hint that would be very helpful for the progress of this PR.
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 am struggling at the moment to find where the frontend settings are passed into this class. If someone could give me a hint that would be very helpful for the progress of this PR.
I'm not sure if that's what you are asking, but users can't configure the default scopes
from the Admin UI at the moment.
They are just minimal defaults for convenience and are used only in the login url(s) that are returned with the List auth method
endpoint. Users can adjust/replace them client-side by modifing the scope
query parameter in the returned provider login url(s) if they need to.
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.
Thanks @ganigeorgiev
- What I meant is that Authenktik.go uses a *baseProvider instance, but I dont see where in the baseProvider instance I can retrieve the settings that get set in the Svelte frontend component AuthentikOptions.svelte. This is essential, since all the endpoints get configured there (and authentik is self-hosted, so I can not provide a general URL in the constructor)
- Maybe you could also give me a hint since authentik is a very general provider, and could also allow for example Keycloak to be used, if we want to keep it named Authentik or if we want to give it a more general name.
- I need some feedback about the frontend part, specifically if I align with quality / vision of other providers.
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.
@pr0ton11 The Admin UI settings API doesn't operate directly with the auth.baseProvider
and instead uses the settings.AuthProviderConfig
-
pocketbase/models/settings/settings.go
Lines 461 to 468 in c1921ae
type AuthProviderConfig struct { | |
Enabled bool `form:"enabled" json:"enabled"` | |
ClientId string `form:"clientId" json:"clientId,omitempty"` | |
ClientSecret string `form:"clientSecret" json:"clientSecret,omitempty"` | |
AuthUrl string `form:"authUrl" json:"authUrl,omitempty"` | |
TokenUrl string `form:"tokenUrl" json:"tokenUrl,omitempty"` | |
UserApiUrl string `form:"userApiUrl" json:"userApiUrl,omitempty"` | |
} |
You can find details about the available settings API fields in https://pocketbase.io/docs/api-settings/.
In any case, you can check the Strava PR for a simple example - #1443.
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.
Thanks for helping with the PR, I completed the implementation and it looks like everything is working as expected now
@pr0ton11 Thank you for working on this but there are some minor things that need to be improved:
|
@pr0ton11 I'll apply the changes manually to skip the back-and-forth and will merge it in the develop branch sometime later today. |
Co-authored-by: Marc Singer <ms@pr0.tech>
Thanks for your effort for the final changes 👍 |
Maybe support for the .well-known URI could be added and it could be renamed to generic. |
@cgrs, @pr0ton11 Let's keep it for now as it is. Unfortunately, there will be always some manual mapping required when fetching the user profile data that will defer from one provider to another, and I'm not sure if we can have a truly generic provider. Eventually, I'll consider adding a note/label in the UI mentioning that the provider could be used with other similar OAuth2 services. |
@cgrs, @pr0ton11 On second thought having a generic OIDC provider may actually be better since the OIDC spec mentions recommended/standard scope claims and fields - https://openid.net/specs/openid-connect-core-1_0.html After the ongoing "View" collection type, I'll consider generalizing the Authentik provider. |
(Just for info for anyone following here) The Authentik provider was replaced with a generic OpenID Connect in the If you've previously used Authentik, you'll have to rename the provider key in your code to To enable more than one OIDC provider you can use the additional |
Co-authored-by: Marc Singer <ms@pr0.tech>
This is a PR that eventually should add a more generic oauth2 auth provider. Since I am self hosting authentik as my identity provider it only makes sense that I implement auth for it in projects I want to use in the future.