This sample app has been modified to produce an id_token
and refresh_token
to stdout and your web browser once you've authenticated with Auth0
My use case was for Kubernetes cluster auth, namely Option 1 when configuring OpenID Connect for kubectl
You'll need an Auth0 account and web client
Auth0 Jargon:
- Auth0 Regular WebApp client
- Your client must be authorised in both the management and extensions API
- The extensions API should have
read:user_idp_tokens
scope and the Allow Offline Access activated
Required Environments Variables
Values can be found in Auth0 client settings
AUTH0_CLIENT_ID=< client id >
AUTH0_DOMAIN=< domain >
AUTH0_CLIENT_SECRET=< client_secret >
AUTH0_CALLBACK_URL=http://localhost:3000/callback
AUTH0_AUDIENCE=urn:auth0-authz-api
With Docker
Assuming you have set up a client in Auth0?
You'll need to retrieve values from your Auth0 client for the environment variables listed in the .env
file
Once done, simply run the exec.sh/exec.ps1
script and browse to http://localhost:3000 where you can authenticate
Your id_token
and refresh_token
output can be copy&pasted from the console you ran the exec.sh
from or your browser
See refresh_token and id_token docs for more info
or
Use my container and supply your own .env
file
docker container run --rm -it --env-file < .env > -p 3000:3000 quay.io/mojanalytics/auth0-golang-kube-app
Without Docker
-
First set the environment variables defined above
-
Run
go run main.go server.go
-
Browse to http://localhost:3000
Remember to Logout to end your session once you have finished.
Clearing cookies tends to resolve any unexpected behaviour. Particularly cookies with localhost in the name
Try accessing the app in another browser