-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmindthegap.html
255 lines (230 loc) · 9.99 KB
/
mindthegap.html
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<style>
:root
{
--white: #ffffff;
--text-grey: #444444;
--warm-grey: #767676;
--warm-grey-two: #bfbfbf;
--white-two: #f6f6f6;
--footer-grey: #ebebeb;
--brand-color: #006b93;
--white-50: rgba(255, 255, 255, 0.5);
--white-three: #e6e6e6;
}
body { font-family: sans-serif; }
.ra21-button
{
background-color: var(--brand-color);
border-radius: 5px;
color: var(--warm-grey);
cursor: pointer;
display: flex;
margin-bottom: 5px;
padding: 10px;
text-decoration: none;
}
.ra21-button-logo-wrap
{
text-align: center;
width: 50px;
height: 100%;
border-right: 1px solid #FFFFFF;
padding: 5px 5px 5px 0;
}
.ra21-button-logo
{
width: 30px;
vertical-align: middle;
}
.ra21-button-text
{
padding-left: 10px;
text-align: center;
width: 85%;
color: var(--white);
}
.ra21-button-text-primary
{
font-size: 13px;
font-weight: 700;
font-style: normal;
font-stretch: normal;
line-height: 1.4;
letter-spacing: normal;
}
.ra21-button-text-secondary
{
/* Zep */
font-size: 13px;
font-weight: normal;
font-style: normal;
font-stretch: normal;
line-height: 1.4;
letter-spacing: normal;
}
.ra21-access-text
{
cursor: pointer;
text-align: center;
/* Zep */
font-size: 13px;
font-weight: normal;
font-style: normal;
font-stretch: normal;
line-height: 1.46;
letter-spacing: normal;
color: var(--brand-color);
}
.ra21-cta-plus, .ra21-cta-access { display: inline; }
.light-grey { color: var(--warm-grey-two); }
.svg-inline--fa
{
display: inline-block;
font-size: inherit;
height: 1em;
overflow: visible;
vertical-align: -0.125em;
}
a { text-decoration: none; }
.align-items-center
{
display: flex;
align-items: center !important;
justify-content: center;
}
.text-truncate
{
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
</style>
</head>
<body id="main" style="background-color: transparent; background-position: initial initial; background-repeat: initial initial;">
<div id=form></div>
<script>
document.cookie = 'saml_ssp_path=; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/'
document.cookie = 'saml_auth_class=; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/'
const sso = "https://wayf.wayf.dk/saml2/idp/SSOService2.php"
const ds = sp => `https://wayf.wayf.dk/ds/?return=${encodeURIComponent(window.location)}&returnIDParam=entityID&entityID=${encodeURIComponent(sp)}`
const mdq = (ent, type) => `https://wayf.wayf.dk/MDQ/${encodeURIComponent(ent)}/${type}/${encodeURIComponent(ent)}`
const localStorageKey = 'RA21IDP'
const u = new URLSearchParams(window.location.search)
const sp = u.get('sp')
const acs = "0" // u.get('acs') ?? "0"
let entityID = u.get('entityID')
if (entityID) { // back from ds - save selected idp
localStorage[localStorageKey] = JSON.stringify({idp: entityID}) // we can't set the displaynames here - don't want to wait for mdq response
sendSAMLRequest(acs, sso, sp, entityID)
}
function sendSAMLRequest(acs, sso, sp, entityID) {
// Use saml2jwt on return
document.cookie = 'saml_ssp_path=/usr/local/www/saml2jwt/_autoload.php; path=/'
document.cookie = 'saml_auth_class=saml2jwt; path=/'
const IssueInstant = new Date().toISOString().slice(0,-5)+"Z"
let array = new Uint8Array(21)
window.crypto.getRandomValues(array)
const ID = "_"+btoa(String.fromCharCode(...array)).replace(/\+/g, '-').replace(/\//g, '_')
const theACS = /^\d+$/.test(acs) ? `AssertionConsumerServiceIndex="${acs}"`: `AssertionConsumerServiceURL="${acs}">`
const SAMLRequest = `
<samlp:AuthnRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" Version="2.0" ProtocolBinding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
ID="${ID}"
IssueInstant="${IssueInstant}"
Destination="${sso}"
${theACS}>
<saml:Issuer>${sp}</saml:Issuer>
<samlp:NameIDPolicy Format="urn:oasis:names:tc:SAML:2.0:nameid-format:transient" AllowCreate="true" />
</samlp:AuthnRequest>
`
document.getElementById('form').innerHTML =`
<form id=request method=post action="${sso}?idpentityid=${entityID}" target=_top>
<input type=hidden id=samlrequest type=text name=SAMLRequest value="${btoa(SAMLRequest)}">
</form>`
document.getElementById("request").submit();
return true
}
let intl = {
accessthru: { en: '***BETA*** Access through', da: '***BETA*** Log in via'},
inst: { en: '***BETA*** Access through your institution', da: '***BETA*** Login via din institution'},
anotherinst: { en: 'Access through another institution', da: 'Login via en anden institution' },
}
</script>
<a id=idpanchor target=_top onClick="return sendSAMLRequest(acs, sso, sp, entityID);">
<div class="ra21CTAcontainer ra21-button" role="button" data-href="" id="idpbutton">
<div class="identityprovider ra21CTAiconButton ra21CTAbutton ra21-button-logo-wrap">
<img class="ra21CTAicon ra21-button-logo" src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdH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DQuOTksMTI4LjY0IDE0NC45OSwxODYuMjEgCSIvPgoJPHBhdGggY2xhc3M9InN0MCIgZD0iTTI0Mi4wNywyMjYuNDJjLTAuMDEsMC0wLjAzLDAtMC4wNCwwaC0xMC43NXYtMTAuNzRjMC0zLjcxLTMuMDEtNi43Mi02LjcyLTYuNzJsLTEwLjEsMHYtODYuMjEKCQljMC04LjItNi43MS0xNC45LTE0LjktMTQuOWMtOC4yLDAtMTQuOSw2LjcxLTE0LjksMTQuOXY4Ni4yMWwtMTE1LjQyLTAuMDJ2LTg2LjE5YzAtOC4yLTYuNzEtMTQuOS0xNC45LTE0LjkKCQljLTguMiwwLTE0LjksNi43MS0xNC45LDE0Ljl2ODYuMThsLTEwLjA4LDBjLTMuNzEsMC02LjcyLDMuMDEtNi43Miw2LjcydjEwLjc0SDExLjg2Yy0zLjcxLDAtNi43MiwzLjAxLTYuNzIsNi43MnYxMS42OGgyNDMuNjIKCQl2LTExLjYzQzI0OC43NywyMjkuNDUsMjQ1Ljc4LDIyNi40MywyNDIuMDcsMjI2LjQyeiIvPgo8L2c+Cjwvc3ZnPgo=">
</div>
<div class="identityprovider d-flex justify-content-center align-items-center ra21CTAbutton text-truncate ra21-button-text">
<div class="ra21CTAbuttonLabel text-truncate">
<div class="ra21-button-text-secondary" id="headline">
</div>
<div class="ra21CTAtitle ra21-button-text-primary text-truncate" id="title">
</div>
</div>
</div>
</div>
</a>
<a id=dsanchor target=_top>
<div class="ra21CTAChooseAnother ra21-access-text" id="dsbutton">
<div class="ra21CTAPlus ra21-cta-plus">
<svg aria-hidden="true" focusable="false" data-prefix="fa" data-icon="plus-square" class="svg-inline--fa fa-plus-square fa-w-14 light-grey" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" data-fa-i2svg="">
<path fill="currentColor" d="M400 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48zm-32 252c0 6.6-5.4 12-12 12h-92v92c0 6.6-5.4 12-12 12h-56c-6.6 0-12-5.4-12-12v-92H92c-6.6 0-12-5.4-12-12v-56c0-6.6 5.4-12 12-12h92v-92c0-6.6 5.4-12 12-12h56c6.6 0 12 5.4 12 12v92h92c6.6 0 12 5.4 12 12v56z">
</path>
</svg>
</div>
<div id=ds class="ra21CTAccess ra21-cta-access">
</div>
</div>
</a>
</body>
<script>
document.documentElement.style.setProperty('--brand-color', u.get('color') || '#006b93');
function getIdPDisplayName(idp) {
window.fetch(mdq(idp, 'idp'))
.then(response => response.text())
.then(xml => {
let xmlDoc = new DOMParser().parseFromString(xml, "application/xml")
idpRec = {idp: idpRec.idp, en: "placeholder" }
let displayNames = xmlDoc.evaluate('//mdui:DisplayName', xmlDoc, x => "urn:oasis:names:tc:SAML:metadata:ui")
while (displayName = displayNames.iterateNext()) {
idpRec[displayName.attributes.getNamedItem('xml:lang').textContent] = displayName.textContent
}
setIdPDisplayName(idpRec)
localStorage[localStorageKey] = JSON.stringify(idpRec)
})
}
function setIdPDisplayName(idpRec) {
if (idpRec.en) {
setI18n('#title', idpRec)
return
}
getIdPDisplayName(idpRec.idp)
}
function setI18n(path, rec) {
document.querySelector(path).innerHTML = rec[u.get('lang')] || rec[navigator.language.substr(0, 2)] || rec['en']
}
if (!entityID) {
setI18n('#title', intl.inst)
//sp = "https://cern.ch/login"
var idpRec = {idp: ""}
if (idpJSON = localStorage[localStorageKey]) {
idpRec = JSON.parse(idpJSON)
}
if (idpRec.idp) {
setIdPDisplayName(idpRec)
setI18n('#ds', intl.anotherinst)
setI18n('#headline', intl.accessthru)
document.querySelector('#dsanchor').href = ds(sp)
entityID = idpRec.idp
} else {
document.querySelector('#dsanchor').style.display = 'none'
document.querySelector('#idpanchor').href = ds(sp)
}
}
</script>
</html>