mirror of
https://github.com/miniflux/v2.git
synced 2025-09-15 18:57:04 +00:00
Add generic OpenID Connect provider (OAuth2)
This adds the oauth2 provider `oidc`. It needs an additional argument, the OIDC discovery endpoint to figure out where the auth and token URLs are. Configuration is similar to setting up the Google Authentication with these changes: * `OAUTH2_PROVIDER = oidc` * `OAUTH2_OIDC_DISCOVERY_ENDPOINT = https://auth.exampe.org/discovery`
This commit is contained in:
parent
54602b55bb
commit
3e1e0b604f
88 changed files with 15856 additions and 155 deletions
|
@ -5,14 +5,17 @@
|
|||
package ui // import "miniflux.app/ui"
|
||||
|
||||
import (
|
||||
"context"
|
||||
"miniflux.app/config"
|
||||
"miniflux.app/oauth2"
|
||||
)
|
||||
|
||||
func getOAuth2Manager() *oauth2.Manager {
|
||||
func getOAuth2Manager(ctx context.Context) *oauth2.Manager {
|
||||
return oauth2.NewManager(
|
||||
ctx,
|
||||
config.Opts.OAuth2ClientID(),
|
||||
config.Opts.OAuth2ClientSecret(),
|
||||
config.Opts.OAuth2RedirectURL(),
|
||||
config.Opts.OAuth2OidcDiscoveryEndpoint(),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -44,14 +44,14 @@ func (h *handler) oauth2Callback(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
authProvider, err := getOAuth2Manager().Provider(provider)
|
||||
authProvider, err := getOAuth2Manager(r.Context()).Provider(provider)
|
||||
if err != nil {
|
||||
logger.Error("[OAuth2] %v", err)
|
||||
html.Redirect(w, r, route.Path(h.router, "login"))
|
||||
return
|
||||
}
|
||||
|
||||
profile, err := authProvider.GetProfile(code)
|
||||
profile, err := authProvider.GetProfile(r.Context(), code)
|
||||
if err != nil {
|
||||
logger.Error("[OAuth2] %v", err)
|
||||
html.Redirect(w, r, route.Path(h.router, "login"))
|
||||
|
|
|
@ -24,7 +24,7 @@ func (h *handler) oauth2Redirect(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
authProvider, err := getOAuth2Manager().Provider(provider)
|
||||
authProvider, err := getOAuth2Manager(r.Context()).Provider(provider)
|
||||
if err != nil {
|
||||
logger.Error("[OAuth2] %v", err)
|
||||
html.Redirect(w, r, route.Path(h.router, "login"))
|
||||
|
|
|
@ -24,7 +24,7 @@ func (h *handler) oauth2Unlink(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
authProvider, err := getOAuth2Manager().Provider(provider)
|
||||
authProvider, err := getOAuth2Manager(r.Context()).Provider(provider)
|
||||
if err != nil {
|
||||
logger.Error("[OAuth2] %v", err)
|
||||
html.Redirect(w, r, route.Path(h.router, "settings"))
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue