From c54a1f8d9aabc1f4f5fe2e0993640d85f76ec9fc Mon Sep 17 00:00:00 2001 From: Christian Galo Date: Sun, 18 May 2025 18:32:26 -0500 Subject: [PATCH] Rename hostname to base-url for accuracy --- cmd/start.go | 2 +- internal/auth/auth.go | 6 +++--- internal/embeds/mc-config.yaml | 2 +- test/mc-config.yaml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cmd/start.go b/cmd/start.go index 2fe90b7..cbf7c76 100644 --- a/cmd/start.go +++ b/cmd/start.go @@ -91,7 +91,7 @@ func init() { startCmd.Flags().StringP("port", "p", "", "Port to listen on") startCmd.Flags().String("oidc-sp-client-id", "", "OIDC Client ID") startCmd.Flags().String("oidc-idp-issuer-url", "", "Identity Provider Issuer URL") - startCmd.Flags().String("hostname", "", "Address at which the server is exposed") + startCmd.Flags().String("base-url", "", "Address at which the server is exposed") startCmd.Flags().String("env", "", "Environment (development/production)") startCmd.Flags().String("oidc-sp-client-secret", "", "OIDC Client Secret") diff --git a/internal/auth/auth.go b/internal/auth/auth.go index 76bfed6..fe5d5e1 100644 --- a/internal/auth/auth.go +++ b/internal/auth/auth.go @@ -49,7 +49,7 @@ func Setup() (*Config, error) { oauthConfig := &oauth2.Config{ ClientID: viper.GetString("oidc-sp-client-id"), ClientSecret: viper.GetString("oidc-sp-client-secret"), - RedirectURL: viper.GetString("hostname") + "/callback", + RedirectURL: viper.GetString("base-url") + "/callback", Endpoint: provider.Endpoint(), Scopes: []string{oidc.ScopeOpenID, "profile", "email"}, } @@ -250,7 +250,7 @@ func (c *Config) LogoutHandler(w http.ResponseWriter, r *http.Request) { // Add query parameters q := keycloakLogoutURL.Query() // Use logout-callback for completing the logout flow - q.Set("post_logout_redirect_uri", viper.GetString("hostname")+"/logout-callback") + q.Set("post_logout_redirect_uri", viper.GetString("base-url")+"/logout-callback") q.Set("client_id", viper.GetString("oidc-sp-client-id")) q.Set("state", state) @@ -342,7 +342,7 @@ func (c *Config) RegistrationHandler(w http.ResponseWriter, r *http.Request) { q.Set("client_id", viper.GetString("oidc-sp-client-id")) q.Set("response_type", "code") q.Set("scope", "openid email profile") - q.Set("redirect_uri", viper.GetString("hostname")+"/callback") + q.Set("redirect_uri", viper.GetString("base-url")+"/callback") q.Set("state", state) q.Set("nonce", nonce) q.Set("code_challenge", codeChallenge) diff --git a/internal/embeds/mc-config.yaml b/internal/embeds/mc-config.yaml index 3921eb8..6737a14 100644 --- a/internal/embeds/mc-config.yaml +++ b/internal/embeds/mc-config.yaml @@ -9,6 +9,6 @@ port: 8081 oidc-sp-client-id: "member-console" oidc-sp-client-secret: "" oidc-idp-issuer-url: "http://localhost:8080/realms/master" -hostname: "http://localhost:8081" +base-url: "http://localhost:8081" session-secret: "" csrf-secret: "" \ No newline at end of file diff --git a/test/mc-config.yaml b/test/mc-config.yaml index 1271051..075395c 100644 --- a/test/mc-config.yaml +++ b/test/mc-config.yaml @@ -9,6 +9,6 @@ port: 8081 oidc-sp-client-id: "member-console" oidc-sp-client-secret: "CigQbREzhFCekZ8yvV3CaCFrHOgANgaH" oidc-idp-issuer-url: "http://localhost:8080/realms/master" -hostname: "http://localhost:8081" +base-url: "http://localhost:8081" session-secret: "rJcniy2aWl3vwBcrMJfqsTL+Wys7EwDx/RC+DRrKcYg=" csrf-secret: "e157b42a5b608882179cb4ac69c12f84" \ No newline at end of file