NewUserAuthWithOAuthConfig creates a UserAuth with a custom oauth2.Config and userinfo URL. This is intended for testing against fake OAuth servers.
(cfg *config.OAuthConfig, oauthCfg *oauth2.Config, store *identity.Store, production bool, userInfoURL string)
| 140 | // NewUserAuthWithOAuthConfig creates a UserAuth with a custom oauth2.Config and |
| 141 | // userinfo URL. This is intended for testing against fake OAuth servers. |
| 142 | func NewUserAuthWithOAuthConfig(cfg *config.OAuthConfig, oauthCfg *oauth2.Config, store *identity.Store, production bool, userInfoURL string) *UserAuth { |
| 143 | baseURL := "" |
| 144 | if u, err := url.Parse(cfg.RedirectURL); err == nil && u.Host != "" { |
| 145 | baseURL = u.Scheme + "://" + u.Host |
| 146 | } |
| 147 | return &UserAuth{ |
| 148 | oauthConfig: oauthCfg, |
| 149 | store: store, |
| 150 | secure: production, |
| 151 | baseURL: baseURL, |
| 152 | userInfoURL: userInfoURL, |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | func generateNonce() string { |
| 157 | b := make([]byte, 16) |
no outgoing calls