From 6f86efb594721bc577c56b284f5f2499e563c45c Mon Sep 17 00:00:00 2001 From: Patrick O'Doherty Date: Mon, 23 May 2016 17:56:15 +0100 Subject: Don't allow wide-open Google or Github configs Fail loudly if either the google_opts domain value or github_opts organization values are not set in the configuration. The lack of these values means that a) in the Google case any @gmail.com address will be allowed b) the Github case any Github user will be allowed. This was previously documented but left as a foot-gun in the code. Future commits will allow for explicit wildcards to be set. --- server/auth/google/google.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'server/auth/google/google.go') diff --git a/server/auth/google/google.go b/server/auth/google/google.go index cf780f3..0328d42 100644 --- a/server/auth/google/google.go +++ b/server/auth/google/google.go @@ -1,6 +1,7 @@ package google import ( + "errors" "fmt" "net/http" "strings" @@ -26,7 +27,11 @@ type Config struct { } // New creates a new Google provider from a configuration. -func New(c *config.Auth) auth.Provider { +func New(c *config.Auth) (auth.Provider, error) { + if c.ProviderOpts["domain"] == "" { + return nil, errors.New("google_opts domain must not be empty") + } + return &Config{ config: &oauth2.Config{ ClientID: c.OauthClientID, @@ -36,7 +41,7 @@ func New(c *config.Auth) auth.Provider { Scopes: []string{googleapi.UserinfoEmailScope, googleapi.UserinfoProfileScope}, }, domain: c.ProviderOpts["domain"], - } + }, nil } // A new oauth2 http client. -- cgit v1.2.3