reauth

package module
v0.0.0-...-8e8e0ba Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2018 License: MIT Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

reauth

Another authentication plugin for CaddyServer

Abstract

Provides a common basis for various and multiple authentication systems. This came to be as we wanted to dynamically authenticate our docker registry against gitlab-ci and avoid storing credentials in gitlab while still permitting users to log in with their own credentials.

Supported backends

The following backends are supported.

With more to come...

Supported failure handlers

The following failure handlers are supported.

Configuration

The core of the plugin supports the following arguments:

Parameter-Name Description
path the path to protect, may be repeated but be aware of strange interactions with except (required)
except sub path to permit unrestricted access to (optional, can be repeated)
failure what to do on failure (see failure handlers, default is HTTPBasic)

Example:

	reauth {
		path /
		except /public
		except /not_so_secret
	}

Along with these two arguments you are required to specify at least one backend.

Backends

Simple

This is the simplest plugin, taking just a list of username=password[,username=password].

Example:

	simple user1=password1,user2=password2
Upstream

Authentication against an upstream http server by performing a http basic authenticated request and checking the response for a http 200 OK status code. Anything other than a 200 OK status code will result in a failure to authenticate.

Parameters for this backend:

Parameter-Name Description
url http/https url to call
skipverify true to ignore TLS errors (optional, false by default)
timeout request timeout (optional 1m by default, go duration syntax is supported)
follow follow redirects (disabled by default as redirecting to a login page might cause a 200)
cookies true to pass cookies to the upstream server

Example

	upstream url=https://google.com,skipverify=true,timeout=5s
GitlabCI

Authenticate against Gitlab as the gitlab-ci-user for the purposes of letting the gitlab-ci access otherwise protected resources without storing credentials in gitlab or gitlab-ci.yml. Works basically like the [Upstream]#upstream backend except the username you provide is the project path

Parameters for this backend:

Parameter-Name Description
url http/https url to call
skipverify true to ignore TLS errors (optional, false by default)
timeout request timeout (optional 1m by default, go duration syntax is supported)

Example

	gitlab url=https://gitlab.example.com,skipverify=true,timeout=5s

Example of logging in via gitlab-ci.yml

	docker login docker.example.com -u "$CI_PROJECT_PATH" -p "$CI_BUILD_TOKEN"
LDAP

Authenticate against a specified LDAP server - for example a Microsoft AD server.

Parameters for this backend are JSON-encoded!

Parameter-Name Description
host host, required - i.e. ldap.example.com
port port, optional (default 389)
tls should StartTLS be used? (default false)
bindUsername (read-only) bind username - i.e. ldap-auth
bindPassword the password for the bind username
skipverify true to ignore TLS errors (optional, false by default)
timeout request timeout (optional 1m by default, go duration syntax is supported)
base Search base, for example "OU=Users,OU=Company,DC=example,DC=com"
filter Filter the users, for example "(&(memberOf=CN=group,OU=Users,OU=Company,DC=example,DC=com)(objectClass=user)(sAMAccountName=%s))"

Example

	ldap {"url":"ldap://ldap-auth:passw@ldap.example.com:389","timeout":"5s","skipverify":true,"base":"OU=Users,OU=Company,DC=example,DC=com","filter":"(&(memberOf=CN=group,OU=Users,OU=Company,DC=example,DC=com)(objectClass=user)(sAMAccountName=%s))"}

Failure handlers

HTTPBasic

This is the default failure handler and is by default configured to send the requested host as the realm

Parameters for this handler:

Parameter-Name Description
realm name of the realm to authenticate against - defaults to host

Example

	failure httpbasic realm=example.org
Redirect

Redirect the user, perhaps to a login page?

Parameters for this handler:

Parameter-Name Description
target target url for the redirection (required)
code the http status code to use, defaults to 302

Example

	failure redirect target=example.org,code=303
Status

Simplest possible failure handler, return http status $code

Parameters for this handler:

Parameter-Name Description
code the http status code to use, defaults to 401

Example

	failure status code=418

Todo

Modularise the failure handlers...

Documentation

Overview

Package reauth is yet another authentication plugin for CaddyServer

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reauth

type Reauth struct {
	// contains filtered or unexported fields
}

Reauth is the main package structure containing all the goodies a good structure needs to live a honest life

func (Reauth) ServeHTTP

func (h Reauth) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error)

ServeHTTP implements the handler interface for Caddy's middleware

type Rule

type Rule struct {
	// contains filtered or unexported fields
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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