fix capitalization
This commit is contained in:
parent
127ae4b638
commit
23fe668668
8 changed files with 18 additions and 18 deletions
|
@ -152,7 +152,7 @@ func ValidateAuthReqIDTokenHint(ctx context.Context, idTokenHint string, verifie
|
||||||
if idTokenHint == "" {
|
if idTokenHint == "" {
|
||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
claims, err := verifier.VerifyIdToken(ctx, idTokenHint)
|
claims, err := verifier.VerifyIDToken(ctx, idTokenHint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", ErrInvalidRequest("The id_token_hint is invalid. If you have any questions, you may contact the administrator of the application.")
|
return "", ErrInvalidRequest("The id_token_hint is invalid. If you have any questions, you may contact the administrator of the application.")
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
|
|
||||||
const (
|
const (
|
||||||
InvalidRequest errorType = "invalid_request"
|
InvalidRequest errorType = "invalid_request"
|
||||||
InvalidRequestUri errorType = "invalid_request_uri"
|
InvalidRequestURI errorType = "invalid_request_uri"
|
||||||
InteractionRequired errorType = "interaction_required"
|
InteractionRequired errorType = "interaction_required"
|
||||||
ServerError errorType = "server_error"
|
ServerError errorType = "server_error"
|
||||||
)
|
)
|
||||||
|
@ -24,7 +24,7 @@ var (
|
||||||
}
|
}
|
||||||
ErrInvalidRequestRedirectURI = func(description string) *OAuthError {
|
ErrInvalidRequestRedirectURI = func(description string) *OAuthError {
|
||||||
return &OAuthError{
|
return &OAuthError{
|
||||||
ErrorType: InvalidRequestUri,
|
ErrorType: InvalidRequestURI,
|
||||||
Description: description,
|
Description: description,
|
||||||
redirectDisabled: true,
|
redirectDisabled: true,
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ type Verifier struct{}
|
||||||
func (v *Verifier) Verify(ctx context.Context, accessToken, idToken string) (*oidc.IDTokenClaims, error) {
|
func (v *Verifier) Verify(ctx context.Context, accessToken, idToken string) (*oidc.IDTokenClaims, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
func (v *Verifier) VerifyIdToken(ctx context.Context, idToken string) (*oidc.IDTokenClaims, error) {
|
func (v *Verifier) VerifyIDToken(ctx context.Context, idToken string) (*oidc.IDTokenClaims, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ func ValidateEndSessionRequest(ctx context.Context, req *oidc.EndSessionRequest,
|
||||||
if req.IdTokenHint == "" {
|
if req.IdTokenHint == "" {
|
||||||
return session, nil
|
return session, nil
|
||||||
}
|
}
|
||||||
claims, err := ender.IDTokenVerifier().VerifyIdToken(ctx, req.IdTokenHint)
|
claims, err := ender.IDTokenVerifier().VerifyIDToken(ctx, req.IdTokenHint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, ErrInvalidRequest("id_token_hint invalid")
|
return nil, ErrInvalidRequest("id_token_hint invalid")
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,7 +148,7 @@ func DefaultACRVerifier(possibleValues []string) ACRVerifier {
|
||||||
//and https://openid.net/specs/openid-connect-core-1_0.html#CodeFlowTokenValidation
|
//and https://openid.net/specs/openid-connect-core-1_0.html#CodeFlowTokenValidation
|
||||||
func (v *DefaultVerifier) Verify(ctx context.Context, accessToken, idTokenString string) (*oidc.IDTokenClaims, error) {
|
func (v *DefaultVerifier) Verify(ctx context.Context, accessToken, idTokenString string) (*oidc.IDTokenClaims, error) {
|
||||||
v.config.now = time.Now().UTC()
|
v.config.now = time.Now().UTC()
|
||||||
idToken, err := v.VerifyIdToken(ctx, idTokenString)
|
idToken, err := v.VerifyIDToken(ctx, idTokenString)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -158,9 +158,9 @@ func (v *DefaultVerifier) Verify(ctx context.Context, accessToken, idTokenString
|
||||||
return idToken, nil
|
return idToken, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//Verify implements the `VerifyIdToken` method of the `Verifier` interface
|
//Verify implements the `VerifyIDToken` method of the `Verifier` interface
|
||||||
//according to https://openid.net/specs/openid-connect-core-1_0.html#IDTokenValidation
|
//according to https://openid.net/specs/openid-connect-core-1_0.html#IDTokenValidation
|
||||||
func (v *DefaultVerifier) VerifyIdToken(ctx context.Context, idTokenString string) (*oidc.IDTokenClaims, error) {
|
func (v *DefaultVerifier) VerifyIDToken(ctx context.Context, idTokenString string) (*oidc.IDTokenClaims, error) {
|
||||||
//1. if encrypted --> decrypt
|
//1. if encrypted --> decrypt
|
||||||
decrypted, err := v.decryptToken(idTokenString)
|
decrypted, err := v.decryptToken(idTokenString)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -49,17 +49,17 @@ func (mr *MockVerifierMockRecorder) Verify(arg0, arg1, arg2 interface{}) *gomock
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Verify", reflect.TypeOf((*MockVerifier)(nil).Verify), arg0, arg1, arg2)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Verify", reflect.TypeOf((*MockVerifier)(nil).Verify), arg0, arg1, arg2)
|
||||||
}
|
}
|
||||||
|
|
||||||
// VerifyIdToken mocks base method
|
// VerifyIDToken mocks base method
|
||||||
func (m *MockVerifier) VerifyIdToken(arg0 context.Context, arg1 string) (*oidc.IDTokenClaims, error) {
|
func (m *MockVerifier) VerifyIDToken(arg0 context.Context, arg1 string) (*oidc.IDTokenClaims, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "VerifyIdToken", arg0, arg1)
|
ret := m.ctrl.Call(m, "VerifyIDToken", arg0, arg1)
|
||||||
ret0, _ := ret[0].(*oidc.IDTokenClaims)
|
ret0, _ := ret[0].(*oidc.IDTokenClaims)
|
||||||
ret1, _ := ret[1].(error)
|
ret1, _ := ret[1].(error)
|
||||||
return ret0, ret1
|
return ret0, ret1
|
||||||
}
|
}
|
||||||
|
|
||||||
// VerifyIdToken indicates an expected call of VerifyIdToken
|
// VerifyIDToken indicates an expected call of VerifyIDToken
|
||||||
func (mr *MockVerifierMockRecorder) VerifyIdToken(arg0, arg1 interface{}) *gomock.Call {
|
func (mr *MockVerifierMockRecorder) VerifyIDToken(arg0, arg1 interface{}) *gomock.Call {
|
||||||
mr.mock.ctrl.T.Helper()
|
mr.mock.ctrl.T.Helper()
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VerifyIdToken", reflect.TypeOf((*MockVerifier)(nil).VerifyIdToken), arg0, arg1)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VerifyIDToken", reflect.TypeOf((*MockVerifier)(nil).VerifyIDToken), arg0, arg1)
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ func NewMockVerifierExpectInvalid(t *testing.T) rp.Verifier {
|
||||||
|
|
||||||
func ExpectVerifyInvalid(v rp.Verifier) {
|
func ExpectVerifyInvalid(v rp.Verifier) {
|
||||||
mock := v.(*MockVerifier)
|
mock := v.(*MockVerifier)
|
||||||
mock.EXPECT().VerifyIdToken(gomock.Any(), gomock.Any()).Return(nil, errors.New("invalid"))
|
mock.EXPECT().VerifyIDToken(gomock.Any(), gomock.Any()).Return(nil, errors.New("invalid"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMockVerifierExpectValid(t *testing.T) rp.Verifier {
|
func NewMockVerifierExpectValid(t *testing.T) rp.Verifier {
|
||||||
|
@ -33,5 +33,5 @@ func NewMockVerifierExpectValid(t *testing.T) rp.Verifier {
|
||||||
|
|
||||||
func ExpectVerifyValid(v rp.Verifier) {
|
func ExpectVerifyValid(v rp.Verifier) {
|
||||||
mock := v.(*MockVerifier)
|
mock := v.(*MockVerifier)
|
||||||
mock.EXPECT().VerifyIdToken(gomock.Any(), gomock.Any()).Return(&oidc.IDTokenClaims{Userinfo: oidc.Userinfo{Subject: "id"}}, nil)
|
mock.EXPECT().VerifyIDToken(gomock.Any(), gomock.Any()).Return(&oidc.IDTokenClaims{Userinfo: oidc.Userinfo{Subject: "id"}}, nil)
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,6 @@ type Verifier interface {
|
||||||
//Verify checks the access_token and id_token and returns the `id token claims`
|
//Verify checks the access_token and id_token and returns the `id token claims`
|
||||||
Verify(ctx context.Context, accessToken, idTokenString string) (*oidc.IDTokenClaims, error)
|
Verify(ctx context.Context, accessToken, idTokenString string) (*oidc.IDTokenClaims, error)
|
||||||
|
|
||||||
//VerifyIdToken checks the id_token only and returns its `id token claims`
|
//VerifyIDToken checks the id_token only and returns its `id token claims`
|
||||||
VerifyIdToken(ctx context.Context, idTokenString string) (*oidc.IDTokenClaims, error)
|
VerifyIDToken(ctx context.Context, idTokenString string) (*oidc.IDTokenClaims, error)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue