extauth

package module
v0.0.0-...-a59451c Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2020 License: MIT Imports: 9 Imported by: 0

README

caddy-extauth

an external authentication plugin for caddy

Quickstart

Requirements

You need podman and buildah to use the projects Makefile. If you don't have those tools and don't want to install them, just go with the xcaddy instructions and use this repo as plugin module.

Build and Run
> make all
> make run
> curl -H "Authorization: secret" localhost:2015
You are authenticated!
> podman logs caddy-extauth-auth
{"level":"info","ip":"127.0.0.1:33554","time":"2020-10-16T06:09:33Z","message":"success"}
> podman logs caddy-extauth-logger
---
GET / HTTP/1.1
Host: localhost:2015
User-Agent: curl/7.72.0
Accept: */*
Accept-Encoding: gzip
Authorization: secret
X-Forwarded-For: 127.0.0.1
X-Forwarded-Proto: http
X-Token: token
> make stop

There is also a compose.yaml file for your reference.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Middleware

type Middleware struct {
	Endpoint            string            // http endpoint endpoint for the auth request
	Timeout             time.Duration     // timeout for the auth request
	CopyRequestHeaders  []string          // headers to copy from the incoming request to the auth request
	CopyResponseHeaders []string          // headers to copy from the auth response to the incoming request
	SetHeaders          map[string]string // headers to set in the auth request
	// contains filtered or unexported fields
}

Middleware implements an HTTP handler that calls an external service for authentication

func (Middleware) CaddyModule

func (Middleware) CaddyModule() caddy.ModuleInfo

CaddyModule returns the Caddy module information.

func (*Middleware) Provision

func (m *Middleware) Provision(ctx caddy.Context) error

Provision implements caddy.Provisioner.

func (Middleware) ServeHTTP

func (m Middleware) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error

ServeHTTP implements caddyhttp.MiddlewareHandler.

func (*Middleware) UnmarshalCaddyfile

func (m *Middleware) UnmarshalCaddyfile(d *caddyfile.Dispenser) (err error)

UnmarshalCaddyfile implements caddyfile.Unmarshaler.

func (*Middleware) Validate

func (m *Middleware) Validate() error

Validate implements caddy.Validator.

Jump to

Keyboard shortcuts

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