Skip to content

Commit

Permalink
feat: add AllowedCorsOrigins (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
greenboxal authored Jun 29, 2020
1 parent e626afc commit 53aea68
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions api/v1alpha1/oauth2client_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ type OAuth2ClientSpec struct {
// PostLogoutRedirectURIs is an array of the post logout redirect URIs allowed for the application
PostLogoutRedirectURIs []RedirectURI `json:"postLogoutRedirectUris,omitempty"`

// AllowedCorsOrigins is an array of allowed CORS origins
AllowedCorsOrigins []RedirectURI `json:"allowedCorsOrigins,omitempty"`

// Audience is a whitelist defining the audiences this client is allowed to request tokens for
Audience []string `json:"audience,omitempty"`

Expand Down Expand Up @@ -185,6 +188,7 @@ func (c *OAuth2Client) ToOAuth2ClientJSON() *hydra.OAuth2ClientJSON {
ResponseTypes: responseToStringSlice(c.Spec.ResponseTypes),
RedirectURIs: redirectToStringSlice(c.Spec.RedirectURIs),
PostLogoutRedirectURIs: redirectToStringSlice(c.Spec.PostLogoutRedirectURIs),
AllowedCorsOrigins: redirectToStringSlice(c.Spec.AllowedCorsOrigins),
Audience: c.Spec.Audience,
Scope: c.Spec.Scope,
Owner: fmt.Sprintf("%s/%s", c.Name, c.Namespace),
Expand Down
5 changes: 5 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ func (in *OAuth2ClientSpec) DeepCopyInto(out *OAuth2ClientSpec) {
*out = make([]RedirectURI, len(*in))
copy(*out, *in)
}
if in.AllowedCorsOrigins != nil {
in, out := &in.AllowedCorsOrigins, &out.AllowedCorsOrigins
*out = make([]RedirectURI, len(*in))
copy(*out, *in)
}
if in.Audience != nil {
in, out := &in.Audience, &out.Audience
*out = make([]string, len(*in))
Expand Down
6 changes: 6 additions & 0 deletions config/crd/bases/hydra.ory.sh_oauth2clients.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,12 @@ spec:
type: object
spec:
properties:
allowedCorsOrigins:
description: AllowedCorsOrigins is an array of allowed CORS origins
items:
pattern: \w+:/?/?[^\s]+
type: string
type: array
audience:
description: Audience is a whitelist defining the audiences this client
is allowed to request tokens for
Expand Down
1 change: 1 addition & 0 deletions hydra/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type OAuth2ClientJSON struct {
GrantTypes []string `json:"grant_types"`
RedirectURIs []string `json:"redirect_uris,omitempty"`
PostLogoutRedirectURIs []string `json:"post_logout_redirect_uris,omitempty"`
AllowedCorsOrigins []string `json:"allowed_cors_origins,omitempty"`
ResponseTypes []string `json:"response_types,omitempty"`
Audience []string `json:"audience,omitempty"`
Scope string `json:"scope"`
Expand Down

0 comments on commit 53aea68

Please sign in to comment.