Skip to content

Individual SAMLv2 application_configuration resource#350

Open
geekofalltrades wants to merge 16 commits intoFusionAuth:mainfrom
geekofalltrades:individual-association-resource
Open

Individual SAMLv2 application_configuration resource#350
geekofalltrades wants to merge 16 commits intoFusionAuth:mainfrom
geekofalltrades:individual-association-resource

Conversation

@geekofalltrades
Copy link

This pull request starts from AI-generated code and revises it and adds tests. Adds a fusionauth_idp_saml_v2_application_configuration resource that uses the identity-provider PATCH endpoint to declaratively manage a single applicationConfiguration on a SAMLv2 IdP. This resource is more suitable for decentralized management where there are Terraform root modules for each FusionAuth application being managed, and the applications all need to be configured on a central IdP.

If this approach is approved, we additionally plan to add standalone applicationConfiguration resources for the Google and Entra IdPs.

Known shortcomings:

  • There is a race condition in the PATCH method. Until it's resolved, it is unsafe to run this resource in parallel (multiple declarations in the same Terraform module without explicit dependency ordering, or running multiple Terraform modules using this resource against the same IdP at the same time).
  • The fusionauth_idp_saml_v2 resource has been updated to not manage applicationConfiguration if its application_configuration config is null. However, the legacy terraform-plugin-sdk this provider is written with can't distinguish between null and explicitly empty. So it is not possible to have a fusionauth_idp_saml_v2 with an explicitly empty application_configuration.
  • The new acceptance tests I've written for this resource are passing, but I can't get the entire suite to run against my test FusionAuth instance.

We may still make some changes subject to internal review.

This is the fusionauth API name for this field.
The claude-generated code included helpers for both JSON patch and the
legacy non-specific patch. According to fusionauth docs the latter is on
the deprecation path and is not as specific or powerful as the newer
JSON patch and JSON Merge patch options.

https://fusionauth.io/docs/apis/#the-patch-http-method
Without this check, Terraform would automatically adopt an existing
configuration into its state on initial creation, which is a Terraform
antipattern.
This locking was added before we knew the IDP API supported PATCH
semantics. It would never have protected the IDP against multiple
Terraform runs, where each run would have started its own provider
server and they would not have shared this mutex.
The documentation reuses verbiage from the AWS provider's security group
vs. its security group rule resources to warn against managing
application configurations with both resources.

*
https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group
*
https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc_security_group_ingress_rule
The native ignore_changes lifecycle option can be used to migrate from
the inline application_configuration to the standalone resource.

Ticket: EZ-7330
The tests do not consistently pass due to raciness on the PATCH method
for identity-provider. This needs to be fixed by FusionAuth.

Ticket: EZ-7330
@geekofalltrades geekofalltrades changed the title Individual association resource Individual SAMLv2 application_configuration resource Feb 18, 2026
We should be able to use this to make fusionauth_idp_saml_v2 not
conflict with fusionauth_idp_saml_v2_application_configuration when its
application_configurations is null.
* If no application_configuration is configured, ensure that an empty
  object is stored back to the state, regardless of what's in
  FusionAuth. This suppresses diffs on idp_saml_v2 when its
  applicationConfiguration in FusionAuth is managed by
  idp_saml_v2_application_configuration in Terraform.
* Perform updates with PATCH + JSON merge patch instead of PUT. If no
  application_configuration is configured, the JSON body contains an
  empty object, resulting in no changes in applicationConfiguration
  in FusionAuth that might be managed by separate
  ipd_saml_v2_application_configuration in Terraform.
There is a race condition in the FusionAuth PATCH endpoint for IdPs
where patches received at the same time may not all be applied. This
causes these tests to fail nondeterministically. This is a bug in the
FusionAuth API that needs to be fixed upstream.

Ticket: EZ-7330
Providers written in terraform-plugin-sdk can't actually support
explicitly empty collections vs. null configuration, but this is ideally
a case that should be supported and tested for. The provider will have
to be ported to the newer terraform-plugin-framework before this is
possible.

Ticket: EZ-7330
If the application_configuration resource already exists and is being
updated, that means it is being managed by Terraform (was previously
created or has been imported). If the configuration goes missing from
FusionAuth, the correct thing for Terraform to do is recreate it, not
fail because it has gone missing.

Ticket: EZ-7330
It is idempotent to apply a JSON patch removing a field that already
doesn't exist.

Ticket: EZ-7330
This type contains the information we care about in native Go types
without requiring further decoding like the SAMLIdentityProviderBody
type.

Ticket: EZ-7330
@geekofalltrades geekofalltrades force-pushed the individual-association-resource branch from 2ce294b to 4eccae8 Compare February 19, 2026 00:36
@daethnir
Copy link

Correction: there isn't an entra IDP type in fusionauth; rather we'd update the generic OpenID Connect one (which is how we support Entra today.

@TomKimber
Copy link
Collaborator

@geekofalltrades @daethnir As discussed directly this PR is still under-review. I've tested and validated the noted short-comings. FusionAuth will assess whether these are acceptable in the mainline provider or whether they will implement API changes to remove/mitigate these limitations. I will update you both directly once that has been decided. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants