Minor changes

This commit is contained in:
David J. Allen 2024-04-17 17:24:56 -06:00
parent af79cfe254
commit d7990807f0
No known key found for this signature in database
GPG key ID: 717C593FF60A2ACC
3 changed files with 8 additions and 4 deletions

View file

@ -41,7 +41,7 @@ func Login(config *Config, client *oauth.Client, provider *oidc.IdentityProvider
// print the authorization URL for sharing // print the authorization URL for sharing
var authorizationUrl = client.BuildAuthorizationUrl(provider.Endpoints.Authorization, state) var authorizationUrl = client.BuildAuthorizationUrl(provider.Endpoints.Authorization, state)
s := NewServerWithConfig(config) s := NewServerWithConfig(config)
fmt.Printf("Login with identity provider:\n\n %s/login\n %s\n\n", fmt.Printf("Login with external identity provider:\n\n %s/login\n %s\n\n",
s.GetListenAddr(), authorizationUrl, s.GetListenAddr(), authorizationUrl,
) )
@ -87,7 +87,7 @@ func Login(config *Config, client *oauth.Client, provider *oidc.IdentityProvider
Client: authzClient, Client: authzClient,
}, },
} }
err = s.Start(button, provider, client, params) err = s.StartLogin(button, provider, client, params)
if errors.Is(err, http.ErrServerClosed) { if errors.Is(err, http.ErrServerClosed) {
fmt.Printf("\n=========================================\nServer closed.\n=========================================\n\n") fmt.Printf("\n=========================================\nServer closed.\n=========================================\n\n")
} else if err != nil { } else if err != nil {
@ -110,6 +110,7 @@ func Login(config *Config, client *oauth.Client, provider *oidc.IdentityProvider
} }
func MakeButton(url string, text string) string { func MakeButton(url string, text string) string {
// check if we have http:// a
html := "<input type=\"button\" " html := "<input type=\"button\" "
html += "class=\"button\" " html += "class=\"button\" "
html += fmt.Sprintf("onclick=\"window.location.href='%s';\" ", url) html += fmt.Sprintf("onclick=\"window.location.href='%s';\" ", url)

View file

@ -90,6 +90,10 @@ func NewServerWithConfig(conf *Config) *server.Server {
}, },
Host: host, Host: host,
Port: port, Port: port,
Issuer: server.Issuer{
Host: conf.Server.Issuer.Host,
Port: conf.Server.Issuer.Port,
},
} }
return server return server
} }

View file

@ -21,8 +21,7 @@ func (client *Client) BuildAuthorizationUrl(issuer string, state string) string
"&redirect_uri=" + url.QueryEscape(strings.Join(client.RedirectUris, ",")) + "&redirect_uri=" + url.QueryEscape(strings.Join(client.RedirectUris, ",")) +
"&response_type=code" + // this has to be set to "code" "&response_type=code" + // this has to be set to "code"
"&state=" + state + "&state=" + state +
"&scope=" + strings.Join(client.Scope, "+") + "&scope=" + strings.Join(client.Scope, "+")
"&resource=" + url.QueryEscape("http://127.0.0.1:4444/oauth2/token")
} }
func (client *Client) InitiateLoginFlow(loginUrl string) error { func (client *Client) InitiateLoginFlow(loginUrl string) error {