# Start server
npm start
# With custom issuer
ISSUER=https://myauth.com npm start
# With custom data directory
NGAUTH_DATA=/data npm startGET /.well-known/openid-configuration
GET /.well-known/oauth-authorization-serverGET /authorize?client_id=ID&redirect_uri=URI&response_type=code&scope=openid%20profile&nonce=N
POST /authorize (form: username, password, client_id, redirect_uri, scope, state, nonce)POST /token
Content-Type: application/x-www-form-urlencoded
Authorization: Basic base64(client_id:client_secret)
grant_type=authorization_code&code=CODE&redirect_uri=URIGET /userinfo
Authorization: Bearer ACCESS_TOKENGET /.well-known/jwks.jsoncurl -X POST http://localhost:3000/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-u client-id:client-secret \
-d "grant_type=authorization_code&code=AUTH_CODE&redirect_uri=http://localhost:3001/callback"Response:
{
"access_token": "eyJ...",
"id_token": "eyJ...",
"token_type": "Bearer",
"expires_in": 3600,
"scope": "openid profile email"
}# Get ID token (from above response)
ID_TOKEN="eyJ..."
# Decode (without verification)
echo $ID_TOKEN | cut -d. -f2 | base64 -d | jq
# Verify with public key
curl -s http://localhost:3000/.well-known/jwks.json | jq '.keys[0]'Default test user (if created):
- Username:
testuser - Password:
testpass
openid- Get ID tokenprofile- Get name, preferred_username, updated_atemail- Get email, email_verified
-
Register Client (if needed)
curl -X POST http://localhost:3000/register \ -H "Content-Type: application/json" \ -d '{ "client_name": "My App", "redirect_uris": ["http://localhost:3001/callback"] }'
-
Authorize
# User visits: GET http://localhost:3000/authorize?client_id=...&redirect_uri=...&response_type=code&scope=openid&nonce=xyz
-
Get Code
Redirects to: http://localhost:3001/callback?code=AUTH_CODE&state=... -
Exchange Code
curl -X POST http://localhost:3000/token \ -u client:secret \ -d "grant_type=authorization_code&code=...&redirect_uri=..." -
Use ID Token
- Extract and verify JWT
- Check nonce claim matches sent value
- Extract user claims from token
-
Get More Info (optional)
curl -H "Authorization: Bearer ACCESS_TOKEN" \ http://localhost:3000/userinfo
const jwt = require('jsonwebtoken');
const fetch = require('node-fetch');
// 1. Get JWKS
const jwks = await fetch('http://localhost:3000/.well-known/jwks.json').then(r => r.json());
const key = jwks.keys[0];
// 2. Verify token
const decoded = jwt.verify(idToken, key, { algorithms: ['RS256'] });
console.log(decoded);
// 3. Check claims
console.assert(decoded.aud === clientId);
console.assert(decoded.nonce === originalNonce);
console.assert(decoded.exp > Date.now() / 1000);Token Endpoint 500 Error
- Check issuer configuration
- Verify client_id and secret
- Look at server logs
Invalid Token at Userinfo
- Ensure Bearer token is the access_token, not id_token
- Check token expiration
- Verify token format
JWKS Endpoint 404
- Confirm server started successfully
- Check server logs for key generation
- Verify URL:
/.well-known/jwks.json
Nonce Mismatch
- Include nonce in /authorize request
- Verify returned in id_token
- Client-side validation required
- Full docs: docs/OIDC.md
- Implementation: OIDC_IMPLEMENTATION.md
- Test examples: test/integration/oidc.test.js