{"id":23789802,"url":"https://github.com/officiallysingh/spring-cloud-api-grateway-azuread-auth","last_synced_at":"2026-04-25T08:35:30.655Z","repository":{"id":238099895,"uuid":"795853131","full_name":"officiallysingh/spring-cloud-api-grateway-azuread-auth","owner":"officiallysingh","description":"Demo project for Spring Cloud API Gateway with AzureAD Auth","archived":false,"fork":false,"pushed_at":"2024-05-06T13:36:32.000Z","size":72,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-21T12:43:18.944Z","etag":null,"topics":["authentication","azure","azure-active-directory","azure-ad","oauth2","oidc","openid-connect","spring-cloud-gateway","spring-security"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/officiallysingh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-04T08:45:58.000Z","updated_at":"2024-05-06T13:36:35.000Z","dependencies_parsed_at":"2025-02-21T12:42:47.273Z","dependency_job_id":"fe8a9fef-0d94-4ee0-bb36-91a540c0b649","html_url":"https://github.com/officiallysingh/spring-cloud-api-grateway-azuread-auth","commit_stats":null,"previous_names":["officiallysingh/spring-cloud-api-grateway-azuread-auth"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/officiallysingh/spring-cloud-api-grateway-azuread-auth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/officiallysingh%2Fspring-cloud-api-grateway-azuread-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/officiallysingh%2Fspring-cloud-api-grateway-azuread-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/officiallysingh%2Fspring-cloud-api-grateway-azuread-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/officiallysingh%2Fspring-cloud-api-grateway-azuread-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/officiallysingh","download_url":"https://codeload.github.com/officiallysingh/spring-cloud-api-grateway-azuread-auth/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/officiallysingh%2Fspring-cloud-api-grateway-azuread-auth/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263061404,"owners_count":23407606,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["authentication","azure","azure-active-directory","azure-ad","oauth2","oidc","openid-connect","spring-cloud-gateway","spring-security"],"created_at":"2025-01-01T17:16:47.023Z","updated_at":"2026-04-25T08:35:30.630Z","avatar_url":"https://github.com/officiallysingh.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Read Me First\nDemo Spring cloud Gateway and applying Authentication using Azure AD. Demo downstream service available at [`spring-boot-web-auth-demo`](https://github.com/officiallysingh/spring-boot-web-auth-demo)\n\n## Guides\nThe following guides illustrate how to use Spring cloud Gateway and applying Authentication using Azure AD:\n\n* [Gateway](https://docs.spring.io/spring-cloud-gateway/docs/current/reference/html/)\n* [Securing a Java Web App with the Spring Boot Starter for Azure Active Directory](https://aka.ms/spring/msdocs/aad)\n* [Azure Active Directory](https://microsoft.github.io/spring-cloud-azure/current/reference/html/index.html#spring-security-with-azure-active-directory)\n\n## Gateway Routes configurations\n* `uri` of downstream service. \n* Path predicate\n* `TokenRelay` to forward Access Token received from Azure AD as `Authorization` header to downstream services.  \n\n```yaml\nspring:\n  cloud:\n    #------------------------- API Gateway configuration -------------------------\n    gateway:\n      routes:\n        - id: book-service\n          uri: http://localhost:8081\n          predicates:\n            - Path=/api/**\n          filters:\n            - TokenRelay=\n```\n\n## Spring boot Azure AD configurations\n\nUpdate `tenant-id`, `client-id` and `client-secret` properties for your Azure AD settings, others remain the same.\n\n```yaml\nspring:\n  cloud:\n    #------------------------- Azure AD configuration -------------------------\n    azure:\n      active-directory:\n        enabled: true\n        profile:\n          tenant-id: ${AZURE_AD_TENANT_ID}\n        credential:\n          client-id: ${AZURE_AD_CLIENT_ID}\n          client-secret: ${AZURE_AD_CLIENT_SECRET}\n\n  security:\n    oauth2:\n      client:\n        registration:\n          azure:\n            client-id: ${spring.cloud.azure.active-directory.credential.client-id}\n            client-secret: ${spring.cloud.azure.active-directory.credential.client-secret}\n            authorization-grant-type: authorization_code\n            redirect-uri: \"{baseUrl}/login/oauth2/code/{registrationId}\"\n            scope: openid, profile, email\n        provider:\n          azure:\n            authorization-uri: https://login.microsoftonline.com/${spring.cloud.azure.active-directory.profile.tenant-id}/oauth2/v2.0/authorize\n            token-uri: https://login.microsoftonline.com/${spring.cloud.azure.active-directory.profile.tenant-id}/oauth2/v2.0/token\n            user-info-uri: https://graph.microsoft.com/oidc/userinfo\n            jwk-set-uri: https://login.microsoftonline.com/${spring.cloud.azure.active-directory.profile.tenant-id}/discovery/v2.0/keys\n            issuer-uri: https://login.microsoftonline.com/${spring.cloud.azure.active-directory.profile.tenant-id}/v2.0\n#           userNameAttribute: unique_name\n```\n\n## Run\nRun the main class [`SpringCloudApiGratewayAzureADAuthApplication`](src/main/java/com/ksoot/gateway/SpringCloudApiGratewayAzureADAuthApplication.java)\nand access the URL http://localhost:8080/api/hello in browser.  \nIt should redirect you to Azure AD login page, fill in Username and Password.  \nAfter successful authentication, you will get following response from downstream service.\n\n`Hello \u003cYou username\u003e from Downstream stream service`","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fofficiallysingh%2Fspring-cloud-api-grateway-azuread-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fofficiallysingh%2Fspring-cloud-api-grateway-azuread-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fofficiallysingh%2Fspring-cloud-api-grateway-azuread-auth/lists"}