Skip to content
Snippets Groups Projects
Commit 4b5cbed5 authored by Henrik (Grubba) Grubbström's avatar Henrik (Grubba) Grubbström
Browse files

ZXID: authenticate() now returns a parsed result in some cases.

parent e75f43a6
Branches
Tags
No related merge requests found
...@@ -62,10 +62,42 @@ class Configuration ...@@ -62,10 +62,42 @@ class Configuration
} }
} }
string(0..255) authenticate(string(0..255)|mapping(string(0..255):string(0..255)) query) mixed authenticate(string(0..255)|mapping(string(0..255):string(0..255)) query)
{ {
if (mappingp(query)) query = mapping_to_query(query); if (mappingp(query)) query = mapping_to_query(query);
return ::authenticate(query); string raw_res = ::authenticate(query);
switch(sizeof(raw_res) && raw_res[0]) {
case '*': // Error.
error("SAML authentication failure: %s\n", raw_res[1..]);
case '<': // HTML-content.
return ([ "data":raw_res, "type":"text/html" ]);
case 'L': // Location header.
if (has_prefix(raw_res, "Location:"));
raw_res =
String.trim_all_whites((raw_res/"\r\n")[0][sizeof("Location:")..]);
return ([ "error":Protocols.HTTP.HTTP_FOUND,
"rettext":"Redirect to " + raw_res,
"extra_heads":([ "Location":raw_res ]) ]);
case 'n': // NOOP.
break;
case 'b': // Send SP metadata.
// Should be handled by the C-layer already.
break;
case 'c': // Send SP CARML declaration.
// Should be handled by the C-layer already.
break;
case 'e': // Send IdP selection page.
break;
case 'a': // Send authentication page (usually on the IdP).
break;
case 'd': // Authentication completed. LDIF-entry.
break;
case 'z': // Authentication failure.
break;
default:
error("Unknown SAML response: %s\n", raw_res);
}
return raw_res;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment