1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-11 17:51:01 +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:
Patrick 2020-03-08 03:45:19 +01:00 committed by GitHub
parent 54602b55bb
commit 3e1e0b604f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
88 changed files with 15856 additions and 155 deletions

View file

@ -4,7 +4,11 @@
package oauth2 // import "miniflux.app/oauth2"
import "errors"
import (
"context"
"errors"
"miniflux.app/logger"
)
// Manager handles OAuth2 providers.
type Manager struct {
@ -26,8 +30,17 @@ func (m *Manager) AddProvider(name string, provider Provider) {
}
// NewManager returns a new Manager.
func NewManager(clientID, clientSecret, redirectURL string) *Manager {
func NewManager(ctx context.Context, clientID, clientSecret, redirectURL, oidcDiscoveryEndpoint string) *Manager {
m := &Manager{providers: make(map[string]Provider)}
m.AddProvider("google", newGoogleProvider(clientID, clientSecret, redirectURL))
if oidcDiscoveryEndpoint != "" {
if genericOidcProvider, err := newOidcProvider(ctx, clientID, clientSecret, redirectURL, oidcDiscoveryEndpoint); err != nil {
logger.Error("[OAuth2] failed to initialize OIDC provider: %v", err)
} else {
m.AddProvider("oidc", genericOidcProvider)
}
}
return m
}