mirror of
https://github.com/oauth2-proxy/oauth2-proxy.git
synced 2026-09-30 03:31:27 +02:00
Add ProviderName field; use in sign_in template
This commit is contained in:
@@ -13,6 +13,7 @@ type GoogleProvider struct {
|
||||
}
|
||||
|
||||
func NewGoogleProvider(p *ProviderData) *GoogleProvider {
|
||||
p.ProviderName = "Google"
|
||||
if p.LoginUrl.String() == "" {
|
||||
p.LoginUrl = &url.URL{Scheme: "https",
|
||||
Host: "accounts.google.com",
|
||||
|
||||
@@ -11,15 +11,17 @@ import (
|
||||
func newGoogleProvider() *GoogleProvider {
|
||||
return NewGoogleProvider(
|
||||
&ProviderData{
|
||||
LoginUrl: &url.URL{},
|
||||
RedeemUrl: &url.URL{},
|
||||
ProfileUrl: &url.URL{},
|
||||
Scope: ""})
|
||||
ProviderName: "",
|
||||
LoginUrl: &url.URL{},
|
||||
RedeemUrl: &url.URL{},
|
||||
ProfileUrl: &url.URL{},
|
||||
Scope: ""})
|
||||
}
|
||||
|
||||
func TestGoogleProviderDefaults(t *testing.T) {
|
||||
p := newGoogleProvider()
|
||||
assert.NotEqual(t, nil, p)
|
||||
assert.Equal(t, "Google", p.Data().ProviderName)
|
||||
assert.Equal(t, "https://accounts.google.com/o/oauth2/auth",
|
||||
p.Data().LoginUrl.String())
|
||||
assert.Equal(t, "https://accounts.google.com/o/oauth2/token",
|
||||
@@ -45,6 +47,7 @@ func TestGoogleProviderOverrides(t *testing.T) {
|
||||
Path: "/oauth/profile"},
|
||||
Scope: "profile"})
|
||||
assert.NotEqual(t, nil, p)
|
||||
assert.Equal(t, "Google", p.Data().ProviderName)
|
||||
assert.Equal(t, "https://example.com/oauth/auth",
|
||||
p.Data().LoginUrl.String())
|
||||
assert.Equal(t, "https://example.com/oauth/token",
|
||||
|
||||
@@ -5,10 +5,11 @@ import (
|
||||
)
|
||||
|
||||
type ProviderData struct {
|
||||
LoginUrl *url.URL
|
||||
RedeemUrl *url.URL
|
||||
ProfileUrl *url.URL
|
||||
Scope string
|
||||
ProviderName string
|
||||
LoginUrl *url.URL
|
||||
RedeemUrl *url.URL
|
||||
ProfileUrl *url.URL
|
||||
Scope string
|
||||
}
|
||||
|
||||
func (p *ProviderData) Data() *ProviderData { return p }
|
||||
|
||||
Reference in New Issue
Block a user