forked from GiancarloGomez/ColdFusion-OneLogin
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Application.cfc
executable file
·52 lines (42 loc) · 1.73 KB
/
Application.cfc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
* @output false
*/
component{
this.name = "SAML_Sample_App";
this.sessionmanagement = true;
this.sessiontimeout = createTimeSpan(0,7,0,0);
this.triggerDataMember=true;
this.invokeImplicitAccessor=true;
// Mappings
this.mappings['/saml'] = getDirectoryFromPath(getCurrentTemplatePath()) & '/saml'
// java settings
this.javaSettings = {
LoadPaths : ["/saml/jars"],
reloadOnChange : true,
watchInterval : 60
};
public boolean function onRequestStart(){
request.identityProvider = "okta";
request.rootDir = "cfml-sso-demo-app/"
request.siteURL = "http" & (cgi.server_port_secure ? "s" : "") & ":" & "//" & cgi.server_name & ":" & cgi.server_port & "/" & request.rootDir;
if (structKeyExists(url,"reload")){
location("./",false);
}
// check if identityProvider is setup and configured
if (!isNull(request.identityProvider)){
try{
data = deserializeJson(fileRead('config/#request.identityProvider#.json'));
request.identityProviderModel = createObject('component', 'saml.providers.' & request.identityProvider).init(argumentCollection = data)
}catch (any e){
request.identityProviderModel = createObject('component', 'saml.providers.' & request.identityProvider).init()
}
if (isNull(request.identityProviderModel)){
request.identityProviderModel = createObject('component', 'saml.providers.' & request.identityProvider).init()
}
// relocate to admin if not completely setup
if (!findNoCase("admin",cgi.script_name) && !request.identityProviderModel.isReady())
location("/#request.rootDir#/admin.cfm",false);
}
return true;
}
}