[oauth2] add Azure AD B2C endpoints

72 views
Skip to first unread message

Gerrit Bot (Gerrit)

unread,
Feb 22, 2022, 4:30:08 PM2/22/22
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Gerrit Bot has uploaded this change for review.

View Change

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.

Gerrit-Project: oauth2
Gerrit-Branch: master
Gerrit-Change-Id: Iaa15d2bd70e9f87761e1f47a0f5cc0c819c65cdd
Gerrit-Change-Number: 387454
Gerrit-PatchSet: 1
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
Gerrit-MessageType: newchange

Gopher Robot (Gerrit)

unread,
Feb 22, 2022, 4:30:43 PM2/22/22
to Gerrit Bot, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

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.

View Change

    To view, visit change 387454. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: oauth2
    Gerrit-Branch: master
    Gerrit-Change-Id: Iaa15d2bd70e9f87761e1f47a0f5cc0c819c65cdd
    Gerrit-Change-Number: 387454
    Gerrit-PatchSet: 1
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-Comment-Date: Tue, 22 Feb 2022 21:30:40 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: No
    Gerrit-MessageType: comment

    Sean Liao (Gerrit)

    unread,
    Apr 16, 2025, 3:22:16 PMApr 16
    to Gerrit Bot, goph...@pubsubhelper.golang.org, Brad Fitzpatrick, Chris Broadfoot, Shin Fan, Cody Oss, Jaana Dogan, Gopher Robot, golang-co...@googlegroups.com

    Sean Liao abandoned this change

    Related details

    Attention set is empty
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: abandon
    Gerrit-Project: oauth2
    Gerrit-Branch: master
    Gerrit-Change-Id: Iaa15d2bd70e9f87761e1f47a0f5cc0c819c65cdd
    Gerrit-Change-Number: 387454
    Gerrit-PatchSet: 1
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-Reviewer: Brad Fitzpatrick <brad...@golang.org>
    Gerrit-CC: Chris Broadfoot <cb...@golang.org>
    Gerrit-CC: Cody Oss <cod...@google.com>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-CC: Jaana Dogan <j...@google.com>
    Gerrit-CC: Shin Fan <shi...@google.com>
    unsatisfied_requirement
    satisfied_requirement
    open
    diffy
    Reply all
    Reply to author
    Forward
    0 new messages