git.iko.soy/typeable/oauth2-proxy
on master help sign in
Merge pull request #195 from steakunderscore/banner-flag

Adds banner flag

commit4eefc01600b7a915f28e374ac72fe00662db3bec authorJoel Speed <Joel.speed@hotmail.co.uk> dateThu 4 Jul 2019, 11:24 (7 years ago) parent85c5cefaa37564
5 files changed+13−1
CHANGELOG.md+1 docs/configuration/configuration.md+1 main.go+8−1 oauthproxy.go+2 options.go+1
CHANGELOG.md+1
@@ -62,6 +62,7 @@
6262- [#185](https://github.com/pusher/oauth2_proxy/pull/185) Fix an unsupported protocol scheme error during token validation when using the Azure provider (@jonas)
6363- [#141](https://github.com/pusher/oauth2_proxy/pull/141) Check google group membership based on email address (@bchess)
6464 - Google Group membership is additionally checked via email address, allowing users outside a GSuite domain to be authorized.
65+- [#195](https://github.com/pusher/outh2_proxy/pull/195) Add `-banner` flag for overriding the banner line that is displayed (@steakunderscore)
6566- [#198](https://github.com/pusher/outh2_proxy/pull/198) Switch from gometalinter to golangci-lint (@steakunderscore)
6667
6768# v3.2.0
docs/configuration/configuration.md+1
@@ -43,6 +43,7 @@ Usage of oauth2_proxy:
4343 -email-domain value: authenticate emails with the specified domain (may be given multiple times). Use * to authenticate any email
4444 -extra-jwt-issuers: if -skip-jwt-bearer-tokens is set, a list of extra JWT issuer=audience pairs (where the issuer URL has a .well-known/openid-configuration or a .well-known/jwks.json)
4545 -flush-interval: period between flushing response buffers when streaming responses (default "1s")
46+ -banner string: custom banner string. Use "-" to disable default banner.
4647 -footer string: custom footer string. Use "-" to disable default footer.
4748 -gcp-healthchecks: will enable /liveness_check, /readiness_check, and / (with the proper user-agent) endpoints that will make it work well with GCP App Engine and GKE Ingresses (default false)
4849 -github-org string: restrict logins to members of this organisation
main.go+8−1
@@ -66,6 +66,7 @@ func main() {
6666 flagSet.String("htpasswd-file", "", "additionally authenticate against a htpasswd file. Entries must be created with \"htpasswd -s\" for SHA encryption or \"htpasswd -B\" for bcrypt encryption")
6767 flagSet.Bool("display-htpasswd-form", true, "display username / password login form if an htpasswd file is provided")
6868 flagSet.String("custom-templates-dir", "", "path to custom html templates")
69+ flagSet.String("banner", "", "custom banner string. Use \"-\" to disable default banner.")
6970 flagSet.String("footer", "", "custom footer string. Use \"-\" to disable default footer.")
7071 flagSet.String("proxy-prefix", "/oauth2", "the url root path that this proxy should be nested under (e.g. /<oauth2>/sign_in)")
7172 flagSet.Bool("proxy-websockets", true, "enables WebSocket proxying")
@@ -148,7 +149,13 @@ func main() {
148149 validator := NewValidator(opts.EmailDomains, opts.AuthenticatedEmailsFile)
149150 oauthproxy := NewOAuthProxy(opts, validator)
150151
151− if len(opts.EmailDomains) != 0 && opts.AuthenticatedEmailsFile == "" {
152+ if len(opts.Banner) >= 1 {
153+ if opts.Banner == "-" {
154+ oauthproxy.SignInMessage = ""
155+ } else {
156+ oauthproxy.SignInMessage = opts.Banner
157+ }
158+ } else if len(opts.EmailDomains) != 0 && opts.AuthenticatedEmailsFile == "" {
152159 if len(opts.EmailDomains) > 1 {
153160 oauthproxy.SignInMessage = fmt.Sprintf("Authenticate using one of the following domains: %v", strings.Join(opts.EmailDomains, ", "))
154161 } else if opts.EmailDomains[0] != "*" {
oauthproxy.go+2
@@ -98,6 +98,7 @@ type OAuthProxy struct {
9898 jwtBearerVerifiers []*oidc.IDTokenVerifier
9999 compiledRegex []*regexp.Regexp
100100 templates *template.Template
101+ Banner string
101102 Footer string
102103}
103104
@@ -280,6 +281,7 @@ func NewOAuthProxy(opts *Options, validator func(string) bool) *OAuthProxy {
280281 PassAuthorization: opts.PassAuthorization,
281282 SkipProviderButton: opts.SkipProviderButton,
282283 templates: loadTemplates(opts.CustomTemplatesDir),
284+ Banner: opts.Banner,
283285 Footer: opts.Footer,
284286 }
285287}
options.go+1
@@ -51,6 +51,7 @@ type Options struct {
5151 HtpasswdFile string `flag:"htpasswd-file" cfg:"htpasswd_file" env:"OAUTH2_PROXY_HTPASSWD_FILE"`
5252 DisplayHtpasswdForm bool `flag:"display-htpasswd-form" cfg:"display_htpasswd_form" env:"OAUTH2_PROXY_DISPLAY_HTPASSWD_FORM"`
5353 CustomTemplatesDir string `flag:"custom-templates-dir" cfg:"custom_templates_dir" env:"OAUTH2_PROXY_CUSTOM_TEMPLATES_DIR"`
54+ Banner string `flag:"banner" cfg:"banner" env:"OAUTH2_PROXY_BANNER"`
5455 Footer string `flag:"footer" cfg:"footer" env:"OAUTH2_PROXY_FOOTER"`
5556
5657 // Embed CookieOptions