MCPcopy Index your code
hub / github.com/coder/coder / Validate

Method Validate

codersdk/oauth2_validation.go:13–76  ·  view source on GitHub ↗

RFC 7591 validation functions for Dynamic Client Registration

()

Source from the content-addressed store, hash-verified

11// RFC 7591 validation functions for Dynamic Client Registration
12
13func (req *OAuth2ClientRegistrationRequest) Validate() error {
14 // Validate redirect URIs - required for authorization code flow
15 if len(req.RedirectURIs) == 0 {
16 return xerrors.New("redirect_uris is required for authorization code flow")
17 }
18
19 if err := validateRedirectURIs(req.RedirectURIs, req.TokenEndpointAuthMethod); err != nil {
20 return xerrors.Errorf("invalid redirect_uris: %w", err)
21 }
22
23 // Validate grant types if specified
24 if len(req.GrantTypes) > 0 {
25 if err := validateGrantTypes(req.GrantTypes); err != nil {
26 return xerrors.Errorf("invalid grant_types: %w", err)
27 }
28 }
29
30 // Validate response types if specified
31 if len(req.ResponseTypes) > 0 {
32 if err := validateResponseTypes(req.ResponseTypes); err != nil {
33 return xerrors.Errorf("invalid response_types: %w", err)
34 }
35 }
36
37 // Validate token endpoint auth method if specified
38 if req.TokenEndpointAuthMethod != "" {
39 if err := validateTokenEndpointAuthMethod(req.TokenEndpointAuthMethod); err != nil {
40 return xerrors.Errorf("invalid token_endpoint_auth_method: %w", err)
41 }
42 }
43
44 // Validate URI fields
45 if req.ClientURI != "" {
46 if err := validateURIField(req.ClientURI, "client_uri"); err != nil {
47 return err
48 }
49 }
50
51 if req.LogoURI != "" {
52 if err := validateURIField(req.LogoURI, "logo_uri"); err != nil {
53 return err
54 }
55 }
56
57 if req.TOSURI != "" {
58 if err := validateURIField(req.TOSURI, "tos_uri"); err != nil {
59 return err
60 }
61 }
62
63 if req.PolicyURI != "" {
64 if err := validateURIField(req.PolicyURI, "policy_uri"); err != nil {
65 return err
66 }
67 }
68
69 if req.JWKSURI != "" {
70 if err := validateURIField(req.JWKSURI, "jwks_uri"); err != nil {

Callers 2

Calls 7

validateRedirectURIsFunction · 0.85
validateGrantTypesFunction · 0.85
validateResponseTypesFunction · 0.85
validateURIFieldFunction · 0.85
NewMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected