Debian Codegraph @

internal/oauth2/providers/generic/config.go

raw
1 package generic
2
3 import (
4 oauth3 "github.com/jkroepke/openvpn-auth-oauth2/v2/internal/oauth2"
5 "github.com/jkroepke/openvpn-auth-oauth2/v2/internal/oauth2/types"
6 )
7
8 // GetProviderConfig implements the [github.com/jkroepke/openvpn-auth-oauth2/internal/oauth2.Provider] interface.
9 func (p Provider) GetProviderConfig() (types.ProviderConfig, error) {
10 scopes := []string{types.ScopeOpenID, types.ScopeProfile, types.ScopeOfflineAccess}
11
12 if p.Conf.OAuth2.Endpoints.Token.IsEmpty() && p.Conf.OAuth2.Endpoints.Auth.IsEmpty() {
13 return types.ProviderConfig{Scopes: scopes}, nil
14 }
15
16 if p.Conf.OAuth2.Endpoints.Auth.IsEmpty() || p.Conf.OAuth2.Endpoints.Token.IsEmpty() {
17 return types.ProviderConfig{}, oauth3.ErrAuthAndTokenEndpointRequired
18 }
19
20 return types.ProviderConfig{
21 AuthURL: p.Conf.OAuth2.Endpoints.Auth.String(),
22 TokenURL: p.Conf.OAuth2.Endpoints.Token.String(),
23 Scopes: scopes,
24 }, nil
25 }