This is demo how to use forwardauth
middleware of traefik
.
You can find more details about it on official traefik docs
- register an app in Azure Active Directory to obtain
ClientId
,ClientSecret
,TenantId
- build docker image
src/TraefikAuthAAD/Dockerfile
and publish it to a registry - create a deploy and make sure that you override these environment variables:
- JwtSigningKey="-- required: put your signing key --"
- AzureAD__GroupId="-- optional: put id of group to restrict list of users that have access --"
- AzureAD__ClientId="{clientId}"
- AzureAD__ClientSecret="{clientSecret}"
- AzureAD__AuthorizeEndpoint="https://login.microsoftonline.com/{tenantid}/oauth2/v2.0/authorize"
- AzureAD__TokenEndpoint="https://login.microsoftonline.com/{tenantid}/oauth2/v2.0/token"
- create a service for the deploy
- create a traefik middleware object:
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: auth
spec:
forwardAuth:
address: http://{service name or ip}/auth
trustForwardHeader: true
- use the middleware in your ingress objects