authenticate.tpl.php 4.69 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta name="viewport" content="initial-scale=1.0"/>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
    <script type="text/javascript" src="<?=SimpleSAML\Module::getModuleURL("customauth/assets/script.js")?>"></script>
    <title>Please select a profile to release attributes</title>
    <link rel="stylesheet" type="text/css" href="<?=SimpleSAML\Module::getModuleURL("customauth/assets/css/default.css")?>"/>
    <link rel="icon" type="image/icon" href="<?=SimpleSAML\Module::getModuleURL("customauth/assets/favicon.ico")?>"/>
    <meta name="robots" content="noindex, nofollow"/>
</head>
<body onload="SimpleSAML_focus('password');">
<div id="wrap">
  <div id="header">
    <br>
    <img src="https://idp.test.inacademia.org/module.php/inacademia_theme/login_icon.svg" alt="IKONA"/>
    <h1><a href="/">Enter your username and password</a></h1>
  </div>
  <div class="romb"></div>
  <div id="content">
    <p class="logintext">A service has requested you to authenticate yourself. <br>Please select a profile and optionally which attributes to release from the information below.</p>

    <form method="post" action="?">
Martin van Es's avatar
Martin van Es committed
24
   <p><hr/><b>Choose Test Scenario</b></p>
25
  <div style="float:left; margin-right: 10px">
Martin van Es's avatar
Martin van Es committed
26
  <select name=username size=10 style='width: 300px;'>
27
<?php
Martin van Es's avatar
WIP    
Martin van Es committed
28
29
30
31
32
33
34
35
36
37
38
    $first = true;
    $users = $this->data['users'];
    $displays = $this->data['displays'];
    $categories = $this->data['categories'];
    foreach ($categories as $category => $cat) {
      if (!$first) echo "<option></option>\n"; $first = false;
      echo "<option value=\"$category\">--- $category ---</option>\n";
      foreach ($cat['users'] as $user) {
	$display = $displays[$user];
        echo "<option name=\"$user\" value=\"$user\">$display</option>\n";
      }
39
40
    }
?>
Martin van Es's avatar
WIP    
Martin van Es committed
41
42
43
  <option></option>
  <option value="Error Scenarios">--- Error Scenarios ---</option>
  <option value="error">SAML Error</option>
44
45
  </select>
  </div>
Martin van Es's avatar
WIP    
Martin van Es committed
46
  <div id="explanation" style='display: grid'>Woohaa!</div><br style="clear: both" />
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
    <p><hr/><b>Choose attributes</b></p>
      <div style="float: left" id="attributes"></div>
      <div  id="about"></div><br style="clear: both" />
    <p><hr/><b>Released attributes</b></p>
      <div id="output"></div>
    <input type="hidden" name="ReturnTo" value="<?= htmlspecialchars($this->data['returnTo']) ?>">
    <p><input id="submit_button" class="btn" type="submit" value="Log in"></p>
    </form>
  </div>
</body>
  <script>
    var users = [];
    var keys = [];
    var message = [];
    var explanations = [];
    var user = '';
<?php
    foreach ($this->data['users'] as $user => $values) {
        echo "users['$user'] = [];\n";
        foreach ($values as $key => $value) {
            echo "users['$user']['$key'] = [\"" . (is_array($value)?implode("\",\"", $value):$value) . "\"]; ";
            echo "keys['$key'] = true;\n";
        }
    }
    foreach ($this->data['attributes'] as $attribute => $message) {
        echo "message['$attribute'] = \"$message\";\n";
    }
    foreach ($this->data['explanations'] as $user => $explanation) {
        echo "explanations['$user'] = \"$explanation\";\n";
    }

?>
Martin van Es's avatar
WIP    
Martin van Es committed
79
80
81
    explanations['Error Scenarios'] = "These are the Error Scenarios";
    explanations['error'] = "This generates a SAML Error";

82
83
84
85
    function update() {
        var html = "";
        for (let key in users[user]) {
            if (keys[key]) {
Martin van Es's avatar
Martin van Es committed
86
87
88
89
90
91
		var vals = users[user][key];
		//html += "<b>" + key + "</b>: " + users[user][key] + "<br />\n";
		html += "<b>" + key + "</b>: \n";
		for (let i in vals) {
                    html += "<li>" + vals[i] + "</li>\n";
		}
92
93
94
95
96
97
98
99
100
101
            }
        }
        $('#output').html(html);

    };
    $('select[name=username]').change(function() {
        var attributes = "";
        user = this.value;
        for (let key in users[user]) {
            attribute = users[user][key];
Martin van Es's avatar
WIP    
Martin van Es committed
102
            attributes += "<input id=chkbx_" + key + " type=checkbox name=keys[" + key + "] " + (keys[key]?'checked':'') + " value='" + users[user][key] + "'><span title='" + message[key] + "'>" + key + "</span><br>\n";
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
        };
	$('#explanation').html(explanations[user]);
        $('#attributes').html(attributes);
        $('#about').html('');
        $('input[id^=chkbx_]').change(function() {
            var key = this.name.slice(5,-1);
            keys[key] = this.checked;
            if (this.checked) $('#about').html(message[key] + '<br>Enabled');
            else $('#about').html(message[key] + '<br>Disabled');
        });
        update();
    });

    $('#attributes').change(function() {
        update();
    });

  </script>
</html>