This commit is contained in:
Livio Amstutz 2019-11-28 08:01:31 +01:00
parent d1d04295a6
commit 8ee38d2ec8
14 changed files with 469 additions and 85 deletions

View file

@ -29,6 +29,8 @@ github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y
github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/mux v1.7.3 h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw=

View file

@ -1,6 +1,8 @@
package mock
import (
"errors"
"github.com/caos/oidc/pkg/oidc"
)
@ -11,7 +13,10 @@ func (s *Storage) CreateAuthRequest(authReq *oidc.AuthRequest) error {
authReq.ID = "id"
return nil
}
func (s *Storage) GetClientByClientID(string) (oidc.Client, error) {
func (s *Storage) GetClientByClientID(id string) (oidc.Client, error) {
if id == "not" {
return nil, errors.New("not found")
}
return &ConfClient{}, nil
}
func (s *Storage) AuthRequestByCode(oidc.Client, string, string) (*oidc.AuthRequest, error) {
@ -26,12 +31,26 @@ func (s *Storage) AuthorizeClientIDCodeVerifier(string, string) (oidc.Client, er
func (s *Storage) DeleteAuthRequestAndCode(string, string) error {
return nil
}
func (s *Storage) AuthRequestByID(id string) (*oidc.AuthRequest, error) {
if id == "none" {
return nil, errors.New("not found")
}
var responseType oidc.ResponseType
if id == "code" {
responseType = oidc.ResponseTypeCode
} else if id == "id" {
responseType = oidc.ResponseTypeIDTokenOnly
} else {
responseType = oidc.ResponseTypeIDToken
}
return &oidc.AuthRequest{
ResponseType: responseType,
RedirectURI: "/callback",
}, nil
}
type ConfClient struct{}
func (c *ConfClient) Type() oidc.ClientType {
return oidc.ClientTypeConfidential
}
func (c *ConfClient) RedirectURIs() []string {
return []string{
"https://registered.com/callback",
@ -43,3 +62,7 @@ func (c *ConfClient) RedirectURIs() []string {
func (c *ConfClient) LoginURL(id string) string {
return "login?id=" + id
}
func (c *ConfClient) ApplicationType() oidc.ApplicationType {
return oidc.ApplicationTypeWeb
}