git.iko.soy/typeable/oauth2-proxy
on master help sign in
Merge pull request #78 from 18F/generalize-templates
243dbb7Jehiah Czebotar
oauthproxy.go+2
@@ -279,11 +279,13 @@ func (p *OauthProxy) SignInPage(rw http.ResponseWriter, req *http.Request, code
279 rw.WriteHeader(code)
279 rw.WriteHeader(code)
280
280
281 t := struct {
281 t := struct {
282+ ProviderName string
282 SignInMessage string
283 SignInMessage string
283 CustomLogin bool
284 CustomLogin bool
284 Redirect string
285 Redirect string
285 Version string
286 Version string
286 }{
287 }{
288+ ProviderName: p.provider.Data().ProviderName,
287 SignInMessage: p.SignInMessage,
289 SignInMessage: p.SignInMessage,
288 CustomLogin: p.displayCustomLoginForm(),
290 CustomLogin: p.displayCustomLoginForm(),
289 Redirect: req.URL.RequestURI(),
291 Redirect: req.URL.RequestURI(),
providers/google.go+1
@@ -13,6 +13,7 @@ type GoogleProvider struct {
13}
13}
14
14
15func NewGoogleProvider(p *ProviderData) *GoogleProvider {
15func NewGoogleProvider(p *ProviderData) *GoogleProvider {
16+ p.ProviderName = "Google"
16 if p.LoginUrl.String() == "" {
17 if p.LoginUrl.String() == "" {
17 p.LoginUrl = &url.URL{Scheme: "https",
18 p.LoginUrl = &url.URL{Scheme: "https",
18 Host: "accounts.google.com",
19 Host: "accounts.google.com",
providers/google_test.go+7−4
@@ -11,15 +11,17 @@ import (
11func newGoogleProvider() *GoogleProvider {
11func newGoogleProvider() *GoogleProvider {
12 return NewGoogleProvider(
12 return NewGoogleProvider(
13 &ProviderData{
13 &ProviderData{
14+ ProviderName: "",
14− LoginUrl: &url.URL{},
15+ LoginUrl: &url.URL{},
15− RedeemUrl: &url.URL{},
16+ RedeemUrl: &url.URL{},
16− ProfileUrl: &url.URL{},
17+ ProfileUrl: &url.URL{},
17− Scope: ""})
18+ Scope: ""})
18}
19}
19
20
20func TestGoogleProviderDefaults(t *testing.T) {
21func TestGoogleProviderDefaults(t *testing.T) {
21 p := newGoogleProvider()
22 p := newGoogleProvider()
22 assert.NotEqual(t, nil, p)
23 assert.NotEqual(t, nil, p)
24+ assert.Equal(t, "Google", p.Data().ProviderName)
23 assert.Equal(t, "https://accounts.google.com/o/oauth2/auth",
25 assert.Equal(t, "https://accounts.google.com/o/oauth2/auth",
24 p.Data().LoginUrl.String())
26 p.Data().LoginUrl.String())
25 assert.Equal(t, "https://accounts.google.com/o/oauth2/token",
27 assert.Equal(t, "https://accounts.google.com/o/oauth2/token",
@@ -45,6 +47,7 @@ func TestGoogleProviderOverrides(t *testing.T) {
45 Path: "/oauth/profile"},
47 Path: "/oauth/profile"},
46 Scope: "profile"})
48 Scope: "profile"})
47 assert.NotEqual(t, nil, p)
49 assert.NotEqual(t, nil, p)
50+ assert.Equal(t, "Google", p.Data().ProviderName)
48 assert.Equal(t, "https://example.com/oauth/auth",
51 assert.Equal(t, "https://example.com/oauth/auth",
49 p.Data().LoginUrl.String())
52 p.Data().LoginUrl.String())
50 assert.Equal(t, "https://example.com/oauth/token",
53 assert.Equal(t, "https://example.com/oauth/token",
providers/provider_data.go+5−4
@@ -5,10 +5,11 @@ import (
5)
5)
6
6
7type ProviderData struct {
7type ProviderData struct {
8+ ProviderName string
8− LoginUrl *url.URL
9+ LoginUrl *url.URL
9− RedeemUrl *url.URL
10+ RedeemUrl *url.URL
10− ProfileUrl *url.URL
11+ ProfileUrl *url.URL
11− Scope string
12+ Scope string
12}
13}
13
14
14func (p *ProviderData) Data() *ProviderData { return p }
15func (p *ProviderData) Data() *ProviderData { return p }
templates.go+1−1
@@ -115,7 +115,7 @@ func getTemplates() *template.Template {
115 {{ if .SignInMessage }}
115 {{ if .SignInMessage }}
116 <p>{{.SignInMessage}}</p>
116 <p>{{.SignInMessage}}</p>
117 {{ end}}
117 {{ end}}
118− <button type="submit" class="btn">Sign in with a Google Account</button><br/>
118+ <button type="submit" class="btn">Sign in with a {{.ProviderName}} Account</button><br/>
119 </form>
119 </form>
120 </div>
120 </div>
121
121