123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317 |
- <!DOCTYPE html>
- <html>
- <head>
- <title>Access Control</title>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0 user-scalable=no">
- <link rel="stylesheet" href="../../script/semantic/semantic.min.css">
- <script type="text/javascript" src="../../script/jquery.min.js"></script>
- <script type="text/javascript" src="../../script/semantic/semantic.min.js"></script>
- <style>
- a.pageFocus {
- background: #222222;
- color: white !important;
- border-radius: 50%;
- -moz-border-radius: 50%;
- -webkit-border-radius: 50%;
- display: inline-block;
- font-weight: bold;
- line-height: 30px;
- margin-right: 2px;
- text-align: center;
- width: 30px;
- }
- .noselect {
- -webkit-touch-callout: none; /* iOS Safari */
- -webkit-user-select: none; /* Safari */
- -khtml-user-select: none; /* Konqueror HTML */
- -moz-user-select: none; /* Old versions of Firefox */
- -ms-user-select: none; /* Internet Explorer/Edge */
- user-select: none; /* Non-prefixed version, currently
- supported by Chrome, Edge, Opera and Firefox */
- }
- </style>
- </head>
- <body>
- <br>
- <div class="ui container" style="height: 100% !important;">
- <div>
- <h3 class="ui header">
- Access Control
- <div class="sub header">Manage IPs from logging into this host</div>
- </h3>
- <div class="ui divider"></div>
- <h3><i class="ui green checkmark icon"></i> Whitelist</h3>
- <div class="ui toggle checkbox">
- <input type="checkbox" id="enableWhiteList" onchange="">
- <label>Enable Whitelist Filtering</label>
- </div>
- <div class="ui inverted green segment" id="whitelistUpdateFeedback" style="display:none;">
- <i class="ui checkmark icon"></i> Whitelist Status Updated
- </div>
- <div class="ui basic segment">
- <p>Add or Remove new whitelisted IP range</p>
- <div class="ui action fluid input">
- <input type="text" id="whitelistIpRange" placeholder="192.168.1.100 - 192.168.1.250">
- <button class="ui green button" onclick="whitelistIpRange();"><i class="ui checkmark icon"></i> Add</button>
- </div>
- <table class="ui celled table">
- <thead>
- <tr><th>IP Range</th>
- <th>Remove</th>
- </tr></thead>
- <tbody id="whitelistTable">
- </tbody>
- </table>
- </div>
- <div class="ui divider"></div>
- <h3><i class="ui red remove icon"></i> Blacklist</h3>
- <div class="ui toggle checkbox">
- <input type="checkbox" id="enableBlacklist" onchange="updateBlacklistEnableState(this.checked);">
- <label>Enable Blacklist Filtering</label>
- </div>
- <div class="ui inverted green segment" id="blacklistUpdateFeedback" style="display:none;">
- <i class="ui checkmark icon"></i> Blacklist Status Updated
- </div>
- <div class="ui basic segment">
- <p>Add or Remove new banned IP range</p>
- <div class="ui action fluid input">
- <input type="text" id="blacklistIpRange" placeholder="192.168.1.100 - 192.168.1.250">
- <button class="ui red button" onclick="blacklistIpRange();"><i class="ui lock icon"></i> Ban</button>
- </div>
- <table class="ui celled table">
- <thead>
- <tr><th>IP Range</th>
- <th>Unban</th>
- </tr></thead>
- <tbody id="blacklisttable">
- </tbody>
- </table>
- </div>
-
-
- <!--
- <div class="ui divider"></div>
- <h3>Regional Block</h3>
- -->
- <div class="ui divider"></div>
- <div class="ui grey message">
- <p><i class="ui info circle icon"></i> For Whitelist and Blacklist, you can enter either a single IP or an IP range. IP range syntax examples as follows.</p>
- <div class="ui bulleted list">
- <div class="item">192.168.1.100</div>
- <div class="item">123.36.53.100</div>
- <div class="item">192.168.0.100 - 192.168.0.250</div>
- </div>
- </div>
- <br><br>
- </div>
-
- <script>
- //Init
- var preloading = true;
- $(".checkbox").checkbox();
- initBlacklist();
- initWhiteList();
- /*
- Whitelist Related
- */
- function initWhiteList(){
- //Get the whitelist enable state
- $.get("../../system/auth/whitelist/enable", function(data){
- if (data == true){
- //Whitelist is enabled
- $("#enableWhiteList").parent().checkbox("set checked");
- }else{
- $("#enableWhiteList").parent().checkbox("set unchecked");
- }
- $("#enableWhiteList").on("change", function(){
- //Toggle enable
- $.ajax({
- url: "../../system/auth/whitelist/enable",
- method: "POST",
- data: {enable: this.checked},
- success: function(data){
- $("#whitelistUpdateFeedback").stop().finish().slideDown("fast").delay(3000).slideUp("fast");
- }
- })
- })
-
- });
- //Get the whitelist table
- $("#whitelistTable").html(`<tr>
- <td colspan="3"><i class="loading spinner icon"></i> Loading</td>
- </tr>`);
- $.get("../../system/auth/whitelist/list", function(data){
- $("#whitelistTable").html('');
- data.forEach(entry => {
- //Strip out all space from record
- displayEntry = entry.split(" ").join("");
- //Check if this is reserved ip range
- var enableRemove = true;
- if (entry == "127.0.0.1"){
- enableRemove = false;
- }
- var removeButtonClass = ""
- if (!enableRemove){
- removeButtonClass = "disabled";
- }
- $("#whitelistTable").append(`<tr>
- <td>${displayEntry}</td>
- <td><button class="ui basic red ${removeButtonClass} icon button" onclick="removeWhitelistforIpRange(this);" range="${entry}"><i class="ui white remove icon"></i></button></td>
- </tr>`);
- })
- if (data.length == 0){
- $("#whitelistTable").html(`<tr>
- <td colspan="3"><i class="remove icon"></i> No Whitelisted IPs</td>
- </tr>`);
- }
- });
- }
- function whitelistIpRange(){
- var targetIP = $("#whitelistIpRange").val();
- $.ajax({
- url: "../../system/auth/whitelist/set",
- method: "POST",
- data: {iprange: targetIP},
- success: function(data){
- if (data.error != undefined){
- alert(data.error);
- }else{
- $("#whitelistIpRange").val('')
- initWhiteList();
- }
-
- }
- });
- }
- function removeWhitelistforIpRange(object){
- var unbanIpRange = $(object).attr("range");
- $.ajax({
- url: "../../system/auth/whitelist/unset",
- method: "POST",
- data: {iprange: unbanIpRange},
- success: function(data){
- if (data.error != undefined){
- alert(data.error);
- }else{
- $("#whitelistIpRange").val('')
- initWhiteList();
- }
-
- }
- });
- }
- /*
- Blacklist Related
- */
- function initBlacklist(){
- //Get the Blacklist enable state
- $.get("../../system/auth/blacklist/enable", function(data){
- if (data == true){
- //Blacklist is enabled
- $("#enableBlacklist").parent().checkbox("set checked");
- }else{
- $("#enableBlacklist").parent().checkbox("set unchecked");
- }
- preloading = false;
- });
- //Get the Blacklist table
- $("#blacklisttable").html(`<tr>
- <td colspan="3"><i class="loading spinner icon"></i> Loading</td>
- </tr>`);
- $.get("../../system/auth/blacklist/list", function(data){
- $("#blacklisttable").html('');
- data.forEach(entry => {
- //Strip out all space from record
- displayEntry = entry.split(" ").join("");
- $("#blacklisttable").append(`<tr>
- <td>${displayEntry}</td>
- <td><button class="ui green icon button" onclick="removeBlacklistforIpRange(this);" range="${entry}"><i class="ui white lock open icon"></i></button></td>
- </tr>`);
- })
- if (data.length == 0){
- $("#blacklisttable").html(`<tr>
- <td colspan="3"><i class="remove icon"></i> No Banned IPs</td>
- </tr>`);
- }
- })
- }
- function updateBlacklistEnableState(enabled){
- if (preloading){
- //Do not update status during preload stage
- return;
- }
- $.ajax({
- url: "../../system/auth/blacklist/enable",
- method: "POST",
- data: {enable: enabled},
- success: function(data){
- $("#blacklistUpdateFeedback").stop().finish().slideDown("fast").delay(3000).slideUp("fast");
- }
- })
- }
- function blacklistIpRange(){
- var targetIP = $("#blacklistIpRange").val();
- $.ajax({
- url: "../../system/auth/blacklist/ban",
- method: "POST",
- data: {iprange: targetIP},
- success: function(data){
- if (data.error != undefined){
- alert(data.error);
- }else{
- $("#blacklistIpRange").val('')
- initBlacklist();
- }
-
- }
- });
- }
- function removeBlacklistforIpRange(object){
- var unbanIpRange = $(object).attr("range");
- $.ajax({
- url: "../../system/auth/blacklist/unban",
- method: "POST",
- data: {iprange: unbanIpRange},
- success: function(data){
- if (data.error != undefined){
- alert(data.error);
- }else{
- $("#blacklistIpRange").val('')
- initBlacklist();
- }
-
- }
- });
- }
- </script>
- </body>
- </html>
|