git.iko.soy/typeable/oauth2-proxy
on request-rules help sign in
46 lines 1.4 kB history raw
1package providers
3import (
4 "errors"
5 "io/ioutil"
6 "net/url"
8 "github.com/oauth2-proxy/oauth2-proxy/pkg/logger"
9)
11// ProviderData contains information required to configure all implementations
12// of OAuth2 providers
13type ProviderData struct {
14 ProviderName string
15 LoginURL *url.URL
16 RedeemURL *url.URL
17 ProfileURL *url.URL
18 ProtectedResource *url.URL
19 ValidateURL *url.URL
20 // Auth request params & related, see
21 //https://openid.net/specs/openid-connect-basic-1_0.html#rfc.section.2.1.1.1
22 AcrValues string
23 ApprovalPrompt string // NOTE: Renamed to "prompt" in OAuth2
24 ClientID string
25 ClientSecret string
26 ClientSecretFile string
27 Scope string
28 Prompt string
31// Data returns the ProviderData
32func (p *ProviderData) Data() *ProviderData { return p }
34func (p *ProviderData) GetClientSecret() (clientSecret string, err error) {
35 if p.ClientSecret != "" || p.ClientSecretFile == "" {
36 return p.ClientSecret, nil
37 }
39 // Getting ClientSecret can fail in runtime so we need to report it without returning the file name to the user
40 fileClientSecret, err := ioutil.ReadFile(p.ClientSecretFile)
41 if err != nil {
42 logger.Printf("error reading client secret file %s: %s", p.ClientSecretFile, err)
43 return "", errors.New("could not read client secret file")
44 }
45 return string(fileClientSecret), nil