-
Notifications
You must be signed in to change notification settings - Fork 301
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
Issue 985 - Add support for clientApplications in conditional access policies #1047
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for opening this PR @benoit74. The acceptance tests are configured by environment variables and generally require/expect that ARM_CLIENT_ID
and ARM_CLIENT_SECRET
are set, although you can currently run the tests using client certificate authentication.
If you need additional resources, for example some service principals, to test this addition, you would need to include these in your test configuration - e.g. in this test for the group_member resource.
I've added some comments below, if you can take a look at these and have a go at adding the tests, then I'll be happy to re-review and we can look to get this merged.
If you need any further help, don't hesitate to ask and myself or another maintainer or community member will be happy to assist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@manicminer oups, I did not even realized I was modifying a vendored file ... sorry, I was probably too tired.
Could you please have a look / release manicminer/hamilton#235?
I will have a look into tests later this week. |
The acceptance tests have uncovered issues and I definitely need help. Issue 1When the acc test tries to create an app registration and a service principal to use them in the included / excluded service principal of a conditional access policy (see Issue 2When moving from a conditional access policy based on Issue 3When
I assumed that I should use the |
Hi @benoit74, unfortunately Azure AD and MS Graph is littered with these sorts of eventual consistency gotchas. In the first instance we will try to work around this in the provider in any way we can so as not to surface this problem to the practitioner. However in this scenario I think we have already exhausted our available workarounds since the In this case, in order to get the tests passing, I would suggest we reference the authenticated service principal rather than creating a new one (via an For the second problem, can you not add a Unfortunately, due to a licensing issue that I seem to be having with our testing tenant, which I think is an Azure problem brought about by the introduction of new Entra licenses, I am unable to test this right now and so we'll have to bump this to next week whilst we continue to iron out these kinks :) |
Hi @manicminer, Very good idea to use the service principal currently authenticated! For the second problem, yes I can add such a block and the test would be ok. My point is more about whether we should hide this complexity from the user of the provider or not. But you are right, it is probably simpler to make the And yes, you need to activate Microsoft Entra Workload Identities on your tenant. It is quite "easy", a person with sufficient permission just has to navigate to https://entra.microsoft.com, open the "Workload Identities" tile on the main page, and there will be a box about activating a trial of "Workload Identities Premium" on the page. Tests are finally ok on my side. I added some extra examples, does it makes sense or is it cluttering the doc? I hope this time I fixed the doc ordering, I do not achieve to make docs-lint run on my laptop, it complains about flags missing, YAML impossible to parse, ... |
@benoit74 Wondered if you had any pending changes to push? If not then I'll rebase and check out the tests; I should be able to look at this in the next week. Thanks! |
@manicminer nope, thank you for reaching back on this. I would be glad if this could get merged soon. Do not hesitate to ask if you encounter any difficulty while testing this. |
@manicminer any news / problems on this issue ? |
Any chance we could release it this week? I get that this is complex to test since it requires specific Microsoft licences, but even with the licences you can already confirm that the changes do not break anything that is working. So at the worst, it is just not working for something which is not supported as of today. And I can tell that my tests are 100% ok on my test tenant, so chances are high that it will work. Releasing this would in addition allow us to get feedback from the community on edge cases that we will never imagine on our own. Sorry for pushing a bit hard on this, but it has already been 3 months and we are deploying more and more of these access policies and it is a pain to do by hand (we already forgot to do this once in a while). Btw, I'm surprised that no one is complaining about this feature being not yet supported. Quite an interesting insight into the security considerations of the community 🤣 |
…avoid presistent diff
* `sign_in_risk_levels` - (Optional) A list of sign-in risk levels included in the policy. Possible values are: `low`, `medium`, `high`, `hidden`, `none`, `unknownFutureValue`. | ||
* `user_risk_levels` - (Optional) A list of user risk levels included in the policy. Possible values are: `low`, `medium`, `high`, `hidden`, `none`, `unknownFutureValue`. | ||
* `users` - (Required) A `users` block as documented below, which specifies users, groups, and roles included in and excluded from the policy. | ||
* `users` - (Optional) A `users` block as documented below, which specifies users, groups, and roles included in and excluded from the policy. Either `client_applications` or `users` must be specified (and not both). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good spot on the others, I believe this one is required
* `users` - (Optional) A `users` block as documented below, which specifies users, groups, and roles included in and excluded from the policy. Either `client_applications` or `users` must be specified (and not both). | |
* `users` - (Required) A `users` block as documented below, which specifies users, groups, and roles included in and excluded from the policy. Either `client_applications` or `users` must be specified (and not both). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the reminders and your patience @benoit74 and apologies for the delay. We've resolved some licensing issues and the tests look good on our end too.
I've made some light changes which I don't believe affects functionality. Mainly that the users
condition block stays required for now - it's proving quite difficult to reliably suppress the diff that occurs from omitting it. It also took me awhile to figure out that the API refuses service principals linked to multi-tenant apps, so I've created a persistent single-tenant app and SP on our end for testing this.
After I merged in main, I managed to break GitHub so ended up rebasing and squashing your changes to a single commit, but made sure to keep your authorship for attribution.
Thanks again for working on this, and apologies again for the delay. I believe we're now all set for additional licensed features like these going forward.
Great ! I Will test it in real condition as soon this is released anyway :) |
This functionality has been released in v2.40.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
Fix #985
I do not know yet how to add tests ; in order to really test this, we need a service principal ID, and by design those IDs are specific to a given Azure Tenant.
Should I add an additional environment variables with a service principal ID to be set to run this test ? What if this is not set, it means the test suite will fail ? Could I even add two variables with two service principal IDs to check that adding multiples items is working ok ?
Thanks in advance