/authcookie

authcookie

1
v1.0.6

Auth Token Cookie Plugin for Traefik

A Traefik middleware plugin that authenticates requests using an internal authentication service and sets a token in the cookie header.

Features

  • Kubernetes-native authentication service integration
  • Secure token handling
  • Configurable endpoint support
  • Header-based authentication

Configuration

Static Configuration

# traefik.yml
experimental:
plugins:
authcookie:
moduleName: "github.com/k8trust/authcookie"
version: "v1.0.6"

Dynamic Configuration

# Dynamic configuration
http:
middlewares:
auth-token:
plugin:
authcookie:
authEndpoint: "http://k8s-service.namespace.svc.cluster.local/central/auth"

Configuration Options

OptionTypeDefaultDescription
authEndpointStringhttp://localhost:9000/test/auth/api-keyFull URL of the Kubernetes authentication service

Authentication Headers

HeaderDescription
x-api-keyAPI key for authentication
x-accountTenant identifier

Development

Project Structure

.
├── Dockerfile             # Container build configuration
├── Makefile              # Build automation
├── README.md             # Documentation
├── authcookie.go         # Main plugin implementation
├── authcookie_test.go    # Plugin tests
├── cmd/
│   └── server/
│       └── main.go       # Standalone server for testing
├── fake_auth_server.go   # Mock auth server for testing
└── go.mod                # Go module definition

Local Development

1. Start the Mock Auth Server

go run fake_auth_server.go

2. Run the Test Server

go run cmd/server/main.go

3. Test the Endpoints

# Test with authentication headers
curl -v \
-H "x-api-key: test-key" \
-H "x-account: test-account" \
http://localhost:8080
# Test unauthorized access
curl -v http://localhost:8080

Running Tests

go test -v ./...

Contributing

We welcome contributions! Please feel free to submit a Pull Request.

Contributors

License

MIT License