mirror of
https://github.com/openziti/zrok.git
synced 2024-11-21 23:53:19 +01:00
redundant oauth configuration cleanup (#404)
This commit is contained in:
parent
d0a9353872
commit
c4f9cecd99
@ -18,11 +18,10 @@ type Config struct {
|
||||
}
|
||||
|
||||
type OauthConfig struct {
|
||||
Host string
|
||||
Port int
|
||||
RedirectUrl string
|
||||
HashKeyRaw string `cf:"+secret"`
|
||||
Providers []*OauthProviderConfig
|
||||
RedirectHost string
|
||||
RedirectPort int
|
||||
HashKeyRaw string `cf:"+secret"`
|
||||
Providers []*OauthProviderConfig
|
||||
}
|
||||
|
||||
func (oc *OauthConfig) GetProvider(name string) *OauthProviderConfig {
|
||||
@ -65,6 +64,6 @@ func configureOauthHandlers(ctx context.Context, cfg *Config, tls bool) error {
|
||||
if err := configureGithubOauth(cfg.Oauth, tls); err != nil {
|
||||
return err
|
||||
}
|
||||
zhttp.StartServer(ctx, fmt.Sprintf("%s:%d", strings.Split(cfg.Address, ":")[0], cfg.Oauth.Port))
|
||||
zhttp.StartServer(ctx, fmt.Sprintf("%s:%d", strings.Split(cfg.Address, ":")[0], cfg.Oauth.RedirectPort))
|
||||
return nil
|
||||
}
|
||||
|
@ -34,12 +34,11 @@ func configureGithubOauth(cfg *OauthConfig, tls bool) error {
|
||||
}
|
||||
clientID := providerCfg.ClientId
|
||||
callbackPath := "/github/oauth"
|
||||
port := cfg.Port
|
||||
redirectUrl := fmt.Sprintf("%s://%s", scheme, cfg.RedirectUrl)
|
||||
redirectUrl := fmt.Sprintf("%s://%s", scheme, cfg.RedirectHost)
|
||||
rpConfig := &oauth2.Config{
|
||||
ClientID: clientID,
|
||||
ClientSecret: providerCfg.ClientSecret,
|
||||
RedirectURL: fmt.Sprintf("%v:%v%v", redirectUrl, port, callbackPath),
|
||||
RedirectURL: fmt.Sprintf("%v:%v%v", redirectUrl, cfg.RedirectPort, callbackPath),
|
||||
Scopes: []string{"user:email"},
|
||||
Endpoint: githubOAuth.Endpoint,
|
||||
}
|
||||
|
@ -35,12 +35,11 @@ func configureGoogleOauth(cfg *OauthConfig, tls bool) error {
|
||||
|
||||
clientID := providerCfg.ClientId
|
||||
callbackPath := "/google/oauth"
|
||||
port := cfg.Port
|
||||
redirectUrl := fmt.Sprintf("%s://%s", scheme, cfg.RedirectUrl)
|
||||
redirectUrl := fmt.Sprintf("%s://%s", scheme, cfg.RedirectHost)
|
||||
rpConfig := &oauth2.Config{
|
||||
ClientID: clientID,
|
||||
ClientSecret: providerCfg.ClientSecret,
|
||||
RedirectURL: fmt.Sprintf("%v:%v%v", redirectUrl, port, callbackPath),
|
||||
RedirectURL: fmt.Sprintf("%v:%v%v", redirectUrl, cfg.RedirectPort, callbackPath),
|
||||
Scopes: []string{"https://www.googleapis.com/auth/userinfo.email"},
|
||||
Endpoint: googleOauth.Endpoint,
|
||||
}
|
||||
|
@ -348,7 +348,7 @@ func basicAuthRequired(w http.ResponseWriter, realm string) {
|
||||
}
|
||||
|
||||
func oauthLoginRequired(w http.ResponseWriter, r *http.Request, shrToken string, pcfg *Config, provider, target string, authCheckInterval time.Duration) {
|
||||
http.Redirect(w, r, fmt.Sprintf("http://%s.%s:%d/%s/login?targethost=%s&checkInterval=%s", shrToken, pcfg.Oauth.Host, pcfg.Oauth.Port, provider, url.QueryEscape(target), authCheckInterval.String()), http.StatusFound)
|
||||
http.Redirect(w, r, fmt.Sprintf("http://%s.%s:%d/%s/login?targethost=%s&checkInterval=%s", shrToken, pcfg.Oauth.RedirectHost, pcfg.Oauth.RedirectPort, provider, url.QueryEscape(target), authCheckInterval.String()), http.StatusFound)
|
||||
}
|
||||
|
||||
func resolveService(hostMatch string, host string) string {
|
||||
|
@ -5,8 +5,8 @@
|
||||
#host_match: zrok.io
|
||||
|
||||
#oauth:
|
||||
# port: 28080
|
||||
# redirect_url: zrok.io
|
||||
# redirect_host: zrok.io
|
||||
# redirect_port: 28080
|
||||
# hash_key_raw: "test1234test1234"
|
||||
# providers:
|
||||
# - name: google
|
||||
|
Loading…
Reference in New Issue
Block a user