renaming, mocking and begin tests
This commit is contained in:
parent
3d5de74d02
commit
85b71e0867
14 changed files with 309 additions and 18 deletions
|
@ -1,4 +1,4 @@
|
|||
package server
|
||||
package op
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
@ -7,6 +7,7 @@ import (
|
|||
"github.com/gorilla/schema"
|
||||
|
||||
"github.com/caos/oidc/pkg/oidc"
|
||||
str_utils "github.com/caos/utils/strings"
|
||||
)
|
||||
|
||||
func ParseAuthRequest(w http.ResponseWriter, r *http.Request) (*oidc.AuthRequest, error) {
|
||||
|
@ -24,6 +25,31 @@ func ParseAuthRequest(w http.ResponseWriter, r *http.Request) (*oidc.AuthRequest
|
|||
return authReq, err
|
||||
}
|
||||
|
||||
func ValidateAuthRequest(authRequest *oidc.AuthRequest) error {
|
||||
func ValidateAuthRequest(authRequest *oidc.AuthRequest, storage Storage) error {
|
||||
|
||||
if err := ValidateRedirectURI(authRequest.RedirectURI, authRequest.ClientID, storage); err != nil {
|
||||
return err
|
||||
}
|
||||
return errors.New("Unimplemented") //TODO: impl https://openid.net/specs/openid-connect-core-1_0.html#rfc.section.3.1.2.2
|
||||
|
||||
// if NeedsExistingSession(authRequest) {
|
||||
// session, err := storage.CheckSession(authRequest)
|
||||
// if err != nil {
|
||||
// //TODO: return err
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
func ValidateRedirectURI(uri, client_id string, storage Storage) error {
|
||||
if uri == "" {
|
||||
return errors.New("redirect_uri must not be empty") //TODO:
|
||||
}
|
||||
client, err := storage.GetClientByClientID(client_id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !str_utils.Contains(client.RedirectURIs(), uri) {
|
||||
return errors.New("redirect_uri not allowed")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue