1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-26 18:21:01 +00:00

Remove extra column from users table (HSTORE field)

Migrated key/value pairs to specific columns.
This commit is contained in:
Frédéric Guillot 2020-12-21 21:14:10 -08:00 committed by fguillot
parent ae74f94655
commit 83f3ccab0e
19 changed files with 256 additions and 141 deletions

View file

@ -6,6 +6,9 @@ package oauth2 // import "miniflux.app/oauth2"
import (
"context"
"miniflux.app/model"
"github.com/coreos/go-oidc"
"golang.org/x/oauth2"
)
@ -17,15 +20,15 @@ type oidcProvider struct {
provider *oidc.Provider
}
func (o oidcProvider) GetUserExtraKey() string {
return "oidc_id" // FIXME? add extra options key to allow multiple OIDC providers each with their own extra key?
func (o *oidcProvider) GetUserExtraKey() string {
return "openid_connect_id"
}
func (o oidcProvider) GetRedirectURL(state string) string {
func (o *oidcProvider) GetRedirectURL(state string) string {
return o.config().AuthCodeURL(state)
}
func (o oidcProvider) GetProfile(ctx context.Context, code string) (*Profile, error) {
func (o *oidcProvider) GetProfile(ctx context.Context, code string) (*Profile, error) {
conf := o.config()
token, err := conf.Exchange(ctx, code)
if err != nil {
@ -41,7 +44,15 @@ func (o oidcProvider) GetProfile(ctx context.Context, code string) (*Profile, er
return profile, nil
}
func (o oidcProvider) config() *oauth2.Config {
func (o *oidcProvider) PopulateUserWithProfileID(user *model.User, profile *Profile) {
user.OpenIDConnectID = profile.ID
}
func (o *oidcProvider) UnsetUserProfileID(user *model.User) {
user.OpenIDConnectID = ""
}
func (o *oidcProvider) config() *oauth2.Config {
return &oauth2.Config{
RedirectURL: o.redirectURL,
ClientID: o.clientID,