Merge branch 'master' into service-accounts

This commit is contained in:
Livio Amstutz 2020-09-10 16:21:40 +02:00
commit 6be292a984
5 changed files with 22 additions and 11 deletions

View file

@ -5,7 +5,7 @@ jobs:
runs-on: ubuntu-18.04 runs-on: ubuntu-18.04
strategy: strategy:
matrix: matrix:
go: ['1.11', '1.12', '1.13', '1.14'] go: ['1.14', '1.15']
name: Go ${{ matrix.go }} test name: Go ${{ matrix.go }} test
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2

View file

@ -39,11 +39,9 @@ For your convinience you can find the relevant standards linked below.
| Version | Supported | | Version | Supported |
|---------|--------------------| |---------|--------------------|
| <1.11 | :x: | | <1.13 | :x: |
| 1.11 | :white_check_mark: |
| 1.12 | :white_check_mark: |
| 1.13 | :white_check_mark: |
| 1.14 | :white_check_mark: | | 1.14 | :white_check_mark: |
| 1.15 | :white_check_mark: |
## Why another library ## Why another library

2
go.mod
View file

@ -1,6 +1,6 @@
module github.com/caos/oidc module github.com/caos/oidc
go 1.13 go 1.15
require ( require (
github.com/caos/logging v0.0.0-20191210002624-b3260f690a6a github.com/caos/logging v0.0.0-20191210002624-b3260f690a6a

View file

@ -277,10 +277,16 @@ func timeToJSON(t time.Time) int64 {
return t.Unix() return t.Unix()
} }
func audienceFromJSON(audience interface{}) []string { func audienceFromJSON(i interface{}) []string {
switch aud := audience.(type) { switch aud := i.(type) {
case []string: case []string:
return aud return aud
case []interface{}:
audience := make([]string, len(aud))
for i, a := range aud {
audience[i] = a.(string)
}
return audience
case string: case string:
return []string{aud} return []string{aud}
} }

View file

@ -40,8 +40,9 @@ type DefaultRP struct {
errorHandler func(http.ResponseWriter, *http.Request, string, string, string) errorHandler func(http.ResponseWriter, *http.Request, string, string, string)
verifier Verifier verifier Verifier
onlyOAuth2 bool verifierOpts []ConfFunc
onlyOAuth2 bool
} }
//NewDefaultRP creates `DefaultRP` with the given //NewDefaultRP creates `DefaultRP` with the given
@ -79,7 +80,7 @@ func NewDefaultRP(rpConfig *Config, rpOpts ...DefaultRPOpts) (DelegationTokenExc
} }
if p.verifier == nil { if p.verifier == nil {
p.verifier = NewDefaultVerifier(rpConfig.Issuer, rpConfig.ClientID, NewRemoteKeySet(p.httpClient, p.endpoints.JKWsURL)) p.verifier = NewDefaultVerifier(rpConfig.Issuer, rpConfig.ClientID, NewRemoteKeySet(p.httpClient, p.endpoints.JKWsURL), p.verifierOpts...)
} }
return p, nil return p, nil
@ -112,6 +113,12 @@ func WithHTTPClient(client *http.Client) DefaultRPOpts {
} }
} }
func WithVerifierOpts(opts ...ConfFunc) DefaultRPOpts {
return func(p *DefaultRP) {
p.verifierOpts = opts
}
}
//AuthURL is the `RelayingParty` interface implementation //AuthURL is the `RelayingParty` interface implementation
//wrapping the oauth2 `AuthCodeURL` //wrapping the oauth2 `AuthCodeURL`
//returning the url of the auth request //returning the url of the auth request