Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dex
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
dex
Commits
0086a1c1
Commit
0086a1c1
authored
Aug 29, 2016
by
Eric Chiang
Committed by
GitHub
Aug 29, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #570 from ericchiang/update-go-oidc-for-hmac-changes
Update go-oidc for hmac changes
parents
7caaca9a
4ea7cebd
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
69 additions
and
64 deletions
+69
-64
glide.lock
glide.lock
+3
-3
glide.yaml
glide.yaml
+1
-1
.travis.yml
vendor/github.com/coreos/go-oidc/.travis.yml
+1
-0
sig_hmac.go
vendor/github.com/coreos/go-oidc/jose/sig_hmac.go
+3
-2
verification.go
vendor/github.com/coreos/go-oidc/oidc/verification.go
+10
-8
verification_test.go
vendor/github.com/coreos/go-oidc/oidc/verification_test.go
+51
-50
No files found.
glide.lock
View file @
0086a1c1
hash:
9e02d162b5001e9ba3028f5cac8b8a85f73be2e7546a4add488b446821e13da6
hash:
a453b9008bef3edc06f6df648bc40048ab387bf03a3e9127cdccb817569d518e
updated: 2016-08-
16T12:24:59.70180315
2-07:00
updated: 2016-08-
27T08:50:06.02545867
2-07:00
imports:
imports:
- name: github.com/andybalholm/cascadia
- name: github.com/andybalholm/cascadia
version: 6122e68c2642b7b75c538a63b15168c6c80fb757
version: 6122e68c2642b7b75c538a63b15168c6c80fb757
- name: github.com/coreos/go-oidc
- name: github.com/coreos/go-oidc
version:
1efe0e1303a62da553fcb6beb8bd2aa9250c0ca8
version:
9fae754a41cbdc3be9cb97a180eb323b625db614
subpackages:
subpackages:
- http
- http
- jose
- jose
...
...
glide.yaml
View file @
0086a1c1
...
@@ -5,7 +5,7 @@ import:
...
@@ -5,7 +5,7 @@ import:
-
package
:
github.com/andybalholm/cascadia
-
package
:
github.com/andybalholm/cascadia
version
:
6122e68c2642b7b75c538a63b15168c6c80fb757
version
:
6122e68c2642b7b75c538a63b15168c6c80fb757
-
package
:
github.com/coreos/go-oidc
-
package
:
github.com/coreos/go-oidc
version
:
1efe0e1303a62da553fcb6beb8bd2aa9250c0ca8
version
:
9fae754a41cbdc3be9cb97a180eb323b625db614
subpackages
:
subpackages
:
-
http
-
http
-
jose
-
jose
...
...
vendor/github.com/coreos/go-oidc/.travis.yml
View file @
0086a1c1
...
@@ -4,6 +4,7 @@ go:
...
@@ -4,6 +4,7 @@ go:
-
1.4.3
-
1.4.3
-
1.5.4
-
1.5.4
-
1.6.1
-
1.6.1
-
1.7
install
:
install
:
-
go get -v -t ./...
-
go get -v -t ./...
...
...
vendor/github.com/coreos/go-oidc/jose/sig_hmac.go
100755 → 100644
View file @
0086a1c1
package
jose
package
jose
import
(
import
(
"bytes"
"crypto"
"crypto"
"crypto/hmac"
"crypto/hmac"
_
"crypto/sha256"
_
"crypto/sha256"
...
@@ -44,7 +43,9 @@ func (v *VerifierHMAC) Alg() string {
...
@@ -44,7 +43,9 @@ func (v *VerifierHMAC) Alg() string {
func
(
v
*
VerifierHMAC
)
Verify
(
sig
[]
byte
,
data
[]
byte
)
error
{
func
(
v
*
VerifierHMAC
)
Verify
(
sig
[]
byte
,
data
[]
byte
)
error
{
h
:=
hmac
.
New
(
v
.
Hash
.
New
,
v
.
Secret
)
h
:=
hmac
.
New
(
v
.
Hash
.
New
,
v
.
Secret
)
h
.
Write
(
data
)
h
.
Write
(
data
)
if
!
bytes
.
Equal
(
sig
,
h
.
Sum
(
nil
))
{
// hmac.Equal compares two hmacs but does it in constant time to mitigating time
// based attacks. See #98
if
!
hmac
.
Equal
(
sig
,
h
.
Sum
(
nil
))
{
return
errors
.
New
(
"invalid hmac signature"
)
return
errors
.
New
(
"invalid hmac signature"
)
}
}
return
nil
return
nil
...
...
vendor/github.com/coreos/go-oidc/oidc/verification.go
View file @
0086a1c1
...
@@ -161,11 +161,18 @@ func NewJWTVerifier(issuer, clientID string, syncFunc func() error, keysFunc fun
...
@@ -161,11 +161,18 @@ func NewJWTVerifier(issuer, clientID string, syncFunc func() error, keysFunc fun
}
}
func
(
v
*
JWTVerifier
)
Verify
(
jwt
jose
.
JWT
)
error
{
func
(
v
*
JWTVerifier
)
Verify
(
jwt
jose
.
JWT
)
error
{
// Verify claims before verifying the signature. This is an optimization to throw out
// tokens we know are invalid without undergoing an expensive signature check and
// possibly a re-sync event.
if
err
:=
VerifyClaims
(
jwt
,
v
.
issuer
,
v
.
clientID
);
err
!=
nil
{
return
fmt
.
Errorf
(
"oidc: JWT claims invalid: %v"
,
err
)
}
ok
,
err
:=
VerifySignature
(
jwt
,
v
.
keysFunc
())
ok
,
err
:=
VerifySignature
(
jwt
,
v
.
keysFunc
())
if
ok
{
if
err
!=
nil
{
goto
SignatureVerified
}
else
if
err
!=
nil
{
return
fmt
.
Errorf
(
"oidc: JWT signature verification failed: %v"
,
err
)
return
fmt
.
Errorf
(
"oidc: JWT signature verification failed: %v"
,
err
)
}
else
if
ok
{
return
nil
}
}
if
err
=
v
.
syncFunc
();
err
!=
nil
{
if
err
=
v
.
syncFunc
();
err
!=
nil
{
...
@@ -179,10 +186,5 @@ func (v *JWTVerifier) Verify(jwt jose.JWT) error {
...
@@ -179,10 +186,5 @@ func (v *JWTVerifier) Verify(jwt jose.JWT) error {
return
errors
.
New
(
"oidc: unable to verify JWT signature: no matching keys"
)
return
errors
.
New
(
"oidc: unable to verify JWT signature: no matching keys"
)
}
}
SignatureVerified
:
if
err
:=
VerifyClaims
(
jwt
,
v
.
issuer
,
v
.
clientID
);
err
!=
nil
{
return
fmt
.
Errorf
(
"oidc: JWT claims invalid: %v"
,
err
)
}
return
nil
return
nil
}
}
vendor/github.com/coreos/go-oidc/oidc/verification_test.go
View file @
0086a1c1
...
@@ -192,43 +192,22 @@ func TestJWTVerifier(t *testing.T) {
...
@@ -192,43 +192,22 @@ func TestJWTVerifier(t *testing.T) {
}
}
pk2
:=
*
key
.
NewPublicKey
(
priv2
.
JWK
())
pk2
:=
*
key
.
NewPublicKey
(
priv2
.
JWK
())
jwtPK1
,
err
:=
jose
.
NewSignedJWT
(
NewClaims
(
iss
,
"XXX"
,
"XXX"
,
past12
,
future12
),
priv1
.
Signer
())
newJWT
:=
func
(
issuer
,
subject
string
,
aud
interface
{},
issuedAt
,
exp
time
.
Time
,
signer
jose
.
Signer
)
jose
.
JWT
{
if
err
!=
nil
{
jwt
,
err
:=
jose
.
NewSignedJWT
(
NewClaims
(
issuer
,
subject
,
aud
,
issuedAt
,
exp
),
signer
)
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
if
err
!=
nil
{
}
t
.
Fatal
(
err
)
}
jwtPK1BadClaims
,
err
:=
jose
.
NewSignedJWT
(
NewClaims
(
iss
,
"XXX"
,
"YYY"
,
past12
,
future12
),
priv1
.
Signer
())
return
*
jwt
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
jwtPK1BadClaims2
,
err
:=
jose
.
NewSignedJWT
(
NewClaims
(
iss
,
"XXX"
,
[]
string
{
"YYY"
,
"ZZZ"
},
past12
,
future12
),
priv1
.
Signer
())
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
jwtExpired
,
err
:=
jose
.
NewSignedJWT
(
NewClaims
(
iss
,
"XXX"
,
"XXX"
,
past36
,
past12
),
priv1
.
Signer
())
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
jwtPK2
,
err
:=
jose
.
NewSignedJWT
(
NewClaims
(
iss
,
"XXX"
,
"XXX"
,
past12
,
future12
),
priv2
.
Signer
())
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
jwtPK3
,
err
:=
jose
.
NewSignedJWT
(
NewClaims
(
iss
,
"XXX"
,
[]
string
{
"ZZZ"
,
"XXX"
},
past12
,
future12
),
priv1
.
Signer
())
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
}
tests
:=
[]
struct
{
tests
:=
[]
struct
{
name
string
verifier
JWTVerifier
verifier
JWTVerifier
jwt
jose
.
JWT
jwt
jose
.
JWT
wantErr
bool
wantErr
bool
}{
}{
// JWT signed with available key
{
{
name
:
"JWT signed with available key"
,
verifier
:
JWTVerifier
{
verifier
:
JWTVerifier
{
issuer
:
"example.com"
,
issuer
:
"example.com"
,
clientID
:
"XXX"
,
clientID
:
"XXX"
,
...
@@ -237,12 +216,11 @@ func TestJWTVerifier(t *testing.T) {
...
@@ -237,12 +216,11 @@ func TestJWTVerifier(t *testing.T) {
return
[]
key
.
PublicKey
{
pk1
}
return
[]
key
.
PublicKey
{
pk1
}
},
},
},
},
jwt
:
*
jwtPK1
,
jwt
:
newJWT
(
iss
,
"XXX"
,
"XXX"
,
past12
,
future12
,
priv1
.
Signer
())
,
wantErr
:
false
,
wantErr
:
false
,
},
},
// JWT signed with available key, with bad claims
{
{
name
:
"JWT signed with available key, with bad claims"
,
verifier
:
JWTVerifier
{
verifier
:
JWTVerifier
{
issuer
:
"example.com"
,
issuer
:
"example.com"
,
clientID
:
"XXX"
,
clientID
:
"XXX"
,
...
@@ -251,12 +229,12 @@ func TestJWTVerifier(t *testing.T) {
...
@@ -251,12 +229,12 @@ func TestJWTVerifier(t *testing.T) {
return
[]
key
.
PublicKey
{
pk1
}
return
[]
key
.
PublicKey
{
pk1
}
},
},
},
},
jwt
:
*
jwtPK1BadClaims
,
jwt
:
newJWT
(
iss
,
"XXX"
,
"YYY"
,
past12
,
future12
,
priv1
.
Signer
())
,
wantErr
:
true
,
wantErr
:
true
,
},
},
// JWT signed with available key,
{
{
name
:
"JWT signed with available key"
,
verifier
:
JWTVerifier
{
verifier
:
JWTVerifier
{
issuer
:
"example.com"
,
issuer
:
"example.com"
,
clientID
:
"XXX"
,
clientID
:
"XXX"
,
...
@@ -265,12 +243,12 @@ func TestJWTVerifier(t *testing.T) {
...
@@ -265,12 +243,12 @@ func TestJWTVerifier(t *testing.T) {
return
[]
key
.
PublicKey
{
pk1
}
return
[]
key
.
PublicKey
{
pk1
}
},
},
},
},
jwt
:
*
jwtPK1BadClaims2
,
jwt
:
newJWT
(
iss
,
"XXX"
,
[]
string
{
"YYY"
,
"ZZZ"
},
past12
,
future12
,
priv1
.
Signer
())
,
wantErr
:
true
,
wantErr
:
true
,
},
},
// expired JWT signed with available key
{
{
name
:
"expired JWT signed with available key"
,
verifier
:
JWTVerifier
{
verifier
:
JWTVerifier
{
issuer
:
"example.com"
,
issuer
:
"example.com"
,
clientID
:
"XXX"
,
clientID
:
"XXX"
,
...
@@ -279,12 +257,12 @@ func TestJWTVerifier(t *testing.T) {
...
@@ -279,12 +257,12 @@ func TestJWTVerifier(t *testing.T) {
return
[]
key
.
PublicKey
{
pk1
}
return
[]
key
.
PublicKey
{
pk1
}
},
},
},
},
jwt
:
*
jwtExpired
,
jwt
:
newJWT
(
iss
,
"XXX"
,
"XXX"
,
past36
,
past12
,
priv1
.
Signer
())
,
wantErr
:
true
,
wantErr
:
true
,
},
},
// JWT signed with unrecognized key, verifiable after sync
{
{
name
:
"JWT signed with unrecognized key, verifiable after sync"
,
verifier
:
JWTVerifier
{
verifier
:
JWTVerifier
{
issuer
:
"example.com"
,
issuer
:
"example.com"
,
clientID
:
"XXX"
,
clientID
:
"XXX"
,
...
@@ -300,12 +278,12 @@ func TestJWTVerifier(t *testing.T) {
...
@@ -300,12 +278,12 @@ func TestJWTVerifier(t *testing.T) {
}
}
}(),
}(),
},
},
jwt
:
*
jwtPK2
,
jwt
:
newJWT
(
iss
,
"XXX"
,
"XXX"
,
past36
,
future12
,
priv2
.
Signer
())
,
wantErr
:
false
,
wantErr
:
false
,
},
},
// JWT signed with unrecognized key, not verifiable after sync
{
{
name
:
"JWT signed with unrecognized key, not verifiable after sync"
,
verifier
:
JWTVerifier
{
verifier
:
JWTVerifier
{
issuer
:
"example.com"
,
issuer
:
"example.com"
,
clientID
:
"XXX"
,
clientID
:
"XXX"
,
...
@@ -314,12 +292,12 @@ func TestJWTVerifier(t *testing.T) {
...
@@ -314,12 +292,12 @@ func TestJWTVerifier(t *testing.T) {
return
[]
key
.
PublicKey
{
pk1
}
return
[]
key
.
PublicKey
{
pk1
}
},
},
},
},
jwt
:
*
jwtPK2
,
jwt
:
newJWT
(
iss
,
"XXX"
,
"XXX"
,
past12
,
future12
,
priv2
.
Signer
())
,
wantErr
:
true
,
wantErr
:
true
,
},
},
// verifier gets no keys from keysFunc, still not verifiable after sync
{
{
name
:
"verifier gets no keys from keysFunc, still not verifiable after sync"
,
verifier
:
JWTVerifier
{
verifier
:
JWTVerifier
{
issuer
:
"example.com"
,
issuer
:
"example.com"
,
clientID
:
"XXX"
,
clientID
:
"XXX"
,
...
@@ -328,12 +306,12 @@ func TestJWTVerifier(t *testing.T) {
...
@@ -328,12 +306,12 @@ func TestJWTVerifier(t *testing.T) {
return
[]
key
.
PublicKey
{}
return
[]
key
.
PublicKey
{}
},
},
},
},
jwt
:
*
jwtPK1
,
jwt
:
newJWT
(
iss
,
"XXX"
,
"XXX"
,
past12
,
future12
,
priv1
.
Signer
())
,
wantErr
:
true
,
wantErr
:
true
,
},
},
// verifier gets no keys from keysFunc, verifiable after sync
{
{
name
:
"verifier gets no keys from keysFunc, verifiable after sync"
,
verifier
:
JWTVerifier
{
verifier
:
JWTVerifier
{
issuer
:
"example.com"
,
issuer
:
"example.com"
,
clientID
:
"XXX"
,
clientID
:
"XXX"
,
...
@@ -349,12 +327,12 @@ func TestJWTVerifier(t *testing.T) {
...
@@ -349,12 +327,12 @@ func TestJWTVerifier(t *testing.T) {
}
}
}(),
}(),
},
},
jwt
:
*
jwtPK2
,
jwt
:
newJWT
(
iss
,
"XXX"
,
"XXX"
,
past12
,
future12
,
priv2
.
Signer
())
,
wantErr
:
false
,
wantErr
:
false
,
},
},
// JWT signed with available key, 'aud' is a string array.
{
{
name
:
"JWT signed with available key, 'aud' is a string array"
,
verifier
:
JWTVerifier
{
verifier
:
JWTVerifier
{
issuer
:
"example.com"
,
issuer
:
"example.com"
,
clientID
:
"XXX"
,
clientID
:
"XXX"
,
...
@@ -363,17 +341,40 @@ func TestJWTVerifier(t *testing.T) {
...
@@ -363,17 +341,40 @@ func TestJWTVerifier(t *testing.T) {
return
[]
key
.
PublicKey
{
pk1
}
return
[]
key
.
PublicKey
{
pk1
}
},
},
},
},
jwt
:
*
jwtPK3
,
jwt
:
newJWT
(
iss
,
"XXX"
,
[]
string
{
"ZZZ"
,
"XXX"
},
past12
,
future12
,
priv1
.
Signer
())
,
wantErr
:
false
,
wantErr
:
false
,
},
},
{
name
:
"invalid issuer claim shouldn't trigger sync"
,
verifier
:
JWTVerifier
{
issuer
:
"example.com"
,
clientID
:
"XXX"
,
syncFunc
:
func
()
error
{
t
.
Errorf
(
"invalid issuer claim shouldn't trigger a sync"
)
return
nil
},
keysFunc
:
func
()
func
()
[]
key
.
PublicKey
{
var
i
int
return
func
()
[]
key
.
PublicKey
{
defer
func
()
{
i
++
}()
return
[][]
key
.
PublicKey
{
[]
key
.
PublicKey
{},
[]
key
.
PublicKey
{
pk2
},
}[
i
]
}
}(),
},
jwt
:
newJWT
(
"invalid-issuer"
,
"XXX"
,
[]
string
{
"ZZZ"
,
"XXX"
},
past12
,
future12
,
priv2
.
Signer
()),
wantErr
:
true
,
},
}
}
for
i
,
tt
:=
range
tests
{
for
_
,
tt
:=
range
tests
{
err
:=
tt
.
verifier
.
Verify
(
tt
.
jwt
)
err
:=
tt
.
verifier
.
Verify
(
tt
.
jwt
)
if
tt
.
wantErr
&&
(
err
==
nil
)
{
if
tt
.
wantErr
&&
(
err
==
nil
)
{
t
.
Errorf
(
"case %
d: wanted non-nil error"
,
i
)
t
.
Errorf
(
"case %
q: wanted non-nil error"
,
tt
.
name
)
}
else
if
!
tt
.
wantErr
&&
(
err
!=
nil
)
{
}
else
if
!
tt
.
wantErr
&&
(
err
!=
nil
)
{
t
.
Errorf
(
"case %
d: wanted nil error, got %v"
,
i
,
err
)
t
.
Errorf
(
"case %
q: wanted nil error, got %v"
,
tt
.
name
,
err
)
}
}
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment