forked from remote/oauth2
Clone authURL.
This commit is contained in:
5
jwt.go
5
jwt.go
@@ -43,9 +43,8 @@ type JWTOptions struct {
|
|||||||
// NewJWTConfig creates a new configuration with the specified options
|
// NewJWTConfig creates a new configuration with the specified options
|
||||||
// and OAuth2 provider endpoint.
|
// and OAuth2 provider endpoint.
|
||||||
func NewJWTConfig(opts *JWTOptions, aud string) (*JWTConfig, error) {
|
func NewJWTConfig(opts *JWTOptions, aud string) (*JWTConfig, error) {
|
||||||
var audURL *url.URL
|
audURL, err := url.Parse(aud)
|
||||||
var err error
|
if err != nil {
|
||||||
if audURL, err = url.Parse(aud); err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
contents, err := ioutil.ReadFile(opts.PemFilename)
|
contents, err := ioutil.ReadFile(opts.PemFilename)
|
||||||
|
|||||||
18
oauth2.go
18
oauth2.go
@@ -79,12 +79,12 @@ type Options struct {
|
|||||||
// NewConfig creates a generic OAuth 2.0 configuration that talks
|
// NewConfig creates a generic OAuth 2.0 configuration that talks
|
||||||
// to an OAuth 2.0 provider specified with authURL and tokenURL.
|
// to an OAuth 2.0 provider specified with authURL and tokenURL.
|
||||||
func NewConfig(opts *Options, authURL, tokenURL string) (*Config, error) {
|
func NewConfig(opts *Options, authURL, tokenURL string) (*Config, error) {
|
||||||
var aURL, tURL *url.URL
|
aURL, err := url.Parse(authURL)
|
||||||
var err error
|
if err != nil {
|
||||||
if aURL, err = url.Parse(authURL); err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if tURL, err = url.Parse(tokenURL); err != nil {
|
tURL, err := url.Parse(tokenURL)
|
||||||
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
conf := &Config{opts: opts, authURL: aURL, tokenURL: tURL}
|
conf := &Config{opts: opts, authURL: aURL, tokenURL: tURL}
|
||||||
@@ -107,15 +107,7 @@ type Config struct {
|
|||||||
// AuthCodeURL returns a URL to OAuth 2.0 provider's consent page
|
// AuthCodeURL returns a URL to OAuth 2.0 provider's consent page
|
||||||
// that asks for permissions for the required scopes explicitly.
|
// that asks for permissions for the required scopes explicitly.
|
||||||
func (c *Config) AuthCodeURL(state string) (authURL string) {
|
func (c *Config) AuthCodeURL(state string) (authURL string) {
|
||||||
u := url.URL{
|
u := *c.authURL
|
||||||
Scheme: c.authURL.Scheme,
|
|
||||||
Opaque: c.authURL.Opaque,
|
|
||||||
User: c.authURL.User,
|
|
||||||
Host: c.authURL.Host,
|
|
||||||
Path: c.authURL.Path,
|
|
||||||
RawQuery: c.authURL.RawQuery,
|
|
||||||
Fragment: c.authURL.Fragment,
|
|
||||||
}
|
|
||||||
q := url.Values{
|
q := url.Values{
|
||||||
"response_type": {"code"},
|
"response_type": {"code"},
|
||||||
"client_id": {c.opts.ClientID},
|
"client_id": {c.opts.ClientID},
|
||||||
|
|||||||
Reference in New Issue
Block a user