Skip to content
This repository was archived by the owner on Oct 10, 2025. It is now read-only.

Commit 3672af6

Browse files
authored
feat: added EntraID in favor of AzureAD and restored old behavior for AzureAD (#668)
### **PR Type** Enhancement ___ ### **Description** - Add EntraID OAuth provider as replacement for deprecated AzureAD - Deprecate AzureAD provider with warning message - Fix OAuth profile validation for empty provider user IDs - Update API types and OpenAPI specification ___ ### Diagram Walkthrough ```mermaid flowchart LR AzureAD["AzureAD Provider (deprecated)"] -- "replaced by" --> EntraID["EntraID Provider"] EntraID --> API["API Types Updated"] EntraID --> Migration["Database Migration"] EntraID --> Validation["Profile Validation"] ``` <details> <summary><h3> File Walkthrough</h3></summary> <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><details><summary>9 files</summary><table> <tr> <td><strong>server.gen.go</strong><dd><code>Update generated API server with EntraID support</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/nhost/hasura-auth/pull/668/files#diff-ebca0209f464067ebb38f8fad9dd352058e15702563f575d649434a1e7722b3d">+159/-159</a></td> </tr> <tr> <td><strong>types.gen.go</strong><dd><code>Add EntraID constants to generated types</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/nhost/hasura-auth/pull/668/files#diff-086764bd76c1416b0d0ddedcc804c3e6983907886215f9bb51162df91e823254">+4/-0</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>oauth.go</strong><dd><code>Add EntraID provider configuration and deprecation warning</code></dd></td> <td><a href="https://github.com/nhost/hasura-auth/pull/668/files#diff-82367f3f24a804b47ced852a588881c0846894bc0edf1ca3bdc6aa5aef7c37b2">+18/-0</a>&nbsp; &nbsp; </td> </tr> <tr> <td><strong>serve.go</strong><dd><code>Add EntraID CLI flags and configuration</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/nhost/hasura-auth/pull/668/files#diff-a900f3187c126bacf5c9c5b1745b5d14bc583c01ab8f1ca84ae449751c224b68">+41/-1</a>&nbsp; &nbsp; </td> </tr> <tr> <td><strong>azuread.go</strong><dd><code>Simplify AzureAD provider implementation</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/nhost/hasura-auth/pull/668/files#diff-206160b7cc0b284900057e9804c7ff57e757be1c4cb9d2b10fefbcafb4a2175f">+8/-10</a>&nbsp; &nbsp; </td> </tr> <tr> <td><strong>entraid.go</strong><dd><code>Implement new EntraID OAuth provider</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/nhost/hasura-auth/pull/668/files#diff-c0398837d3ac23ce780549e0c991cee331b013048d5b86d1c66b359f3a735e51">+70/-0</a>&nbsp; &nbsp; </td> </tr> <tr> <td><strong>scopes.go</strong><dd><code>Add default scopes for EntraID provider</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/nhost/hasura-auth/pull/668/files#diff-9007412d3f446ebcafd71f4c653bae37b99757ed41a2c08a5bacd78f2f644df2">+4/-1</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>00018_entraid-provider.down.sql</strong><dd><code>Add EntraID provider migration rollback</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/nhost/hasura-auth/pull/668/files#diff-4f4dcec8d023a9e6a961dd636b84c80b79264116e9971db83596edd40e6624a2">+4/-0</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>00018_entraid-provider.up.sql</strong><dd><code>Add EntraID provider database migration</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/nhost/hasura-auth/pull/668/files#diff-793c1d93860ab26c9c19a0f16d812753861db914456881a758907952f3db8ac1">+8/-0</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></details></td></tr><tr><td><strong>Formatting</strong></td><td><details><summary>2 files</summary><table> <tr> <td><strong>elevate_webauthn_test.go</strong><dd><code>Fix linter comment for credential ID constant</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/nhost/hasura-auth/pull/668/files#diff-47ef225c96c0aa63c67e926b18c922a14e7ccbd71145ffe646da196d3cc13880">+1/-1</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>sign_in_webauthn_test.go</strong><dd><code>Fix linter comment for credential ID constant</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/nhost/hasura-auth/pull/668/files#diff-a920a6aad3937fe5b208622b01177a4b04a182240e113b6fd1a231b12e7ed20f">+1/-1</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></details></td></tr><tr><td><strong>Bug fix</strong></td><td><details><summary>2 files</summary><table> <tr> <td><strong>sign_in_provider_callback_get.go</strong><dd><code>Add validation for empty provider user ID</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/nhost/hasura-auth/pull/668/files#diff-3ce523d5652c343d2bdb3dc0f4e3ec54888b43c7e348d4b7c59a9139c1aecefe">+5/-0</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>workflows.go</strong><dd><code>Add validation for empty provider user ID</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/nhost/hasura-auth/pull/668/files#diff-6aaacc47584f1edde5a01051611a7baffc583fc32b48df6d7fee39afa16a65cb">+5/-0</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></details></td></tr><tr><td><strong>Configuration changes</strong></td><td><details><summary>1 files</summary><table> <tr> <td><strong>.golangci.yaml</strong><dd><code>Update linter configuration for issue limits</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/nhost/hasura-auth/pull/668/files#diff-9917ddc9f1c3304218f7269265b746d997c5c0615478177b5fceecd33ef47cb5">+3/-0</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></details></td></tr><tr><td><strong>Documentation</strong></td><td><details><summary>1 files</summary><table> <tr> <td><strong>openapi.yaml</strong><dd><code>Add EntraID to OpenAPI specification</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/nhost/hasura-auth/pull/668/files#diff-6e0796423f18517e4c44819722b39c2c5ab9999f9dfb37598288ea041d1db2b0">+1/-0</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></details></td></tr></tr></tbody></table> </details> ___
1 parent 19de480 commit 3672af6

18 files changed

Lines changed: 338 additions & 179 deletions

.golangci.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
version: "2"
2+
issues:
3+
max-issues-per-linter: 0
4+
max-same-issues: 0
25
linters:
36
default: all
47
settings:

docs/openapi.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2507,6 +2507,7 @@ components:
25072507
- bitbucket
25082508
- workos
25092509
- azuread
2510+
- entraid
25102511
- strava
25112512
- facebook
25122513
- windowslive

flake.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go/api/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
package api
22

3-
const IdTokenProviderFake = IdTokenProvider("fake") //nolint:revive,stylecheck
3+
const IdTokenProviderFake = IdTokenProvider("fake") //nolint:revive

go/api/server.gen.go

Lines changed: 159 additions & 159 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go/api/types.gen.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go/cmd/oauth.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package cmd
22

33
import (
44
"fmt"
5+
"log/slog"
56

67
"github.com/nhost/hasura-auth/go/api"
78
"github.com/nhost/hasura-auth/go/providers"
@@ -33,6 +34,8 @@ func getDefaultScopes(providerName api.SignInProvider) []string {
3334
return providers.DefaultWorkOSScopes
3435
case api.SignInProviderAzuread:
3536
return providers.DefaultAzureadScopes
37+
case api.SignInProviderEntraid:
38+
return providers.DefaultEntraIDScopes
3639
case api.SignInProviderFacebook:
3740
return providers.DefaultFacebookScopes
3841
case api.SignInProviderWindowslive:
@@ -66,6 +69,7 @@ func getScopes(provider api.SignInProvider, scopes []string) []string {
6669
//nolint:funlen,cyclop
6770
func getOauth2Providers(
6871
cCtx *cli.Context,
72+
logger *slog.Logger,
6973
) (providers.Map, error) {
7074
providersMap := make(providers.Map)
7175

@@ -180,6 +184,10 @@ func getOauth2Providers(
180184
}
181185

182186
if cCtx.Bool(flagAzureadEnabled) {
187+
logger.WarnContext(
188+
cCtx.Context, "AzureAD provider is deprecated, use EntraID provider instead",
189+
)
190+
183191
providersMap["azuread"] = providers.NewAzureadProvider(
184192
cCtx.String(flagAzureadClientID),
185193
cCtx.String(flagAzureadClientSecret),
@@ -189,6 +197,16 @@ func getOauth2Providers(
189197
)
190198
}
191199

200+
if cCtx.Bool(flagEntraIDEnabled) {
201+
providersMap["entraid"] = providers.NewEntraIDProvider(
202+
cCtx.String(flagEntraIDClientID),
203+
cCtx.String(flagEntraIDClientSecret),
204+
cCtx.String(flagServerURL),
205+
cCtx.String(flagEntraIDTenant),
206+
getScopes(api.SignInProviderEntraid, cCtx.StringSlice(flagEntraIDScope)),
207+
)
208+
}
209+
192210
if cCtx.Bool(flagFacebookEnabled) {
193211
providersMap["facebook"] = providers.NewFacebookProvider(
194212
cCtx.String(flagFacebookClientID),

go/cmd/serve.go

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,11 @@ const (
154154
flagAzureadClientSecret = "azuread-client-secret" //nolint:gosec
155155
flagAzureadTenant = "azuread-tenant"
156156
flagAzureadScope = "azuread-scope"
157+
flagEntraIDEnabled = "entraid-enabled"
158+
flagEntraIDClientID = "entraid-client-id"
159+
flagEntraIDClientSecret = "entraid-client-secret" //nolint:gosec
160+
flagEntraIDTenant = "entraid-tenant"
161+
flagEntraIDScope = "entraid-scope"
157162
flagFacebookEnabled = "facebook-enabled"
158163
flagFacebookClientID = "facebook-client-id"
159164
flagFacebookClientSecret = "facebook-client-secret"
@@ -1042,6 +1047,7 @@ func CommandServe() *cli.Command { //nolint:funlen,maintidx
10421047
Name: flagAzureadTenant,
10431048
Usage: "Azuread Tenant",
10441049
Category: "oauth-azuread",
1050+
Value: "common",
10451051
EnvVars: []string{"AUTH_PROVIDER_AZUREAD_TENANT"},
10461052
},
10471053
&cli.StringSliceFlag{ //nolint: exhaustruct
@@ -1051,6 +1057,40 @@ func CommandServe() *cli.Command { //nolint:funlen,maintidx
10511057
Value: cli.NewStringSlice(providers.DefaultAzureadScopes...),
10521058
EnvVars: []string{"AUTH_PROVIDER_AZUREAD_SCOPE"},
10531059
},
1060+
// Microsoft EntraID flags
1061+
&cli.BoolFlag{ //nolint: exhaustruct
1062+
Name: flagEntraIDEnabled,
1063+
Usage: "Enable EntraID OAuth provider",
1064+
Category: "oauth-entraid",
1065+
Value: false,
1066+
EnvVars: []string{"AUTH_PROVIDER_ENTRAID_ENABLED"},
1067+
},
1068+
&cli.StringFlag{ //nolint: exhaustruct
1069+
Name: flagEntraIDClientID,
1070+
Usage: "EntraID OAuth client ID",
1071+
Category: "oauth-entraid",
1072+
EnvVars: []string{"AUTH_PROVIDER_ENTRAID_CLIENT_ID"},
1073+
},
1074+
&cli.StringFlag{ //nolint: exhaustruct
1075+
Name: flagEntraIDClientSecret,
1076+
Usage: "EntraID OAuth client secret",
1077+
Category: "oauth-entraid",
1078+
EnvVars: []string{"AUTH_PROVIDER_ENTRAID_CLIENT_SECRET"},
1079+
},
1080+
&cli.StringFlag{ //nolint:exhaustruct
1081+
Name: flagEntraIDTenant,
1082+
Usage: "EntraID Tenant",
1083+
Category: "oauth-entraid",
1084+
Value: "common",
1085+
EnvVars: []string{"AUTH_PROVIDER_ENTRAID_TENANT"},
1086+
},
1087+
&cli.StringSliceFlag{ //nolint: exhaustruct
1088+
Name: flagEntraIDScope,
1089+
Usage: "EntraID OAuth scope",
1090+
Category: "oauth-entraid",
1091+
Value: cli.NewStringSlice(providers.DefaultEntraIDScopes...),
1092+
EnvVars: []string{"AUTH_PROVIDER_ENTRAID_SCOPE"},
1093+
},
10541094
// Facebook provider flags
10551095
&cli.BoolFlag{ //nolint: exhaustruct
10561096
Name: flagFacebookEnabled,
@@ -1271,7 +1311,7 @@ func getGoServer( //nolint:funlen
12711311
return nil, err
12721312
}
12731313

1274-
oauthProviders, err := getOauth2Providers(cCtx)
1314+
oauthProviders, err := getOauth2Providers(cCtx, logger)
12751315
if err != nil {
12761316
return nil, fmt.Errorf("problem creating oauth providers: %w", err)
12771317
}

go/controller/errors.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,13 @@ func (response ErrorResponse) VisitRefreshTokenResponse(w http.ResponseWriter) e
168168
return response.visit(w)
169169
}
170170

171-
func (response ErrorResponse) VisitSignInIdTokenResponse( //nolint:revive,stylecheck
171+
func (response ErrorResponse) VisitSignInIdTokenResponse( //nolint:revive
172172
w http.ResponseWriter,
173173
) error {
174174
return response.visit(w)
175175
}
176176

177-
func (response ErrorResponse) VisitLinkIdTokenResponse( //nolint:revive,stylecheck
177+
func (response ErrorResponse) VisitLinkIdTokenResponse( //nolint:revive
178178
w http.ResponseWriter,
179179
) error {
180180
return response.visit(w)

go/controller/link_id_token.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/nhost/hasura-auth/go/middleware"
88
)
99

10-
func (ctrl *Controller) LinkIdToken( //nolint:ireturn,revive,stylecheck
10+
func (ctrl *Controller) LinkIdToken( //nolint:ireturn,revive
1111
ctx context.Context, req api.LinkIdTokenRequestObject,
1212
) (api.LinkIdTokenResponseObject, error) {
1313
logger := middleware.LoggerFromContext(ctx)

0 commit comments

Comments
 (0)