Skip to content
Snippets Groups Projects
Commit a65ad08e authored by ale's avatar ale
Browse files

Add a slash on the login redirect URL only when necessary

parent 210f1644
No related branches found
No related tags found
1 merge request!3Nonce
...@@ -490,6 +490,14 @@ static int mod_sso_method_handler(request_rec *r) { ...@@ -490,6 +490,14 @@ static int mod_sso_method_handler(request_rec *r) {
return DECLINED; 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, static int redirect_to_login_server(request_rec *r, modsso_config *s_cfg,
const char *service_host, const char *service_host,
const char *service, const char **groups, const char *service, const char **groups,
...@@ -499,7 +507,8 @@ static int redirect_to_login_server(request_rec *r, modsso_config *s_cfg, ...@@ -499,7 +507,8 @@ static int redirect_to_login_server(request_rec *r, modsso_config *s_cfg,
dest = full_uri(r, service_host); dest = full_uri(r, service_host);
login_url = apr_pstrcat(r->pool, "https://", s_cfg->login_server, 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); "&d=", modsso_url_encode(r->pool, dest), NULL);
if (s_cfg->session_key != NULL) { if (s_cfg->session_key != NULL) {
// If we have a session key, send a nonce to the login server. We // If we have a session key, send a nonce to the login server. We
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment