fixes
This commit is contained in:
parent
b60f1ed7a8
commit
251c476e17
4 changed files with 23 additions and 21 deletions
|
@ -43,7 +43,7 @@ func main() {
|
|||
state := func() string {
|
||||
return uuid.New().String()
|
||||
}
|
||||
token := cli.CodeFlow(relyingParty, callbackPath, port, state)
|
||||
token := cli.CodeFlow(ctx, relyingParty, callbackPath, port, state)
|
||||
|
||||
client := github.NewClient(relyingParty.OAuthConfig().Client(ctx, token.Token))
|
||||
|
||||
|
|
|
@ -170,17 +170,18 @@ func NewRelyingPartyOIDC(issuer, clientID, clientSecret, redirectURI string, sco
|
|||
return nil, err
|
||||
}
|
||||
}
|
||||
endpoints, err := Discover(rp.issuer, rp.httpClient)
|
||||
config, err := client.Discover(rp.issuer, rp.httpClient)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
endpoints := GetEndpoints(config)
|
||||
rp.oauthConfig.Endpoint = endpoints.Endpoint
|
||||
rp.endpoints = endpoints
|
||||
|
||||
return rp, nil
|
||||
}
|
||||
|
||||
//DefaultRPOpts is the type for providing dynamic options to the DefaultRP
|
||||
//Option is the type for providing dynamic options to the relyingParty
|
||||
type Option func(*relyingParty) error
|
||||
|
||||
//WithCookieHandler set a `CookieHandler` for securing the various redirects
|
||||
|
|
|
@ -52,6 +52,20 @@ func (e *Error) IsRedirectDisabled() bool {
|
|||
return e.redirectDisabled
|
||||
}
|
||||
|
||||
type errorType string
|
||||
|
||||
const (
|
||||
InvalidRequest errorType = "invalid_request"
|
||||
InvalidScope errorType = "invalid_scope"
|
||||
InvalidClient errorType = "invalid_client"
|
||||
InvalidGrant errorType = "invalid_grant"
|
||||
UnauthorizedClient errorType = "unauthorized_client"
|
||||
UnsupportedGrantType errorType = "unsupported_grant_type"
|
||||
ServerError errorType = "server_error"
|
||||
InteractionRequired errorType = "interaction_required"
|
||||
LoginRequired errorType = "login_required"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrInvalidRequest = func() *Error {
|
||||
return &Error{
|
||||
|
@ -117,17 +131,3 @@ func DefaultToServerError(err error, description string) *Error {
|
|||
}
|
||||
return oauth
|
||||
}
|
||||
|
||||
type errorType string
|
||||
|
||||
const (
|
||||
InvalidRequest errorType = "invalid_request"
|
||||
InvalidScope errorType = "invalid_scope"
|
||||
InvalidClient errorType = "invalid_client"
|
||||
InvalidGrant errorType = "invalid_grant"
|
||||
UnauthorizedClient errorType = "unauthorized_client"
|
||||
UnsupportedGrantType errorType = "unsupported_grant_type"
|
||||
ServerError errorType = "server_error"
|
||||
InteractionRequired errorType = "interaction_required"
|
||||
LoginRequired errorType = "login_required"
|
||||
)
|
||||
|
|
|
@ -7,12 +7,13 @@ import (
|
|||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"github.com/caos/oidc/pkg/oidc"
|
||||
"github.com/caos/oidc/pkg/op"
|
||||
"github.com/caos/oidc/pkg/op/mock"
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"gopkg.in/square/go-jose.v2"
|
||||
|
||||
"github.com/caos/oidc/pkg/oidc"
|
||||
"github.com/caos/oidc/pkg/op"
|
||||
"github.com/caos/oidc/pkg/op/mock"
|
||||
)
|
||||
|
||||
func TestKeys(t *testing.T) {
|
||||
|
@ -34,7 +35,7 @@ func TestKeys(t *testing.T) {
|
|||
args: args{
|
||||
k: func() op.KeyProvider {
|
||||
m := mock.NewMockKeyProvider(gomock.NewController(t))
|
||||
m.EXPECT().GetKeySet(gomock.Any()).Return(nil, oidc.ErrServerError)
|
||||
m.EXPECT().GetKeySet(gomock.Any()).Return(nil, oidc.ErrServerError())
|
||||
return m
|
||||
}(),
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue