Debian Codegraph @

internal/oauth2/providers/github/config.go

raw
1 package github
2
3 import (
4 "github.com/jkroepke/openvpn-auth-oauth2/v2/internal/oauth2/types"
5 "golang.org/x/oauth2"
6 "golang.org/x/oauth2/endpoints"
7 )
8
9 // GetProviderConfig implements the [github.com/jkroepke/openvpn-auth-oauth2/internal/oauth2.Provider] interface.
10 // It returns the OAuth2 GitHub [endpoints.GitHub], since GitHub does not support OIDC discovery.
11 func (p Provider) GetProviderConfig() (types.ProviderConfig, error) {
12 providerConfig, err := p.Provider.GetProviderConfig()
13 if err != nil {
14 return types.ProviderConfig{}, err //nolint:wrapcheck
15 }
16
17 providerConfig.Scopes = []string{"user:email", "read:org"}
18
19 if providerConfig.Endpoint == (oauth2.Endpoint{}) {
20 providerConfig.Endpoint = endpoints.GitHub
21 }
22
23 return providerConfig, nil
24 }