/Traefik OIDC Authentication WASM

Traefik OIDC Authentication WASM

3
v0.0.6

Traefik OIDC WASM Plugin

This plugin allows you to secure the upstream services with an OpenID Connect (OIDC) provider. It uses the WASM extension of Traefik to perform.

[!WARNING] This middleware is under active development - things should NOT break, but they might.

💡 Getting Started

Enable the plugin in your traefik configuration.

experimental:
plugins:
traefik-oidc:
moduleName: "github.com/xzzpig/traefik-oidc-wasm"
version: "v0.0.4"

Add a middleware and reference it in a route.

http:
services:
whoami:
loadBalancer:
servers:
- url: http://whoami:80
middlewares:
oidc-auth:
plugin:
traefik-oidc:
provider:
issuerUrl: "https://idm.example.com"
clientID: your_client_id
clientSecret: your_client_secret
scopes: ["openid", "profile", "email", "groups"]
claimMap:
name: "X-Oidc-Name"
preferred_username: "X-Oidc-Username"
sub: "X-Oidc-Subject"
groups: "X-Oidc-Groups"
endpoint:
logout: "/oauth2/logout"
routers:
whoami:
entryPoints: ["web"]
rule: "HostRegexp(`.+`)"
service: whoami
middlewares: ["oidc-auth"]

🛠 Configuration Options

Plugin Config

NameRequiredTypeDefaultDescription
provideryesProvidernoneIdentity Provider Configuration. See Provider Config.
cookienoCookienoneCookie Configuration. See Cookie Config.
endpointnoEndpointnoneEndpoint Configuration. See Endpoint Config.
totpnoTOTPnoneTOTP Configuration to generate auth state. See TOTP Config.
claimMapnomap[string]stringnonekey value pairs of claims to extract from the OIDC token and set as headers.
dnsAddrnostring"1.1.1.1:53"Address of the DNS server to use. (Because there is no default DNS resolver in WASM, this is required)
tokenAutoRefreshTimenotime.Duration5mThe rest of time to auto refresh the token.
enablenobooltrueEnable the plugin.

Provider Config

NameRequiredTypeDefaultDescription
issuerUrlyesstringnoneURL of the OIDC provider.
clientIDyesstringnoneClient ID of the OIDC client.
clientSecretyesstringnoneClient Secret of the OIDC client.
scopesno[]string["openid"]Scopes to request from the OIDC provider.
NameRequiredTypeDefaultDescription
accessTokennostring"__oidc_token"Name of the cookie to store the access token.
refreshTokennostring"__oidc_refresh_token"Name of the cookie to store the refresh token.
originPathnostring"__oidc_origin_path"Name of the cookie to store the origin path.

Endpoint Config

NameRequiredTypeDefaultDescription
callbacknostring"/oauth2/callback"Path to the OIDC callback endpoint.
logoutnostring"/oauth2/logout"Path to the OIDC logout endpoint.
fallbacknostring"/"Path to the fallback endpoint. When logout is called, it will redirect to this endpoint.

TOTP Config

NameRequiredTypeDefaultDescription
Periodnouint30The period of the TOTP token.
Skewnouint0The skew of the TOTP token.
Digestnouint8The length of the TOTP token.
Algorithmnostring"SHA1"The algorithm of the TOTP token.