forked from xrowgmbh/rest-bundle
/
page_head_script.html.twig
68 lines (61 loc) · 2.78 KB
/
page_head_script.html.twig
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<script type='text/javascript'>
var lsKeyName = 'xrowOpenIDConnect',
jwtProviderId = '{{oa_params.jwtProviderId}}',
checkSessionDuration = 10,
snDomains = new Array(),
snCounter = 0,
oauthSettings = {"client_id": "{{oa_params.clid}}",
"client_secret": "{{oa_params.clsc}}",
"baseURL": "{{oa_params.clba}}",
"endpointPrefix": "{{oa_params.endpoint_rest}}",
"tokenURL": "{{oa_params.endpoint_token}}/token",
"authURL": "{{oa_params.endpoint_rest}}/auth",
"openIDConnectURL": "{{oa_params.endpoint_rest}}/oicauth",
"apiSessionURL": "{{oa_params.endpoint_rest}}/session",
"apiLogoutURL": "{{oa_params.endpoint_rest}}/sessions",
"setcookieURL": "{{oa_params.endpoint_rest}}/set_session_cookie",
"checkSessionIframeURL": "{{oa_params.endpoint_rest}}/check_session_iframe"};
if (typeof pathToLoginTemplate === 'undefined') {
var pathToLoginTemplate = '/bundles/xrowrest/js/angular/openIDConnect/build/login.html';
}
{# Get seconds to check if user is logged in if defined #}
{% if oa_params.checkSessionDuration is defined %}
checkSessionDuration = {{oa_params.checkSessionDuration}};
{% endif %}
{# Get all allowed domains for sharing the session cookie #}
{% if oa_params.oicdomains is defined and oa_params.clba != app.request.schemeAndHttpHost %}
{% set oicdomains = oa_params.oicdomains|split(',') %}
{% for OpenIDConnectDomain in oicdomains %}
{% if app.request.schemeAndHttpHost != OpenIDConnectDomain|trim %}
snDomains[snCounter] = '{{OpenIDConnectDomain|trim}}';
snCounter++;
{% endif %}
{% endfor %}
{% endif %}
{% if oa_params.callback_function_if_token_is_set is defined %}
var callbackFunctionIfToken = '{{oa_params.callback_function_if_token_is_set}}';
{% endif %}
{% if oa_params.callback_function_if_restLogin_fail is defined %}
var callbackRestLoginFormErrorHandling = '{{oa_params.callback_function_if_restLogin_fail}}';
{% endif %}
</script>
{# ANGULAR 2 Start #}
{% if not is_granted('IS_AUTHENTICATED_FULLY') %}
<!-- 1. Load libraries -->
<script src="{{ asset('bundles/xrowrest/js/angular/openIDConnect/build/lib/es6-shim.min.js') }}"></script>
<script src="{{ asset('bundles/xrowrest/js/angular/openIDConnect/build/lib/system.src.js') }}"></script>
<script src="{{ asset('bundles/xrowrest/js/angular/openIDConnect/build/lib/vendors.js') }}"></script>
<script src="{{ asset('bundles/xrowrest/js/angular/openIDConnect/build/main.js') }}"></script>
<!-- 2. Configure SystemJS -->
<script>
System.config({
packages: {
app: {
defaultExtension: 'js',
format: 'register'
}
}
});
</script>
{% endif %}
{# ANGULAR 2 End #}