Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azuread_group_role_management_policy does not work and result in Invalid policy when authentication context is setup #1605

Open
SuryenduB opened this issue Dec 26, 2024 · 1 comment

Comments

@SuryenduB
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritise this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritise the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform (and AzureAD Provider) Version

Terraform v1.9.3
on windows_amd64

  • provider registry.terraform.io/hashicorp/azuread v3.0.2
  • provider registry.terraform.io/hashicorp/time v0.12.1

Affected Resource(s)

  • azuread_group_role_management_policy

Terraform Configuration Files

resource "azuread_group" "pimgroup1" {
  display_name            = "glob_gsec_pim_admins_roles_workplace"
  security_enabled        = true
  assignable_to_role      = true
  prevent_duplicate_names = true

}

resource "azuread_group" "pimapprover" {
  display_name            = "glob_gsec_pimapprovers"
  security_enabled        = true
  prevent_duplicate_names = true
}


resource "azuread_group_role_management_policy" "pimpolicy1" {
  group_id = split("/", azuread_group.pimgroup1.id)[2]
  role_id  = "member"

  activation_rules {
    maximum_duration                                   = "PT16H"
    require_justification                              = true
    require_ticket_info                                = true
    required_conditional_access_authentication_context = "c2"

  }


}


resource "azuread_privileged_access_group_eligibility_schedule" "example" {
  for_each        = toset(local.user_ids)
  group_id        = split("/", azuread_group.pimgroup1.id)[2]
  principal_id    = split("/", each.value)[2]
  assignment_type = "member"
  duration        = "P30D"
  justification   = "as requested"
}




Debug Output

https://gist.github.com/SuryenduB/0a81d846643fc653d1b8e9a773e69907

Panic Output

Expected Behavior

image Expected behaviour authentication to be set.

Actual Behavior

Authentication Context is not set.
image

Steps to Reproduce

  1. terraform apply

Important Factoids

References

  • #0000
@jamesw4
Copy link

jamesw4 commented Jan 17, 2025

Seeing same issue with TF 1.10.4 and AzureAD 3.1.0. The original debug log on this ticket caught me out as was comparing with my issue, but the debug log appears to be for a successful run. My debug log can be found here - https://gist.github.com/jamesw4/2ec23beeead41af5ff2e481d890a0ef6

It seems that claimValue for the auth context is being set to null. I had a quick look at the code but by no means an expert, but wondering if it seeing there is already a value (there is, its null) and its setting that rather than taking the provided value?

Before the apply the rule looks like this:

{
  "@odata.type": "#microsoft.graph.unifiedRoleManagementPolicyAuthenticationContextRule",
  "id": "AuthenticationContext_EndUser_Assignment",
  "isEnabled": false,
  "claimValue": null,
  "target": {
    "caller": "EndUser",
    "operations": [
      "all"
    ],
    "level": "Assignment",
    "inheritableSettings": [],
    "enforcedSettings": []
  }
}

Then the patch from terraform looks like this, i.e. its switched to enabled, but claimValue is still null, some of the nesting also looks off?:

{
  "@odata.type": "#microsoft.graph.unifiedRoleManagementPolicyAuthenticationContextRule",
  "claimValue": null,
  "id": "AuthenticationContext_EndUser_Assignment",
  "isEnabled": true,
  "target": {
    "caller": "EndUser",
    "enforcedSettings": [],
    "inheritableSettings": [],
    "level": "Assignment",
    "operations": [
      "all"
    ]
  }
}

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

No branches or pull requests

2 participants