Skip to content

added Ace editor and use that for editing claims JSON #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 94 additions & 1 deletion legal/legal.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,97 @@ licenses of third-party software libraries used by the Software.

## Components

N/A
### Ace (Ajax.org Cloud9 Editor)

* License: BSD 3-clause
* Modifications: No
* Link: https://ace.c9.io/
* Notices:

<pre>
Copyright (c) 2010, Ajax.org B.V.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Ajax.org B.V. nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</pre>

### Bootstrap

* License: MIT
* Modifications: No
* Link: http://getbootstrap.com/
* Notices:

<pre>
Copyright 2011-2014 Twitter, Inc.

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
</pre>

### jQuery

* License: MIT
* Modifications: No
* Link: https://jquery.org/
* Notices:

<pre>
Copyright 2014 jQuery Foundation and other contributors
http://jquery.com/

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
</pre>
18 changes: 18 additions & 0 deletions static/ace.js

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions static/ext-error_marker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
;
(function() {
window.require(["ace/ext/error_marker"], function(m) {
if (typeof module == "object" && typeof exports == "object" && module) {
module.exports = m;
}
});
})();

9 changes: 9 additions & 0 deletions static/mode-json.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions static/theme-dreamweaver.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions static/worker-json.js

Large diffs are not rendered by default.

67 changes: 64 additions & 3 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<link rel="stylesheet" href="static/bootstrap.min.css">
<link rel="stylesheet" href="static/bootstrap-theme.min.css">
<script src="static/jquery-3.1.1.min.js"></script>
<script src="static/ace.js" type="text/javascript" charset="utf-8"></script>

<style type="text/css">
.navbar img {
Expand Down Expand Up @@ -49,6 +50,11 @@
padding-left: 0;
padding-bottom: 0.5em;
}

#claims_editor {
position: relative;
height: 250px;
}
</style>

<script type="application/javascript">
Expand Down Expand Up @@ -289,15 +295,70 @@ <h2 class="welcome">Welcome <span id="sessionname"></span>!</h2>
</div>
<div class="form-group">
<label for="claims">Claims</label>
<textarea name="claims" id="claims" rows="5" class="json form-control">
{
<input name="claims" type="hidden">
<div id="claims_editor">{
"id_token": {

},
"userinfo": {
}
}</div>
<div class="btn-group btn-group-sm" role="group" aria-label="...">
<button type="button" class="btn btn-default" id="zoneinfoClaim">Zoneinfo</button>
<button type="button" class="btn btn-default" id="addressClaim">Address</button>
<button type="button" class="btn btn-default" id="phoneTimezoneClaims">Phone &amp; Timezone</button>
<button type="button" class="btn btn-default" id="resetClaims">Reset</button>
</div>

<script>
var claimsFormInput = $('input[name="claims"]').hide();
var editor = ace.edit("claims_editor");
var originalValue = editor.getValue();

$("#zoneinfoClaim").click({
"id_token": {
"zoneinfo": {"essential": true}
}
}, setClaims);

$("#addressClaim").click({
"id_token": {
"address": {
"formatted": {"essential": true}
}
}
}, setClaims);

$("#phoneTimezoneClaims").click({
"id_token": {
"zoneinfo": {"essential": true}
},
"userinfo": {
"phone_number": {"essential": null}
}
}, setClaims);

$("#resetClaims").click(originalValue, setClaims);

editor.on('change', function(){
claimsFormInput.val(editor.getValue());
});

editor.setTheme("ace/theme/dreamweaver");
editor.session.setMode("ace/mode/json");
function setClaims(event) {
var data = event.data;
var stringValue = typeof data === "string" ? data : JSON.stringify(data, null, " ");

editor.setValue(stringValue);
editor.clearSelection();

var forceConsent = originalValue !== data;
var scopeValue = forceConsent ? "openid" : "";
$("#scope").val(scopeValue);
$("input[name='forceConsent']").prop('checked', forceConsent);
}
</textarea>
</script>
</div>

<div style="margin-bottom: 1em">
Expand Down