From 93af191e77d9ca6a990c7cf6cbe552d5549366ca Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Thu, 12 Apr 2012 16:54:25 -0700 Subject: [PATCH] auth: add some more auth modes Change-Id: I1674f5fff8a8ea3490f315844df68a474f8c6d5e --- pkg/auth/auth.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/pkg/auth/auth.go b/pkg/auth/auth.go index ac679f891..56c60e4b3 100644 --- a/pkg/auth/auth.go +++ b/pkg/auth/auth.go @@ -63,6 +63,10 @@ func FromConfig(authConfig string) (AuthMode, error) { } switch authType { + case "none": + return None{}, nil + case "localhost": + return Localhost{}, nil case "userpass": if len(pieces) < 3 { return nil, fmt.Errorf("Wrong userpass auth string; needs to be \"userpass:user:password\"") @@ -129,6 +133,24 @@ func (up *UserPass) AddAuthHeader(req *http.Request) { req.SetBasicAuth(up.Username, up.Password) } +type None struct{} + +func (None) IsAuthorized(req *http.Request) bool { + return true +} + +type Localhost struct { + None +} + +func (Localhost) IsAuthorized(req *http.Request) bool { + return localhostAuthorized(req) +} + +func (None) AddAuthHeader(req *http.Request) { + // Nothing. +} + // DevAuth is used when the env var CAMLI_ADVERTISED_PASSWORD // is defined type DevAuth struct {