git.iko.soy/typeable/oauth2-proxy
on master help sign in
feature: switch Azure AD graph API to Microsoft Graph API (#440)

* feature: switch Azure AD graph API to Microsoft Graph API * Update CHANGELOG * Expand Breaking Changes notice * Update CHANGELOG.md Co-Authored-By: Joel Speed <Joel.speed@hotmail.co.uk> * fix: use constant http method Co-authored-by: Joel Speed <Joel.speed@hotmail.co.uk>

commit7f72a222277a3b6c2c13a18c17321a6709591e40 authorMitsuo Heijo <mitsuo.heijo@gmail.com> dateSun 12 Apr 2020, 19:53 (7 years ago) parentb0b8756
3 files changed+16−13
CHANGELOG.md+6−1 providers/azure.go+4−5 providers/azure_test.go+6−7
CHANGELOG.md+6−1
@@ -12,8 +12,14 @@
1212 - See the changes listed below for PR [#464](https://github.com/oauth2-proxy/oauth2-proxy/pull/464) for full details
1313 - Binaries renamed from `oauth2_proxy` to `oauth2-proxy`
1414
15+- [#440](https://github.com/oauth2-proxy/oauth2-proxy/pull/440) Switch Azure AD Graph API to Microsoft Graph API (@johejo)
16+ - The Azure AD Graph API has been [deprecated](https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-graph-api) and is being replaced by the Microsoft Graph API.
17+ If your application relies on the access token being passed to it to access the Azure AD Graph API, you should migrate your application to use the Microsoft Graph API.
18+ Existing behaviour can be retained by setting `-resource=https://graph.windows.net`.
19+
1520## Changes since v5.1.0
1621
22+- [#440](https://github.com/oauth2-proxy/oauth2-proxy/pull/440) Switch Azure AD Graph API to Microsoft Graph API (@johejo)
1723- [#453](https://github.com/oauth2-proxy/oauth2-proxy/pull/453) Prevent browser caching during auth flow (@johejo)
1824- [#481](https://github.com/oauth2-proxy/oauth2-proxy/pull/481) Update Okta docs (@trevorbox)
1925- [#474](https://github.com/oauth2-proxy/oauth2-proxy/pull/474) Always log hasMember request error object (@jbielick)
@@ -61,7 +67,6 @@ N/A
6167- [#405](https://github.com/oauth2-proxy/oauth2-proxy/pull/405) The `/sign_in` page now honors the `rd` query parameter, fixing the redirect after a successful authentication (@ti-mo)
6268- [#434](https://github.com/oauth2-proxy/oauth2-proxy/pull/434) Give the option to prefer email address in the username header when using the -pass-user-headers option (@jordancrawfordnz)
6369
64−
6570# v5.0.0
6671
6772## Release Hightlights
providers/azure.go+4−5
@@ -28,16 +28,15 @@ func NewAzureProvider(p *ProviderData) *AzureProvider {
2828
2929 if p.ProfileURL == nil || p.ProfileURL.String() == "" {
3030 p.ProfileURL = &url.URL{
31− Scheme: "https",
32− Host: "graph.windows.net",
33− Path: "/me",
34− RawQuery: "api-version=1.6",
31+ Scheme: "https",
32+ Host: "graph.microsoft.com",
33+ Path: "/v1.0/me",
3534 }
3635 }
3736 if p.ProtectedResource == nil || p.ProtectedResource.String() == "" {
3837 p.ProtectedResource = &url.URL{
3938 Scheme: "https",
40− Host: "graph.windows.net",
39+ Host: "graph.microsoft.com",
4140 }
4241 }
4342 if p.Scope == "" {
providers/azure_test.go+6−7
@@ -41,9 +41,9 @@ func TestAzureProviderDefaults(t *testing.T) {
4141 p.Data().LoginURL.String())
4242 assert.Equal(t, "https://login.microsoftonline.com/common/oauth2/token",
4343 p.Data().RedeemURL.String())
44− assert.Equal(t, "https://graph.windows.net/me?api-version=1.6",
44+ assert.Equal(t, "https://graph.microsoft.com/v1.0/me",
4545 p.Data().ProfileURL.String())
46− assert.Equal(t, "https://graph.windows.net",
46+ assert.Equal(t, "https://graph.microsoft.com",
4747 p.Data().ProtectedResource.String())
4848 assert.Equal(t, "",
4949 p.Data().ValidateURL.String())
@@ -97,9 +97,9 @@ func TestAzureSetTenant(t *testing.T) {
9797 p.Data().LoginURL.String())
9898 assert.Equal(t, "https://login.microsoftonline.com/example/oauth2/token",
9999 p.Data().RedeemURL.String())
100− assert.Equal(t, "https://graph.windows.net/me?api-version=1.6",
100+ assert.Equal(t, "https://graph.microsoft.com/v1.0/me",
101101 p.Data().ProfileURL.String())
102− assert.Equal(t, "https://graph.windows.net",
102+ assert.Equal(t, "https://graph.microsoft.com",
103103 p.Data().ProtectedResource.String())
104104 assert.Equal(t, "",
105105 p.Data().ValidateURL.String())
@@ -107,12 +107,11 @@ func TestAzureSetTenant(t *testing.T) {
107107}
108108
109109func testAzureBackend(payload string) *httptest.Server {
110− path := "/me"
111− query := "api-version=1.6"
110+ path := "/v1.0/me"
112111
113112 return httptest.NewServer(http.HandlerFunc(
114113 func(w http.ResponseWriter, r *http.Request) {
115− if (r.URL.Path != path || r.URL.RawQuery != query) && r.Method != http.MethodPost {
114+ if (r.URL.Path != path) && r.Method != http.MethodPost {
116115 w.WriteHeader(404)
117116 } else if r.Method == http.MethodPost && r.Body != nil {
118117 w.WriteHeader(200)