コード例 #1
0
ファイル: connector_uaa.go プロジェクト: Tecsisa/dex
func newUAAConnector(cfg *UAAConnectorConfig, uaaBaseURL *url.URL, cbURL string) (oauth2Connector, error) {
	uaaAuthURL := *uaaBaseURL
	uaaTokenURL := *uaaBaseURL
	uaaAuthURL.Path = path.Join(uaaAuthURL.Path, "/oauth/authorize")
	uaaTokenURL.Path = path.Join(uaaTokenURL.Path, "/oauth/token")
	config := oauth2.Config{
		Credentials: oauth2.ClientCredentials{ID: cfg.ClientID, Secret: cfg.ClientSecret},
		AuthURL:     uaaAuthURL.String(),
		TokenURL:    uaaTokenURL.String(),
		Scope:       []string{"openid"},
		AuthMethod:  oauth2.AuthMethodClientSecretPost,
		RedirectURL: cbURL,
	}

	cli, err := oauth2.NewClient(http.DefaultClient, config)
	if err != nil {
		return nil, err
	}

	return &uaaOAuth2Connector{
		clientID:     cfg.ClientID,
		clientSecret: cfg.ClientSecret,
		client:       cli,
		uaaBaseURL:   uaaBaseURL,
	}, nil
}
コード例 #2
0
ファイル: client.go プロジェクト: sym3tri/go-oidc
func (c *Client) OAuthClient() (*oauth2.Client, error) {
	authMethod, err := c.chooseAuthMethod()
	if err != nil {
		return nil, err
	}

	ocfg := oauth2.Config{
		Credentials: oauth2.ClientCredentials(c.credentials),
		RedirectURL: c.redirectURL,
		AuthURL:     c.providerConfig.AuthEndpoint,
		TokenURL:    c.providerConfig.TokenEndpoint,
		Scope:       c.scope,
		AuthMethod:  authMethod,
	}

	return oauth2.NewClient(c.httpClient, ocfg)
}
コード例 #3
0
ファイル: connector_bitbucket.go プロジェクト: Tecsisa/dex
func newBitbucketConnector(clientID, clientSecret, cbURL string) (oauth2Connector, error) {
	config := oauth2.Config{
		Credentials: oauth2.ClientCredentials{ID: clientID, Secret: clientSecret},
		AuthURL:     bitbucketAuthURL,
		TokenURL:    bitbucketTokenURL,
		AuthMethod:  oauth2.AuthMethodClientSecretPost,
		RedirectURL: cbURL,
	}

	cli, err := oauth2.NewClient(http.DefaultClient, config)
	if err != nil {
		return nil, err
	}

	return &bitbucketOAuth2Connector{
		clientID:     clientID,
		clientSecret: clientSecret,
		client:       cli,
	}, nil
}
コード例 #4
0
ファイル: connector_facebook.go プロジェクト: Tecsisa/dex
func newFacebookConnector(clientID, clientSecret, cbURL string) (oauth2Connector, error) {
	config := oauth2.Config{
		Credentials: oauth2.ClientCredentials{ID: clientID, Secret: clientSecret},
		AuthURL:     facebookConnectorAuthURL,
		TokenURL:    facebookTokenURL,
		AuthMethod:  oauth2.AuthMethodClientSecretPost,
		RedirectURL: cbURL,
		Scope:       []string{"email"},
	}

	cli, err := oauth2.NewClient(http.DefaultClient, config)
	if err != nil {
		return nil, err
	}

	return &facebookOAuth2Connector{
		clientID:     clientID,
		clientSecret: clientSecret,
		client:       cli,
	}, nil
}