Skip to content

Commit

Permalink
* added configuration for application.provided_scope_policy (#278)
Browse files Browse the repository at this point in the history
Fixes #277

* * added configuration for `application.provided_scope_policy`

* Update resource_fusionauth_application.go

changed OAuth configuration scope policy to enabled by default

* Update application.md

Updated description

---------

Co-authored-by: Mark Manes <[email protected]>
  • Loading branch information
zaalbarxx and mmanes authored Jun 14, 2024
1 parent bd40ab5 commit 5f6366c
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 0 deletions.
31 changes: 31 additions & 0 deletions docs/resources/application.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,24 @@ resource "fusionauth_application" "Forum" {
logout_behavior = "AllApplications"
logout_url = "http://www.example.com/logout"
require_client_authentication = false
provided_scope_policy {
address {
enabled = false
required = false
}
email {
enabled = false
required = false
}
phone {
enabled = false
required = false
}
profile {
enabled = false
required = false
}
}
}
registration_configuration {
birth_date {
Expand Down Expand Up @@ -147,6 +165,19 @@ resource "fusionauth_application" "Forum" {
- `proof_key_for_code_exchange_policy` - (Optional) Determines the PKCE requirements when using the authorization code grant.
- `require_client_authentication` - (Optional) Determines if the OAuth 2.0 Token endpoint requires client authentication. If this is enabled, the client must provide client credentials when using the Token endpoint. The client_id and client_secret may be provided using a Basic Authorization HTTP header, or by sending these parameters in the request body using POST data.
- `require_registration` - (Optional) When enabled the user will be required to be registered, or complete registration before redirecting to the configured callback in the authorization code grant or the implicit grant. This configuration does not currently apply to any other grant.
- `provided_scope_policy` - (Optional) Configures which of the default scopes are enabled and required.
* `address`
* `enabled` - (Optional)
* `required` - (Optional)
* `email`
* `enabled` - (Optional)
* `required` - (Optional)
* `phone`
* `enabled` - (Optional)
* `required` - (Optional)
* `profile`
* `enabled` - (Optional)
* `required` - (Optional)
* `registration_configuration` - (Optional)
- `birth_date` - (Optional)
* `enabled` - (Optional)
Expand Down
53 changes: 53 additions & 0 deletions fusionauth/resource_fusionauth_application.go
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,11 @@ func newOAuthConfiguration() *schema.Resource {
Default: false,
Description: "When enabled the user will be required to be registered, or complete registration before redirecting to the configured callback in the authorization code grant or the implicit grant. This configuration does not currently apply to any other grant.",
},
"provided_scope_policy": {
Type: schema.TypeList,
Optional: true,
Elem: newOAuthConfigurationScopePolicy(),
},
},
}
}
Expand Down Expand Up @@ -854,3 +859,51 @@ func newRegistrationConfiguration() *schema.Resource {
},
}
}

func newOAuthConfigurationScopePolicy() *schema.Resource {
requireable := func() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
"enabled": {
Type: schema.TypeBool,
Optional: true,
Default: true,
},
"required": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},
},
}
}

return &schema.Resource{
Schema: map[string]*schema.Schema{
"address": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Elem: requireable(),
},
"email": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Elem: requireable(),
},
"phone": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Elem: requireable(),
},
"profile": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Elem: requireable(),
},
},
}
}
6 changes: 6 additions & 0 deletions fusionauth/resource_fusionauth_application_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ func buildApplication(data *schema.ResourceData) fusionauth.Application {
LogoutBehavior: fusionauth.LogoutBehavior(data.Get("oauth_configuration.0.logout_behavior").(string)),
EnabledGrants: buildGrants("oauth_configuration.0.enabled_grants", data),
RequireRegistration: data.Get("oauth_configuration.0.require_registration").(bool),
ProvidedScopePolicy: fusionauth.ProvidedScopePolicy{
Address: buildRequireable("oauth_configuration.0.provided_scope_policy.0.address", data),
Email: buildRequireable("oauth_configuration.0.provided_scope_policy.0.email", data),
Phone: buildRequireable("oauth_configuration.0.provided_scope_policy.0.phone", data),
Profile: buildRequireable("oauth_configuration.0.provided_scope_policy.0.profile", data),
},
},
PasswordlessConfiguration: fusionauth.PasswordlessConfiguration{
Enableable: buildEnableable("passwordless_configuration_enabled", data),
Expand Down

0 comments on commit 5f6366c

Please sign in to comment.