chore: additional errors and error improvements that catch problems earlier
This commit is contained in:
parent
0d721d937e
commit
c0badf2329
2 changed files with 14 additions and 1 deletions
|
@ -2,6 +2,7 @@ package op
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
@ -78,6 +79,14 @@ func Authorize(w http.ResponseWriter, r *http.Request, authorizer Authorizer) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if authReq.ClientID == "" {
|
||||||
|
AuthRequestError(w, r, authReq, fmt.Errorf("auth request is missing client_id"), authorizer.Encoder())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if authReq.RedirectURI == "" {
|
||||||
|
AuthRequestError(w, r, authReq, fmt.Errorf("auth request is missing redirect_uri"), authorizer.Encoder())
|
||||||
|
return
|
||||||
|
}
|
||||||
validation := ValidateAuthRequest
|
validation := ValidateAuthRequest
|
||||||
if validater, ok := authorizer.(AuthorizeValidator); ok {
|
if validater, ok := authorizer.(AuthorizeValidator); ok {
|
||||||
validation = validater.ValidateAuthRequest
|
validation = validater.ValidateAuthRequest
|
||||||
|
@ -378,6 +387,10 @@ func RedirectToLogin(authReqID string, client Client, w http.ResponseWriter, r *
|
||||||
func AuthorizeCallback(w http.ResponseWriter, r *http.Request, authorizer Authorizer) {
|
func AuthorizeCallback(w http.ResponseWriter, r *http.Request, authorizer Authorizer) {
|
||||||
params := mux.Vars(r)
|
params := mux.Vars(r)
|
||||||
id := params["id"]
|
id := params["id"]
|
||||||
|
if id == "" {
|
||||||
|
AuthRequestError(w, r, nil, fmt.Errorf("auth request callback is missing id"), authorizer.Encoder())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
authReq, err := authorizer.Storage().AuthRequestByID(r.Context(), id)
|
authReq, err := authorizer.Storage().AuthRequestByID(r.Context(), id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -53,7 +53,7 @@ func ValidateAccessTokenRequest(ctx context.Context, tokenReq *oidc.AccessTokenR
|
||||||
return nil, nil, oidc.ErrInvalidGrant()
|
return nil, nil, oidc.ErrInvalidGrant()
|
||||||
}
|
}
|
||||||
if !ValidateGrantType(client, oidc.GrantTypeCode) {
|
if !ValidateGrantType(client, oidc.GrantTypeCode) {
|
||||||
return nil, nil, oidc.ErrUnauthorizedClient()
|
return nil, nil, oidc.ErrUnauthorizedClient().WithDescription("client missing grant type " + string(oidc.GrantTypeCode))
|
||||||
}
|
}
|
||||||
if tokenReq.RedirectURI != authReq.GetRedirectURI() {
|
if tokenReq.RedirectURI != authReq.GetRedirectURI() {
|
||||||
return nil, nil, oidc.ErrInvalidGrant().WithDescription("redirect_uri does not correspond")
|
return nil, nil, oidc.ErrInvalidGrant().WithDescription("redirect_uri does not correspond")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue