fix: do not error when issuer discovery has no introspection endpoint
This commit is contained in:
parent
576bf5f0b5
commit
974bdcb0b3
1 changed files with 11 additions and 4 deletions
|
@ -77,11 +77,15 @@ func newResourceServer(issuer string, authorizer func() (interface{}, error), op
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
rs.tokenURL = config.TokenEndpoint
|
if rs.tokenURL == "" {
|
||||||
rs.introspectURL = config.IntrospectionEndpoint
|
rs.tokenURL = config.TokenEndpoint
|
||||||
|
}
|
||||||
|
if rs.introspectURL == "" {
|
||||||
|
rs.introspectURL = config.IntrospectionEndpoint
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if rs.introspectURL == "" || rs.tokenURL == "" {
|
if rs.tokenURL == "" {
|
||||||
return nil, errors.New("introspectURL and/or tokenURL is empty: please provide with either `WithStaticEndpoints` or a discovery url")
|
return nil, errors.New("tokenURL is empty: please provide with either `WithStaticEndpoints` or a discovery url")
|
||||||
}
|
}
|
||||||
rs.authFn = authorizer
|
rs.authFn = authorizer
|
||||||
return rs, nil
|
return rs, nil
|
||||||
|
@ -113,6 +117,9 @@ func WithStaticEndpoints(tokenURL, introspectURL string) Option {
|
||||||
}
|
}
|
||||||
|
|
||||||
func Introspect(ctx context.Context, rp ResourceServer, token string) (*oidc.IntrospectionResponse, error) {
|
func Introspect(ctx context.Context, rp ResourceServer, token string) (*oidc.IntrospectionResponse, error) {
|
||||||
|
if rp.IntrospectionURL() == "" {
|
||||||
|
return nil, errors.New("resource server: introspection URL is empty")
|
||||||
|
}
|
||||||
authFn, err := rp.AuthFn()
|
authFn, err := rp.AuthFn()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue