Gerrit Bot has uploaded this change for review.
add Azure AD B2C endpoints
It is very common to mix up Azure AD and Azure B2C. Since endpoints are not the same, I implemented a function to get Azure AD B2C endpoints according to the documentation below.
https://docs.microsoft.com/en-us/azure/active-directory-b2c/tokens-overview#endpoints
Change-Id: Iaa15d2bd70e9f87761e1f47a0f5cc0c819c65cdd
GitHub-Last-Rev: e3b881498fa86dacc762865ee07313be6dda6473
GitHub-Pull-Request: golang/oauth2#547
---
M endpoints/endpoints.go
M microsoft/microsoft.go
2 files changed, 40 insertions(+), 0 deletions(-)
diff --git a/endpoints/endpoints.go b/endpoints/endpoints.go
index cd3e167..02d7dca 100644
--- a/endpoints/endpoints.go
+++ b/endpoints/endpoints.go
@@ -230,6 +230,18 @@
}
}
+// AzureADB2CEndpoint returns a new oauth2.Endpoint for the given tenant and policy at Azure Active Directory B2C.
+// policy is the Azure B2C User flow name Example: `B2C_1_SignUpSignIn`.
+// For more information see:
+// https://docs.microsoft.com/en-us/azure/active-directory-b2c/tokens-overview#endpoints
+
+func AzureADB2CEndpoint(tenant string, policy string) oauth2.Endpoint {
+ return oauth2.Endpoint{
+ AuthURL: "https://" + tenant + ".b2clogin.com/" + tenant + ".onmicrosoft.com/" + policy + "/oauth2/v2.0/authorize",
+ TokenURL: "https://" + tenant + ".b2clogin.com/" + tenant + ".onmicrosoft.com/" + policy + "/oauth2/v2.0/token",
+ }
+}
+
// HipChatServer returns a new oauth2.Endpoint for a HipChat Server instance
// running on the given domain or host.
func HipChatServer(host string) oauth2.Endpoint {
diff --git a/microsoft/microsoft.go b/microsoft/microsoft.go
index 3ffbc57..e39386e 100644
--- a/microsoft/microsoft.go
+++ b/microsoft/microsoft.go
@@ -29,3 +29,16 @@
TokenURL: "https://login.microsoftonline.com/" + tenant + "/oauth2/v2.0/token",
}
}
+
+// AzureADB2CEndpoint returns a new oauth2.Endpoint for the given tenant and policy at Azure Active Directory B2C.
+// policy is the Azure B2C User flow name Example: `B2C_1_SignUpSignIn`.
+// For more information see:
+// https://docs.microsoft.com/en-us/azure/active-directory-b2c/tokens-overview#endpoints
+
+func AzureADB2CEndpoint(tenant string, policy string) oauth2.Endpoint {
+ return oauth2.Endpoint{
+ AuthURL: "https://" + tenant + ".b2clogin.com/" + tenant + ".onmicrosoft.com/" + policy + "/oauth2/v2.0/authorize",
+ TokenURL: "https://" + tenant + ".b2clogin.com/" + tenant + ".onmicrosoft.com/" + policy + "/oauth2/v2.0/token",
+ }
+}
+
To view, visit change 387454. To unsubscribe, or for help writing mail filters, visit settings.
Congratulations on opening your first change. Thank you for your contribution!
Next steps:
A maintainer will review your change and provide feedback. See
https://go.dev/doc/contribute#review for more info and tips to get your
patch through code review.
Most changes in the Go project go through a few rounds of revision. This can be
surprising to people new to the project. The careful, iterative review process
is our way of helping mentor contributors and ensuring that their contributions
have a lasting impact.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |