119 lines
4.3 KiB
Plaintext
119 lines
4.3 KiB
Plaintext
<%@ language = "JavaScript" %>
|
|
<% /*
|
|
$Revision$
|
|
$Id$
|
|
|
|
File: aut/saml/default.asp
|
|
Description: Single Sign On script
|
|
Parameters:
|
|
Context:
|
|
Note: In c:\opt\shibboleth-sp\etc\shibboleth\shibboleth2.xml staat
|
|
<RequestMapper type="Native">
|
|
<RequestMap applicationId="default">
|
|
<Host name="xxxx.facilitor.nl">
|
|
<Path name="trunk/appl/aut/saml" authType="shibboleth" requireSession="true"/>
|
|
</Host>
|
|
</RequestMap>
|
|
</RequestMapper>
|
|
ofwel trunk/appl/saml heeft een 'requireSession' en Shibboleth
|
|
grijpt automatisch in als je een bestand (deze default.asp) in
|
|
deze folder oproept. Je wordt geauthenticeerd tegen je identity
|
|
provider (via wat redirects) en komt uiteindelijk terug in dit
|
|
bestand met allerlei server variabelen gezet
|
|
|
|
*/ %>
|
|
<%
|
|
ANONYMOUS_Allowed = 1;
|
|
LOGIN_try = 1; // we zitten al in een login-try dus geen os_logon meer of zo
|
|
%>
|
|
<!-- #include file="../../../appl/Shared/common.inc" -->
|
|
<!-- #include file="../login.inc" -->
|
|
<!-- #include file="../../../appl/api2/api2.inc" -->
|
|
<!-- #include file="../../../appl/api2/model_aut_idp.inc" -->
|
|
<%
|
|
DEBUGMODE=0;
|
|
|
|
if (!DEBUGMODE)
|
|
{
|
|
if (Request.ServerVariables("HTTP_SHIBIDENTITYPROVIDER").Count == 0)
|
|
shared.internal_error("Shibboleth not installed?");
|
|
}
|
|
else
|
|
__Logging = 1;
|
|
|
|
//Response.Write(__DumpCollection(Request.ServerVariables));
|
|
//Response.End;
|
|
|
|
// Als je dit punt bereikt ben je al geauthenticeerd door SAML
|
|
var issuer = String(Request.ServerVariables("HTTP_SHIBIDENTITYPROVIDER"));
|
|
if (DEBUGMODE)
|
|
{
|
|
issuer = "https://sts.aareon.com/adfs/services/trust";
|
|
}
|
|
|
|
__Log("Detected SAML identity provider (entityId): " + issuer);
|
|
var idp_data_arr = new model_aut_idp({ internal: true }).REST_GET({ filter: { type: 5 /* SAML */, issuer: issuer }, include: [ "idpmappings" ]});
|
|
if (!idp_data_arr.length)
|
|
shared.internal_error("Unknown SAML issuer {0}".format(issuer));
|
|
var idp_data = idp_data_arr[0];
|
|
if (idp_data.loglevel > 0)
|
|
{
|
|
__Logging = idp_data.loglevel;
|
|
__Log("Logging for this IdP ({0}) is forced on".format(idp_data.name), '#f00');
|
|
}
|
|
shared.registeraction("IDP_Login", { daily: 2, refkey: idp_data.id }); // Per dag tellen voor de statistieken
|
|
|
|
var svars = ["<pre>"]; // Voor logging
|
|
|
|
var wasCodePage = Session.Codepage;
|
|
Session.Codepage = 65001; // Van Shibboleth krijgen we UTF-8 namen
|
|
|
|
var claim = {}; // We bouwen een claim op uit alle servervariabelen die met HTTP_ beginnen
|
|
|
|
var ignoreHTTP = "HTTP_COOKIE,HTTP_REFERER".split(","); // Ik wil ze vooral niet in de logfile krijgen
|
|
|
|
for (i=1; i <= Request.ServerVariables.Count; i++)
|
|
{
|
|
var name = Request.ServerVariables.key(i);
|
|
if ((name.match(/^HTTP_/) || name == "REMOTE_USER") && !inArray(name, ignoreHTTP))
|
|
{
|
|
claim[name] = String(Request.ServerVariables(i));
|
|
svars.push(Request.ServerVariables.key(i) + ": " + Request.ServerVariables(i));
|
|
}
|
|
}
|
|
Session.Codepage = wasCodePage; // Geen risico lopen
|
|
|
|
svars.push("</pre>");
|
|
__SafeLog(svars.join("\n"));
|
|
|
|
if (DEBUGMODE)
|
|
{
|
|
claim = {
|
|
"iat": 1609773360,
|
|
"jti": "#j.grootlipman3@facilitorxxxx.nl#1609773359696",
|
|
"aud": "logc.facilitor.nl",
|
|
"iss": "PROVTEST",
|
|
"HTTP_MAIL": "j.grootlipman3@facilitorxxxx.nl",
|
|
"voornaam": "Jos",
|
|
"afdeling": "Onbekend",
|
|
"ver": "1.0"
|
|
}
|
|
}
|
|
process_claim(claim, idp_data);
|
|
|
|
if (user_key > 0) // dan hebben we (nu) een nieuwe user
|
|
{
|
|
Response.AddHeader ("FCLT_USERID", customerId + "\\" + String(user_key)); // Voor de logregel van *dit* bestand
|
|
|
|
// Onthouden hoe je bent binnengekomen zodat logout naar logout_url kan leiden
|
|
Session("idp_key") = idp_data.id;
|
|
var return_to = getQParam("return_to", "/") || "/";
|
|
Response.Redirect(rooturl + return_to);
|
|
}
|
|
else
|
|
{ // Automatisch naar het inlogscherm
|
|
Response.Redirect(rooturl + "/?sso=0");
|
|
}
|
|
|
|
ASPPAGE_END(); %>
|