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

Add support for AuthenticationStrengthPolicies #249

Merged
merged 22 commits into from
Jul 24, 2023

Conversation

bubbletroubles
Copy link
Contributor

@bubbletroubles bubbletroubles commented Jul 20, 2023

Adding support for AuthenticationStrengthPolicies.

Microsoft GraphAPI doco - https://learn.microsoft.com/en-us/graph/api/resources/authenticationstrengthpolicy?view=graph-rest-1.0

@bubbletroubles bubbletroubles changed the title Adding support for AuthenticationStrengthPolicies Add support for AuthenticationStrengthPolicies Jul 20, 2023
@bubbletroubles bubbletroubles marked this pull request as ready for review July 22, 2023 00:40
Copy link
Owner

@manicminer manicminer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks for this @bubbletroubles, this is mostly looking good. I noted one correction below, and also thought that we should make sure to test this in the ConditionalAccessPolicyClient tests. For example:

	authStrengthPolicy := testAuthenticationStrengthPoliciesClient_Create(t, c, msgraph.AuthenticationStrengthPolicy{
		DisplayName:         utils.StringPtr(fmt.Sprintf("test-policy-%s", c.RandomString)),
		Description:         utils.StringPtr("Password and Hardware OATH"),
		AllowedCombinations: &[]string{"password, hardwareOath"},
	},
	)

	policy := testConditionalAccessPolicysClient_Create(t, c, msgraph.ConditionalAccessPolicy{
		DisplayName: utils.StringPtr(fmt.Sprintf("test-policy-%s", c.RandomString)),
		State:       utils.StringPtr("enabled"),
		Conditions: &msgraph.ConditionalAccessConditionSet{
			ClientAppTypes: &[]string{"mobileAppsAndDesktopClients", "browser"},
			Applications: &msgraph.ConditionalAccessApplications{
				IncludeApplications: &[]string{testAppId},
			},
			Users: &msgraph.ConditionalAccessUsers{
				IncludeUsers:  &[]string{"All"},
				ExcludeUsers:  &[]string{*testUser.ID(), "GuestsOrExternalUsers"},
				IncludeGroups: &[]string{*testIncGroup.ID()},
				ExcludeGroups: &[]string{*testExcGroup.ID()},
			},
			Locations: &msgraph.ConditionalAccessLocations{
				IncludeLocations: &[]string{"All"},
				ExcludeLocations: &[]string{"AllTrusted"},
			},
		},
		GrantControls: &msgraph.ConditionalAccessGrantControls{
			Operator:        utils.StringPtr("OR"),
			BuiltInControls: &[]string{"block"},
			AuthenticationStrength: &msgraph.AuthenticationStrengthPolicy{
				ID: authStrengthPolicy.ID,
			},
		},
	})

If you can look to add this, then we should be good to merge 👍

msgraph/models.go Outdated Show resolved Hide resolved
@manicminer manicminer added enhancement New feature or request package/msgraph labels Jul 23, 2023
@manicminer manicminer added this to the v0.63.0 milestone Jul 23, 2023
@bubbletroubles
Copy link
Contributor Author

Thanks @manicminer - All suggested changes have been made and Conditional Access tests updated (and passing).

I had to re-trigger the tests a couple of times as other resources APIs were giving errors. I believe this was a transient problem.

@manicminer
Copy link
Owner

It looks like MS Graph may be having some service issues at the moment

@bubbletroubles
Copy link
Contributor Author

Hi @manicminer It's now saying the limit of authentication strenth policies is reached. This is most likely because I don't have a delete action in the custom authentication strengths test, so each test is creating a policy but not deleting it when finished.

I'll add a delete action to the test and also add a cleanup file in the test_cleanup folder.

Are you able to manually remove a couple of policies so the tests for this PR can run successfully?

@manicminer
Copy link
Owner

@bubbletroubles No problem, done. I've added Authentication Strength Policies to the cleanup tool (which runs nightly) which should help with cleanup of failed tests. The limit for this particular object seems to be 18 fwiw.

@bubbletroubles
Copy link
Contributor Author

bubbletroubles commented Jul 24, 2023

thanks @manicminer . I've just checked and there is already a delete in the authentication_strength_policy_test.go file. I originally didn't have one in the Conditional Access tests, but it's there as of a few commits ago. Hopefully its now good to merge.

Copy link
Owner

@manicminer manicminer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @bubbletroubles, this LGTM 🚀

@manicminer manicminer merged commit 2d9ae82 into manicminer:main Jul 24, 2023
manicminer added a commit that referenced this pull request Jul 24, 2023
@bubbletroubles bubbletroubles deleted the auth_strength branch July 24, 2023 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request package/msgraph
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants