git.iko.soy/typeable/oauth2-proxy
on master help sign in
Custom footer text (optional)

Closes #256 and #166

commit57f82ed71e1bd88fc31757a91905af140dbc7781 authorJehiah Czebotar <jehiah@gmail.com> dateSat 18 Jun 2016, 23:53 (10 years ago) parent168cff9
4 files changed+11−1
main.go+1−1 oauthproxy.go+4 options.go+1 templates.go+5
main.go+1−1
@@ -51,6 +51,7 @@ func main() {
5151 flagSet.String("htpasswd-file", "", "additionally authenticate against a htpasswd file. Entries must be created with \"htpasswd -s\" for SHA encryption")
5252 flagSet.Bool("display-htpasswd-form", true, "display username / password login form if an htpasswd file is provided")
5353 flagSet.String("custom-templates-dir", "", "path to custom html templates")
54+ flagSet.String("footer", "", "custom footer string. Use \"-\" to disable default footer.")
5455 flagSet.String("proxy-prefix", "/oauth2", "the url root path that this proxy should be nested under (e.g. /<oauth2>/sign_in)")
5556
5657 flagSet.String("cookie-name", "_oauth2_proxy", "the name of the cookie that the oauth_proxy creates")
@@ -98,7 +99,6 @@ func main() {
9899 log.Printf("%s", err)
99100 os.Exit(1)
100101 }
101−
102102 validator := NewValidator(opts.EmailDomains, opts.AuthenticatedEmailsFile)
103103 oauthproxy := NewOAuthProxy(opts, validator)
104104
oauthproxy.go+4
@@ -66,6 +66,7 @@ type OAuthProxy struct {
6666 skipAuthRegex []string
6767 compiledRegex []*regexp.Regexp
6868 templates *template.Template
69+ Footer string
6970}
7071
7172type UpstreamProxy struct {
@@ -199,6 +200,7 @@ func NewOAuthProxy(opts *Options, validator func(string) bool) *OAuthProxy {
199200 SkipProviderButton: opts.SkipProviderButton,
200201 CookieCipher: cipher,
201202 templates: loadTemplates(opts.CustomTemplatesDir),
203+ Footer: opts.Footer,
202204 }
203205}
204206
@@ -345,6 +347,7 @@ func (p *OAuthProxy) SignInPage(rw http.ResponseWriter, req *http.Request, code
345347 Redirect string
346348 Version string
347349 ProxyPrefix string
350+ Footer template.HTML
348351 }{
349352 ProviderName: p.provider.Data().ProviderName,
350353 SignInMessage: p.SignInMessage,
@@ -352,6 +355,7 @@ func (p *OAuthProxy) SignInPage(rw http.ResponseWriter, req *http.Request, code
352355 Redirect: redirect_url,
353356 Version: VERSION,
354357 ProxyPrefix: p.ProxyPrefix,
358+ Footer: template.HTML(p.Footer),
355359 }
356360 p.templates.ExecuteTemplate(rw, "sign_in.html", t)
357361}
options.go+1
@@ -35,6 +35,7 @@ type Options struct {
3535 HtpasswdFile string `flag:"htpasswd-file" cfg:"htpasswd_file"`
3636 DisplayHtpasswdForm bool `flag:"display-htpasswd-form" cfg:"display_htpasswd_form"`
3737 CustomTemplatesDir string `flag:"custom-templates-dir" cfg:"custom_templates_dir"`
38+ Footer string `flag:"footer" cfg:"footer"`
3839
3940 CookieName string `flag:"cookie-name" cfg:"cookie_name" env:"OAUTH2_PROXY_COOKIE_NAME"`
4041 CookieSecret string `flag:"cookie-secret" cfg:"cookie_secret" env:"OAUTH2_PROXY_COOKIE_SECRET"`
templates.go+5
@@ -130,7 +130,12 @@ func getTemplates() *template.Template {
130130 </div>
131131 {{ end }}
132132 <footer>
133+ {{ if eq .Footer "-" }}
134+ {{ else if eq .Footer ""}}
133135 Secured with <a href="https://github.com/bitly/oauth2_proxy#oauth2_proxy">OAuth2 Proxy</a> version {{.Version}}
136+ {{ else }}
137+ {{.Footer}}
138+ {{ end }}
134139 </footer>
135140</body>
136141</html>