git.iko.soy/typeable/oauth2-proxy
on master help sign in
Adds banner flag

This is to override what's displayed on the main page.

commit924eab6355ae4414407a83583ba45cc29d8054db authorHenry Jenkins <henry@henryjenkins.com> dateWed 19 Jun 2019, 15:24 (7 years ago) parent317f09f
4 files changed+12−1
docs/configuration/configuration.md+1 main.go+8−1 oauthproxy.go+2 options.go+1
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
@@ -269,6 +270,7 @@ func NewOAuthProxy(opts *Options, validator func(string) bool) *OAuthProxy {
269270 PassAuthorization: opts.PassAuthorization,
270271 SkipProviderButton: opts.SkipProviderButton,
271272 templates: loadTemplates(opts.CustomTemplatesDir),
273+ Banner: opts.Banner,
272274 Footer: opts.Footer,
273275 }
274276}
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