diff --git a/src/mod_sso/mod_sso.c b/src/mod_sso/mod_sso.c index 1cd6b982e625872652be8cdcbd8fc91fa86252be..7fef0a61f8622673d13719aaf5d63b655fe7f9fa 100644 --- a/src/mod_sso/mod_sso.c +++ b/src/mod_sso/mod_sso.c @@ -490,6 +490,14 @@ static int mod_sso_method_handler(request_rec *r) { return DECLINED; } +static int ends_with_slash(const char *s) { + int l = strlen(s); + if (l < 1) { + return 0; + } + return s[l-1] == '/'; +} + static int redirect_to_login_server(request_rec *r, modsso_config *s_cfg, const char *service_host, const char *service, const char **groups, @@ -499,7 +507,8 @@ static int redirect_to_login_server(request_rec *r, modsso_config *s_cfg, dest = full_uri(r, service_host); login_url = apr_pstrcat(r->pool, "https://", s_cfg->login_server, - "/?s=", modsso_url_encode(r->pool, service), + ends_with_slash(s_cfg->login_server) ? "" : "/", + "?s=", modsso_url_encode(r->pool, service), "&d=", modsso_url_encode(r->pool, dest), NULL); if (s_cfg->session_key != NULL) { // If we have a session key, send a nonce to the login server. We