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 servicePrincipal methods AddTokenSigningCertificate and SetPref… #151

Closed
wants to merge 1 commit into from

Conversation

dhohengassner
Copy link
Contributor

✨ add servicePrincipal methods AddTokenSigningCertificate and SetPreferredTokenSigningKeyThumbprint

This commit adds support to create the certificiate for Azure AD signed certs and set
the preferred token thumbprint on the service principal.

This will allow to follow the steps described in
https://docs.microsoft.com/en-us/graph/application-saml-sso-configure-api#create-a-signing-certificate
using hamilton SDK.

Currently Microsoft does not support a method to remove the created certificate key from the service principal.
https://docs.microsoft.com/en-us/graph/api/serviceprincipal-addtokensigningcertificate

Also manual removal via removePassword and removekey API calls are not supported and fail with an internal server error.

This SDK extension is the base to extend the terraform-provider-azuread.

Issue: hashicorp/terraform-provider-azuread#732

@dhohengassner
Copy link
Contributor Author

@manicminer This should be the base for the terraform provider extension. Please review

Tested this in my developer account and can see the thumbprint set on the service principal.
Thanks

@dhohengassner
Copy link
Contributor Author

dhohengassner commented Feb 16, 2022

@manicminer I tried to figure out why the tests are failing but I think this is not related to my changes.

It seems all unit tests are failing with the same protocol failure. Locally they seem to work for me.

I see the same error in other PRs as well. Is this already known? Any idea is much appreciated.

Thanks!

@manicminer
Copy link
Owner

Hi @dhohengassner, it looks like PRs from forks are not able to use OIDC auth. GitHub doesn't have any security model in place for allowing this either, a detail I seem to have skipped over when switching the tests to use this auth method.

Until recently we used a private self hosted runner to run the test workflows, alas this is offline for the moment so we'll have to resort to running them manually. You are welcome to post a screenshot of local test results. I will also happily run them when reviewing.

@dhohengassner dhohengassner force-pushed the token-signing-cert branch 2 times, most recently from 041a362 to 8395e58 Compare February 17, 2022 14:37
…erredTokenSigningKeyThumbprint

This commit adds support to create the certificiate for Azure AD signed certs and set
the preferred token thumbprint on the service principal.

This will allow to follow the steps described in
https://docs.microsoft.com/en-us/graph/application-saml-sso-configure-api#create-a-signing-certificate
using hamilton SDK.

Currently Microsoft does not support a method to remove the created certificate key from the service principal.
https://docs.microsoft.com/en-us/graph/api/serviceprincipal-addtokensigningcertificate

Also manual removal via `removePassword` and `removekey` API calls are not supported and fail with an internal server error.

This SDK extension is the base to extend the `terraform-provider-azuread`.

Issue: hashicorp/terraform-provider-azuread#732
@dhohengassner
Copy link
Contributor Author

@manicminer think this PR is ready for review

Looking forward to your review.

Thanks

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.

Hi @dhohengassner, thanks again for this contribution and your patience. I've been away for a week so apologies for the delay in reviewing.

Overall this looks great, I just wonder if the ServicePrincipalsClient.SetPreferredTokenSigningKeyThumbprint is needed? Open to your discretion if you think it's important to implement.

Also, if you merge/rebase from main, the tests should now be fixed as the self-hosted runner is back online.

}

// SetPreferredTokenSigningKeyThumbprint sets the field preferredTokenSigningKeyThumbprint for a Service Principal.
func (c *ServicePrincipalsClient) SetPreferredTokenSigningKeyThumbprint(ctx context.Context, servicePrincipalId string, thumbprint string) (int, error) {
Copy link
Owner

Choose a reason for hiding this comment

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

Whilst I can see the utility here, would you say this method is necessary if this can be done with ServicePrincipalsClient.Update?

@manicminer
Copy link
Owner

@dhohengassner I had to make a small change to fix the test but was unfortunately unable to push to your fork. I've opened #158 to replace this PR, preserving your original commit. Many thanks again for your work on this!

@manicminer manicminer closed this Apr 14, 2022
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