*: update go-oidc to shorten length of key IDs
This commit is contained in:
parent
bdaded57b8
commit
f5a85e9764
4 changed files with 25 additions and 11 deletions
6
glide.lock
generated
6
glide.lock
generated
|
@ -1,10 +1,10 @@
|
||||||
hash: ed84ba1c371faf2f9a0bf64f6a7767a017e663cb99afa273ec5659432bb474d5
|
hash: 2e6ef5ae85fe17d9b695b37ba6875b438a617692cc1f6fefc682c4e405a4dcf1
|
||||||
updated: 2016-06-28T10:15:56.223659517-07:00
|
updated: 2016-06-28T10:36:39.146887182-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: 8ae400b75540a4f57ec549a89b3e9d994c636f2a
|
version: 5aa9381f6e998aa16cc96b4347d33dcc29792864
|
||||||
subpackages:
|
subpackages:
|
||||||
- http
|
- http
|
||||||
- jose
|
- jose
|
||||||
|
|
|
@ -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: 8ae400b75540a4f57ec549a89b3e9d994c636f2a
|
version: 5aa9381f6e998aa16cc96b4347d33dcc29792864
|
||||||
subpackages:
|
subpackages:
|
||||||
- http
|
- http
|
||||||
- jose
|
- jose
|
||||||
|
|
14
vendor/github.com/coreos/go-oidc/key/key.go
generated
vendored
14
vendor/github.com/coreos/go-oidc/key/key.go
generated
vendored
|
@ -3,9 +3,9 @@ package key
|
||||||
import (
|
import (
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"crypto/rsa"
|
"crypto/rsa"
|
||||||
"encoding/base64"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"math/big"
|
"io"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/coreos/go-oidc/jose"
|
"github.com/coreos/go-oidc/jose"
|
||||||
|
@ -139,15 +139,15 @@ func GeneratePrivateKey() (*PrivateKey, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
keyID := make([]byte, 20)
|
||||||
|
if _, err := io.ReadFull(rand.Reader, keyID); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
k := PrivateKey{
|
k := PrivateKey{
|
||||||
KeyID: base64BigInt(pk.PublicKey.N),
|
KeyID: hex.EncodeToString(keyID),
|
||||||
PrivateKey: pk,
|
PrivateKey: pk,
|
||||||
}
|
}
|
||||||
|
|
||||||
return &k, nil
|
return &k, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func base64BigInt(b *big.Int) string {
|
|
||||||
return base64.URLEncoding.EncodeToString(b.Bytes())
|
|
||||||
}
|
|
||||||
|
|
14
vendor/github.com/coreos/go-oidc/key/key_test.go
generated
vendored
14
vendor/github.com/coreos/go-oidc/key/key_test.go
generated
vendored
|
@ -87,3 +87,17 @@ func TestPublicKeyMarshalJSON(t *testing.T) {
|
||||||
t.Errorf("got != want:\n%s\n%s", got, want)
|
t.Errorf("got != want:\n%s\n%s", got, want)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestGeneratePrivateKeyIDs(t *testing.T) {
|
||||||
|
key1, err := GeneratePrivateKey()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("GeneratePrivateKey(): %v", err)
|
||||||
|
}
|
||||||
|
key2, err := GeneratePrivateKey()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("GeneratePrivateKey(): %v", err)
|
||||||
|
}
|
||||||
|
if key1.KeyID == key2.KeyID {
|
||||||
|
t.Fatalf("expected different keys to have different key IDs")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Reference in a new issue