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 Domain Hint #363

Merged
merged 3 commits into from
Dec 15, 2022
Merged

Add Domain Hint #363

merged 3 commits into from
Dec 15, 2022

Conversation

eopeter
Copy link
Contributor

@eopeter eopeter commented Dec 2, 2022

This PR Seeks to enable adding Domain Hint option to be used to accelerate the user to their federated IdP sign-in page. Or they can be used by a multi-tenant application to accelerate the user straight to the branded Azure AD sign-in page for their tenant.

@eopeter eopeter marked this pull request as ready for review December 2, 2022 09:22
@rayluo rayluo requested a review from chlowell December 2, 2022 17:54
Copy link
Contributor

@rayluo rayluo left a comment

Choose a reason for hiding this comment

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

apps/confidential/confidential.go Outdated Show resolved Hide resolved
@@ -531,6 +532,33 @@ func WithLoginHint(username string) interface {
}
}

// WithDomainHint pre-populates the login prompt with the IdP domain.
func WithDomainHint(domain string) interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Is it possible to refactor our code base so that we wouldn't need to duplicate this code snippet twice?

CC: @chlowell

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I refactored to avoid the code duplication

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, thanks for consolidating the new WithDomainHint() and existing WithLoginHint() with a common underlying helper. My original comment was about the WET between confidential client and public client, though. All the implementation and their corresponding test case are currently duplicated in the two clients, while the behavior could ideally be shared among a common base of both confidential client and public client.

Not sure how much refactoring would be needed. I'll defer this topic to @chlowell .

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think withHint() and its supporting type make the code more complex for no benefit--this approach doesn't lower the maintenance burden. It's better for WithLoginHint() and WithDomainHint() to simply set their respective fields directly.

Sharing one implementation of WithDomainHint() between confidential and public clients might be possible, but the constraints imposed by Go and the current implementation make it difficult and much more complex than parallel options in each package. I don't think it's worth pursuing.

Regarding a shared base for both client types, we do have one, but testing it isn't a substitute for testing the public API.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I reverted the WithHint() code and now have separate WithLoginHint() and WithDomainHint()

@eopeter eopeter requested review from rayluo and removed request for chlowell December 2, 2022 19:08
@eopeter eopeter requested review from chlowell and removed request for rayluo December 7, 2022 19:41
Copy link
Collaborator

@chlowell chlowell left a comment

Choose a reason for hiding this comment

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

Looks good to me as Go. I'm not familiar with the AAD feature, so defer to @rayluo for MSAL perspective.

apps/confidential/confidential.go Outdated Show resolved Hide resolved
apps/public/public.go Outdated Show resolved Hide resolved
apps/public/public.go Outdated Show resolved Hide resolved
Co-authored-by: Charles Lowell <10964656+chlowell@users.noreply.github.com>
@sonarcloud
Copy link

sonarcloud bot commented Dec 8, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@rayluo rayluo merged commit 16c062c into AzureAD:dev Dec 15, 2022
@rayluo rayluo mentioned this pull request Jan 23, 2023
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