oidc-auth

command
v0.16.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

README

OIDC token validation

An HTTP server that accepts GitHub Actions OIDC tokens. The validator is global middleware: every request needs a valid bearer token in the Authorization header. Cookies are not read.

For an API with principal extraction and a role check, see api-auth. For a browser app with a login, see browser-session.

Running the example

go run ./examples/oidc-auth
Variable Meaning Default
LISTEN_ADDR address to listen on 127.0.0.1:8080
OIDC_AUDIENCE accepted token audience https://github.com/my-org

Then call it with a token that GitHub Actions issued for that audience. A request with no token is refused with 401:

curl -i http://127.0.0.1:8080/secure
curl -H 'Authorization: Bearer <token>' http://127.0.0.1:8080/secure

See githubactions-oidc for getting a token inside a workflow.

What it demonstrates

  • Creating an OIDC validator configuration for GitHub Actions
  • Using the OAuth2 validator as global middleware
  • Shutting down on SIGTERM

See main.go for the code.

Documentation

Overview

Command main demonstrates wrapping an HTTP server with OIDC token validation middleware, accepting GitHub Actions OIDC tokens.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL