8 "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/logger"
11// ProviderData contains information required to configure all implementations
13type ProviderData struct {
18 ProtectedResource *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
23 ApprovalPrompt string // NOTE: Renamed to "prompt" in OAuth2
26 ClientSecretFile 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
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)
42 logger.Errorf("error reading client secret file %s: %s", p.ClientSecretFile, err)
43 return "", errors.New("could not read client secret file")
45 return string(fileClientSecret), nil
48type providerDefaults struct {
57func (p *ProviderData) setProviderDefaults(defaults providerDefaults) {
58 p.ProviderName = defaults.name
59 p.LoginURL = defaultURL(p.LoginURL, defaults.loginURL)
60 p.RedeemURL = defaultURL(p.RedeemURL, defaults.redeemURL)
61 p.ProfileURL = defaultURL(p.ProfileURL, defaults.profileURL)
62 p.ValidateURL = defaultURL(p.ValidateURL, defaults.validateURL)
65 p.Scope = defaults.scope
69// defaultURL will set return a default value if the given value is not set.
70func defaultURL(u *url.URL, d *url.URL) *url.URL {
71 if u != nil && u.String() != "" {
72 // The value is already set
76 // If the default is given, return that
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list