mirror of
https://github.com/pomerium/pomerium.git
synced 2025-07-23 11:39:32 +02:00
mcp: add /authorize request part
This commit is contained in:
parent
b4e762e70e
commit
b9b1754fcd
14 changed files with 573 additions and 3 deletions
40
internal/oauth21/validate_client.go
Normal file
40
internal/oauth21/validate_client.go
Normal file
|
@ -0,0 +1,40 @@
|
|||
package oauth21
|
||||
|
||||
import (
|
||||
"slices"
|
||||
|
||||
"github.com/pomerium/pomerium/internal/oauth21/gen"
|
||||
rfc7591v1 "github.com/pomerium/pomerium/internal/rfc7591"
|
||||
)
|
||||
|
||||
func ValidateAuthorizationRequest(
|
||||
client *rfc7591v1.ClientRegistrationRequest,
|
||||
req *gen.AuthorizationRequest,
|
||||
) error {
|
||||
if err := ValidateAuthorizationRequestRedirectURI(client, req.RedirectUri); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func ValidateAuthorizationRequestRedirectURI(
|
||||
client *rfc7591v1.ClientRegistrationRequest,
|
||||
redirectURI *string,
|
||||
) error {
|
||||
if len(client.RedirectUris) == 0 {
|
||||
return Error{Code: InvalidClient, Description: "client has no redirect URIs"}
|
||||
}
|
||||
|
||||
if redirectURI == nil {
|
||||
if len(client.RedirectUris) != 1 {
|
||||
return Error{Code: InvalidRequest, Description: "client has multiple redirect URIs and none were provided"}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
if !slices.Contains(client.RedirectUris, *redirectURI) {
|
||||
return Error{Code: InvalidGrant, Description: "client redirect URI does not match registered redirect URIs"}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue