Compare commits
No commits in common. "13b91d99166c9d0b32b1c52067272fa30f9acb5c" and "6eb9e7631609b6c99e0f3555783fb53c77ba363f" have entirely different histories.
13b91d9916
...
6eb9e76316
19 changed files with 61 additions and 283 deletions
|
@ -24,8 +24,6 @@ Then, build the server:
|
|||
./build.sh
|
||||
```
|
||||
|
||||
After that, configure the server using the `config.json` file (see below), and you're ready to go!
|
||||
|
||||
## Usage
|
||||
To run the server, simply run the binary:
|
||||
```sh
|
||||
|
@ -33,7 +31,7 @@ To run the server, simply run the binary:
|
|||
```
|
||||
|
||||
## Configuration
|
||||
The server can be configured using a `config.json` file. An example configuration file is provided in the repository as `config.json.example`. The configuration file is structured as follows:
|
||||
The server can be configured using a `config.json` file. An example configuration file is provided in the repository.
|
||||
### Global
|
||||
- `port` - The port the server listens on
|
||||
- `ip` - The IP address the server listens on
|
||||
|
|
|
@ -1,16 +1,4 @@
|
|||
@font-face {
|
||||
font-family: 'Figtree';
|
||||
src: url("fonts/Figtree.woff2") format("woff2");
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
html {
|
||||
background: linear-gradient(to top left, rgb(217, 236, 255), rgb(228, 249, 255), rgb(221, 255, 238), rgb(249,255,253)) no-repeat center center fixed;
|
||||
-webkit-background-size: cover;
|
||||
-moz-background-size: cover;
|
||||
-o-background-size: cover;
|
||||
background-size: cover;
|
||||
}
|
||||
@import url("../fonts/inter.css");
|
||||
|
||||
:root {
|
||||
--invertdm: 0%;
|
||||
|
@ -78,16 +66,17 @@ p#statusBox {
|
|||
body {
|
||||
margin: 0;
|
||||
background-color: var(--editor);
|
||||
font-family: "Figtree", sans-serif;
|
||||
font-family: "Inter", sans-serif;
|
||||
}
|
||||
|
||||
/* Sign up/log in div */
|
||||
|
||||
.inOutDiv {
|
||||
border-radius: 25px;
|
||||
border-radius: 8px;
|
||||
margin: 10%;
|
||||
padding: 30px;
|
||||
border: solid 1px var(--border-color);
|
||||
background-color: var(--inOutDiv);
|
||||
padding: 35px 35px 50px;
|
||||
}
|
||||
|
||||
table {
|
||||
|
@ -98,14 +87,14 @@ input {
|
|||
width: calc(100% - 35px);
|
||||
margin-left: 10px;
|
||||
margin-right: 10px;
|
||||
height: 35px;
|
||||
height: 30px;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
|
||||
border: solid;
|
||||
border-color: var(--border-color);
|
||||
border-width: 1px;
|
||||
border-radius: 5px;
|
||||
border-radius: 8px;
|
||||
min-width: 20px;
|
||||
}
|
||||
|
||||
|
@ -168,6 +157,9 @@ input {
|
|||
.inOutDiv p {
|
||||
font-size: 14px;
|
||||
}
|
||||
.inOutDiv h2 {
|
||||
font-size: 21px;
|
||||
}
|
||||
.background {
|
||||
display: none;
|
||||
}
|
||||
|
@ -209,24 +201,27 @@ input {
|
|||
|
||||
.newOauth, .oauthList, .sessionEntry, .oauthEntry {
|
||||
text-align: center;
|
||||
width: calc(100% - 17.5vh);
|
||||
margin-top: 7vh;
|
||||
margin-left: 7vh;
|
||||
margin-right: 7vh;
|
||||
padding: 15px 10px 30px;
|
||||
border-style: solid;
|
||||
border-image: none;
|
||||
border-radius: 25px;
|
||||
border-radius: 8px;
|
||||
border-width: 1px;
|
||||
font-size: 17px;
|
||||
background-color: var(--inOutDiv);
|
||||
border-color: var(--border-color);
|
||||
}
|
||||
|
||||
.oauthEntry, .sessionEntry {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
padding: 20px;
|
||||
padding: 5px;
|
||||
margin-top: 0;
|
||||
margin-bottom: 20px;
|
||||
border: 3px dotted var(--border-color);
|
||||
}
|
||||
|
||||
.oauthEntry button, .sessionEntry button {
|
||||
|
@ -292,9 +287,8 @@ button:hover {
|
|||
|
||||
h2 {
|
||||
display: block;
|
||||
margin-top: 10px;
|
||||
font-weight: 600;
|
||||
font-size: 22px;
|
||||
margin-top: 20px;
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
.inOutDiv a {
|
||||
|
@ -302,6 +296,21 @@ h2 {
|
|||
text-align: center;
|
||||
}
|
||||
|
||||
.background {
|
||||
position: fixed;
|
||||
z-index: -2;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
-webkit-user-drag: none;
|
||||
user-select: none;
|
||||
-moz-user-select: none;
|
||||
-webkit-user-select: none;
|
||||
-ms-user-select: none;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.vAlign {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
@ -347,82 +356,3 @@ h2 {
|
|||
.w900 {
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
/* swipe animation */
|
||||
.swipe {
|
||||
pointer-events: none;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
background-color: #fff;
|
||||
animation: swipe 0.2s forwards;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.swipe-animate {
|
||||
display: initial;
|
||||
}
|
||||
|
||||
|
||||
/* swipe-out animation */
|
||||
.swipe-out {
|
||||
pointer-events: none;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.swipe-out-animate {
|
||||
animation: swipe-out 0.2s forwards;
|
||||
}
|
||||
|
||||
@keyframes swipe {
|
||||
0% {
|
||||
transform: translateX(-100%);
|
||||
}
|
||||
100% {
|
||||
transform: translateX(0);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes swipe-out {
|
||||
0% {
|
||||
transform: translateX(0);
|
||||
}
|
||||
100% {
|
||||
transform: translateX(100%);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes swipe-reduced {
|
||||
0% {
|
||||
opacity: 0;
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes swipe-out-reduced {
|
||||
0% {
|
||||
opacity: 1;
|
||||
}
|
||||
100% {
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.swipe {
|
||||
animation: swipe-reduced 0.5s forwards;
|
||||
}
|
||||
|
||||
.swipe-out {
|
||||
animation: swipe-out-reduced 0.5s forwards;
|
||||
}
|
||||
}
|
|
@ -12,8 +12,9 @@
|
|||
<body>
|
||||
<span id="passThrough" style="display: none;">{{ .name }}</span>
|
||||
<span id="autoAccept" style="display: none;">0</span>
|
||||
<img src="/static/img/background.png" class="background" alt="">
|
||||
<div class="inOutDiv">
|
||||
<h2>Authorise Application</h2>
|
||||
<h2 class="w300">Authorise Application</h2>
|
||||
<p id="statusBox">Loading...</p>
|
||||
<br>
|
||||
<div style="display: flex;justify-content: center;">
|
||||
|
@ -23,8 +24,6 @@
|
|||
<br>
|
||||
<a href="/dashboard">Return to Dashboard</a>
|
||||
</div>
|
||||
<div id="swipe" class="swipe"></div>
|
||||
<div id="swipe-out" class="swipe-out"></div>
|
||||
<script>
|
||||
loadWasm("/static/wasm/authorize.wasm")
|
||||
</script>
|
||||
|
|
|
@ -12,15 +12,14 @@
|
|||
<body>
|
||||
<span id="passThrough" style="display: none;">{{ .name }}</span>
|
||||
<span id="autoAccept" style="display: none;">1</span>
|
||||
<img src="/static/img/background.png" class="background" alt="">
|
||||
<div class="inOutDiv">
|
||||
<h2>Authorizing application</h2>
|
||||
<h2 class="w300">Authorizing application</h2>
|
||||
<p id="statusBox">Please wait...</p>
|
||||
</div>
|
||||
<script>
|
||||
<script>
|
||||
loadWasm("/static/wasm/authorize.wasm")
|
||||
</script>
|
||||
<div id="swipe" class="swipe"></div>
|
||||
<div id="swipe-out" class="swipe-out"></div>
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
<script src="/static/js/wasm_exec.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<img src="/static/img/background.png" class="background" alt="">
|
||||
<div class="inOutDiv">
|
||||
<h2>Relaying back information, please wait...</h2>
|
||||
<p id="statusBox">Processing information sent...</p>
|
||||
|
@ -17,7 +18,5 @@
|
|||
<script>
|
||||
loadWasm("/static/wasm/clientKeyShare.wasm")
|
||||
</script>
|
||||
<div id="swipe" class="swipe"></div>
|
||||
<div id="swipe-out" class="swipe-out"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
<script src="/static/js/wasm_exec.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<img src="/static/img/background.png" class="background" alt="">
|
||||
<div class="newOauth">
|
||||
<h2>Dashboard</h2>
|
||||
<p>Welcome to the {{ .identifier }} dashboard!</p>
|
||||
|
@ -49,7 +50,5 @@
|
|||
<script>
|
||||
loadWasm("/static/wasm/dashboard.wasm")
|
||||
</script>
|
||||
<div id="swipe" class="swipe"></div>
|
||||
<div id="swipe-out" class="swipe-out"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -13,8 +13,9 @@
|
|||
|
||||
<body>
|
||||
<span id="passThrough" style="display: none;">{{ .identifier }}</span>
|
||||
<img src="/static/img/background.png" class="background" alt="">
|
||||
<div class="inOutDiv">
|
||||
<h2>Login</h2>
|
||||
<h2 class="w300">Login</h2>
|
||||
<p id="statusBox"></p>
|
||||
<div class="inputContainer" id="inputContainer">
|
||||
<div class="vAlign"><span id="inputNameBox"></span></div>
|
||||
|
@ -32,6 +33,4 @@
|
|||
<script>
|
||||
loadWasm("/static/wasm/login.wasm")
|
||||
</script>
|
||||
<div id="swipe" class="swipe"></div>
|
||||
<div id="swipe-out" class="swipe-out"></div>
|
||||
</body>
|
||||
|
|
|
@ -9,4 +9,7 @@
|
|||
<link rel="icon" href="/static/svg/favicon.svg">
|
||||
<script src="/static/js/logout.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<p>Logging out...</p>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -14,7 +14,5 @@
|
|||
<body>
|
||||
<p>Please wait...</p>
|
||||
<p>If your browser does not refresh, please refresh the page manually.</p>
|
||||
<div id="swipe" class="swipe"></div>
|
||||
<div id="swipe-out" class="swipe-out"></div>
|
||||
</body>
|
||||
</html>
|
|
@ -11,8 +11,9 @@
|
|||
|
||||
<body>
|
||||
<p style="display: none;" id="passthrough">{{ .unique_token }}</p>
|
||||
<div class="inOutDiv"></div>
|
||||
<h2>Signup</h2>
|
||||
<img src="/static/img/background.png" class="background" alt="">
|
||||
<div class="inOutDiv">
|
||||
<h2 class="w300">Signup</h2>
|
||||
<p>Signup to {{ .identifier }}!</p>
|
||||
<p id="statusBox"></p>
|
||||
<table id="inputContainer">
|
||||
|
@ -47,7 +48,5 @@
|
|||
<script>
|
||||
loadWasm("/static/wasm/signup.wasm")
|
||||
</script>
|
||||
<div id="swipe" class="swipe"></div>
|
||||
<div id="swipe-out" class="swipe-out"></div>
|
||||
</body>
|
||||
</html>
|
|
@ -9,7 +9,8 @@
|
|||
<link rel="stylesheet" type="text/css" href="/static/css/style.css"/>
|
||||
<script src="/static/js/wasm_exec.js"></script>
|
||||
</head>
|
||||
<body style="display: none;">
|
||||
<body>
|
||||
<img src="/static/img/background.png" class="background" alt="">
|
||||
<div class="inOutDiv">
|
||||
<h2>{{ .identifier }} Tester</h2>
|
||||
<p id="statusBox">Click authorize to begin the test</p>
|
||||
|
@ -19,7 +20,5 @@
|
|||
<script>
|
||||
loadWasm("/static/wasm/testApp.wasm")
|
||||
</script>
|
||||
<div id="swipe" class="swipe"></div>
|
||||
<div id="swipe-out" class="swipe-out"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -9,11 +9,10 @@
|
|||
<link rel="stylesheet" type="text/css" href="/static/css/style.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<img src="/static/img/background.png" class="background" alt="">
|
||||
<div class="inOutDiv">
|
||||
<h2>{{ .identifier }} Tester</h2>
|
||||
<p>The tester has been disabled by the administrator.</p>
|
||||
</div>
|
||||
<div id="swipe" class="swipe"></div>
|
||||
<div id="swipe-out" class="swipe-out"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -8,10 +8,9 @@ import (
|
|||
"net/url"
|
||||
"strings"
|
||||
"syscall/js"
|
||||
"time"
|
||||
)
|
||||
|
||||
func authorize(deny bool, query url.Values, sleepTime time.Duration) {
|
||||
func authorize(deny bool, query url.Values) {
|
||||
// Get the token from local storage
|
||||
localStorage := js.Global().Get("localStorage")
|
||||
token := localStorage.Call("getItem", "DONOTSHARE-secretKey").String()
|
||||
|
@ -80,8 +79,6 @@ func authorize(deny bool, query url.Values, sleepTime time.Duration) {
|
|||
denyUri += "&state=" + query.Get("state")
|
||||
}
|
||||
|
||||
js.Global().Get("swipe").Get("classList").Call("add", "swipe-animate")
|
||||
time.Sleep(sleepTime)
|
||||
js.Global().Get("window").Get("location").Call("replace", denyUri)
|
||||
} else {
|
||||
// Redirect to the redirect_uri with the code
|
||||
|
@ -90,8 +87,6 @@ func authorize(deny bool, query url.Values, sleepTime time.Duration) {
|
|||
allowUri += "&state=" + query.Get("state")
|
||||
}
|
||||
|
||||
js.Global().Get("swipe").Get("classList").Call("add", "swipe-animate")
|
||||
time.Sleep(sleepTime)
|
||||
js.Global().Get("window").Get("location").Call("replace", allowUri)
|
||||
}
|
||||
} else if response.StatusCode == 401 {
|
||||
|
@ -104,22 +99,9 @@ func authorize(deny bool, query url.Values, sleepTime time.Duration) {
|
|||
}
|
||||
|
||||
func main() {
|
||||
// Transition in
|
||||
js.Global().Get("document").Get("body").Set("style", "display: initial")
|
||||
js.Global().Get("swipe-out").Get("classList").Call("add", "swipe-out-animate")
|
||||
|
||||
var sleepTime = 200 * time.Millisecond
|
||||
if js.Global().Get("window").Call("matchMedia", "(prefers-reduced-motion: reduce)").Get("matches").Bool() {
|
||||
sleepTime = 500 * time.Millisecond
|
||||
}
|
||||
|
||||
time.Sleep(sleepTime)
|
||||
|
||||
// Redirect to log-in if not signed in
|
||||
localStorage := js.Global().Get("localStorage")
|
||||
if localStorage.Call("getItem", "DONOTSHARE-secretKey").IsNull() {
|
||||
js.Global().Get("swipe").Get("classList").Call("add", "swipe-animate")
|
||||
time.Sleep(sleepTime)
|
||||
js.Global().Get("window").Get("location").Call("replace", "/login"+js.Global().Get("window").Get("location").Get("search").String())
|
||||
}
|
||||
|
||||
|
@ -169,8 +151,6 @@ func main() {
|
|||
}
|
||||
|
||||
// Redirect to log-out if not signed in
|
||||
js.Global().Get("swipe").Get("classList").Call("add", "swipe-animate")
|
||||
time.Sleep(sleepTime)
|
||||
js.Global().Get("window").Get("location").Call("replace", "/logout"+js.Global().Get("window").Get("location").Get("search").String())
|
||||
return
|
||||
} else if response.StatusCode == 500 {
|
||||
|
@ -207,18 +187,18 @@ func main() {
|
|||
// Add an event listener to the Deny button
|
||||
js.Global().Get("document").Call("getElementById", "denyButton").Call("addEventListener", "click", js.FuncOf(func(this js.Value, p []js.Value) interface{} {
|
||||
// We still partially authorize the user to prevent open redirects
|
||||
go authorize(true, query, sleepTime)
|
||||
go authorize(true, query)
|
||||
return nil
|
||||
}))
|
||||
|
||||
// Add an event listener to the Allow button
|
||||
js.Global().Get("document").Call("getElementById", "allowButton").Call("addEventListener", "click", js.FuncOf(func(this js.Value, p []js.Value) interface{} {
|
||||
go authorize(false, query, sleepTime)
|
||||
go authorize(false, query)
|
||||
return nil
|
||||
}))
|
||||
} else {
|
||||
// Auto-accept the request, as it's from an internal service
|
||||
go authorize(false, query, sleepTime)
|
||||
go authorize(false, query)
|
||||
}
|
||||
|
||||
// Wait for events
|
||||
|
|
|
@ -9,26 +9,12 @@ import (
|
|||
"net/url"
|
||||
"strings"
|
||||
"syscall/js"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Transition in
|
||||
js.Global().Get("document").Get("body").Set("style", "display: initial")
|
||||
js.Global().Get("swipe-out").Get("classList").Call("add", "swipe-out-animate")
|
||||
|
||||
var sleepTime = 200 * time.Millisecond
|
||||
if js.Global().Get("window").Call("matchMedia", "(prefers-reduced-motion: reduce)").Get("matches").Bool() {
|
||||
sleepTime = 500 * time.Millisecond
|
||||
}
|
||||
|
||||
time.Sleep(sleepTime)
|
||||
|
||||
// Redirect to log-in if not signed in
|
||||
localStorage := js.Global().Get("localStorage")
|
||||
if localStorage.Call("getItem", "DONOTSHARE-secretKey").IsNull() {
|
||||
js.Global().Get("swipe").Get("classList").Call("add", "swipe-animate")
|
||||
time.Sleep(sleepTime)
|
||||
js.Global().Get("window").Get("location").Call("replace", "/login"+js.Global().Get("window").Get("location").Get("search").String())
|
||||
}
|
||||
|
||||
|
@ -100,7 +86,5 @@ func main() {
|
|||
|
||||
// Redirect back to the referrer with the encrypted client key
|
||||
redirectUri := strings.Split(js.Global().Get("document").Get("referrer").String(), "?")[0]
|
||||
js.Global().Get("swipe").Get("classList").Call("add", "swipe-animate")
|
||||
time.Sleep(sleepTime)
|
||||
js.Global().Get("window").Get("location").Call("replace", redirectUri+"?ecdhPublicKey="+base64.URLEncoding.EncodeToString(privateKey.PublicKey().Bytes())+"&nonce="+base64.URLEncoding.EncodeToString(nonce)+"&cipherText="+base64.URLEncoding.EncodeToString(encryptedClientKey))
|
||||
}
|
||||
|
|
|
@ -191,22 +191,9 @@ func fetchOauthClients(oauthList js.Value, localStorage js.Value, body []byte) {
|
|||
}
|
||||
|
||||
func main() {
|
||||
// Transition in
|
||||
js.Global().Get("document").Get("body").Set("style", "display: initial")
|
||||
js.Global().Get("swipe-out").Get("classList").Call("add", "swipe-out-animate")
|
||||
|
||||
var sleepTime = 200 * time.Millisecond
|
||||
if js.Global().Get("window").Call("matchMedia", "(prefers-reduced-motion: reduce)").Get("matches").Bool() {
|
||||
sleepTime = 500 * time.Millisecond
|
||||
}
|
||||
|
||||
time.Sleep(sleepTime)
|
||||
|
||||
// Redirect to log-in if not signed in
|
||||
localStorage := js.Global().Get("localStorage")
|
||||
if localStorage.Call("getItem", "DONOTSHARE-secretKey").IsNull() {
|
||||
js.Global().Get("swipe").Get("classList").Call("add", "swipe-animate")
|
||||
time.Sleep(sleepTime)
|
||||
js.Global().Get("window").Get("location").Call("replace", "/login"+js.Global().Get("window").Get("location").Get("search").String())
|
||||
}
|
||||
|
||||
|
@ -261,8 +248,6 @@ func main() {
|
|||
}
|
||||
|
||||
// Redirect to log-out if not signed in
|
||||
js.Global().Get("swipe").Get("classList").Call("add", "swipe-animate")
|
||||
time.Sleep(sleepTime)
|
||||
js.Global().Get("window").Get("location").Call("replace", "/logout")
|
||||
return
|
||||
} else if response.StatusCode == 500 {
|
||||
|
@ -414,8 +399,6 @@ func main() {
|
|||
if response.StatusCode == 200 {
|
||||
sessionElement.Call("remove")
|
||||
if session.(map[string]interface{})["session"].(string) == localStorage.Call("getItem", "DONOTSHARE-secretKey").String() {
|
||||
js.Global().Get("swipe").Get("classList").Call("add", "swipe-animate")
|
||||
time.Sleep(sleepTime)
|
||||
js.Global().Get("window").Get("location").Call("replace", "/logout")
|
||||
}
|
||||
} else if response.StatusCode != 500 {
|
||||
|
@ -621,8 +604,6 @@ func main() {
|
|||
}
|
||||
|
||||
if response.StatusCode == 200 {
|
||||
js.Global().Get("swipe").Get("classList").Call("add", "swipe-animate")
|
||||
time.Sleep(sleepTime)
|
||||
js.Global().Get("window").Get("location").Call("replace", "/logout")
|
||||
} else if response.StatusCode != 500 {
|
||||
js.Global().Call("alert", responseMap["error"].(string))
|
||||
|
@ -692,8 +673,6 @@ func main() {
|
|||
}
|
||||
|
||||
// We don't care about the response, we're logging out anyway
|
||||
js.Global().Get("swipe").Get("classList").Call("add", "swipe-animate")
|
||||
time.Sleep(sleepTime)
|
||||
js.Global().Get("window").Get("location").Call("replace", "/logout")
|
||||
}()
|
||||
return nil
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"syscall/js"
|
||||
"time"
|
||||
|
||||
|
@ -69,34 +68,10 @@ func showInput(inputType int, inputContainer js.Value, usernameBox js.Value, sig
|
|||
}
|
||||
|
||||
func main() {
|
||||
// Transition in
|
||||
js.Global().Get("document").Get("body").Set("style", "display: initial")
|
||||
js.Global().Get("swipe-out").Get("classList").Call("add", "swipe-out-animate")
|
||||
|
||||
var sleepTime = 200 * time.Millisecond
|
||||
if js.Global().Get("window").Call("matchMedia", "(prefers-reduced-motion: reduce)").Get("matches").Bool() {
|
||||
sleepTime = 500 * time.Millisecond
|
||||
}
|
||||
|
||||
time.Sleep(sleepTime)
|
||||
|
||||
// Parse the url parameters using url.ParseQuery
|
||||
dashboard := false
|
||||
_, err := url.ParseQuery(strings.TrimPrefix(js.Global().Get("window").Get("location").Get("search").String(), "?"))
|
||||
if err != nil {
|
||||
dashboard = true
|
||||
}
|
||||
|
||||
// Redirect to app if already signed in
|
||||
localStorage := js.Global().Get("localStorage")
|
||||
if !localStorage.Call("getItem", "DONOTSHARE-secretKey").IsNull() {
|
||||
js.Global().Get("swipe").Get("classList").Call("add", "swipe-animate")
|
||||
time.Sleep(sleepTime)
|
||||
if !dashboard {
|
||||
js.Global().Get("window").Get("location").Call("replace", "/authorize"+js.Global().Get("window").Get("location").Get("search").String())
|
||||
} else {
|
||||
js.Global().Get("window").Get("location").Call("replace", "/dashboard")
|
||||
}
|
||||
}
|
||||
|
||||
var usernameBox = js.Global().Get("document").Call("getElementById", "usernameBox")
|
||||
|
@ -244,13 +219,7 @@ func main() {
|
|||
// Redirect to app
|
||||
statusBox.Set("innerText", "Welcome!")
|
||||
time.Sleep(time.Second)
|
||||
js.Global().Get("swipe").Get("classList").Call("add", "swipe-animate")
|
||||
time.Sleep(sleepTime)
|
||||
if !dashboard {
|
||||
js.Global().Get("window").Get("location").Call("replace", "/authorize"+js.Global().Get("window").Get("location").Get("search").String())
|
||||
} else {
|
||||
js.Global().Get("window").Get("location").Call("replace", "/dashboard")
|
||||
}
|
||||
} else if response.StatusCode == 401 {
|
||||
// Login failed
|
||||
showInput(1, inputContainer, usernameBox, signupButton, passwordBox, backButton, inputNameBox, statusBox, nextButton)
|
||||
|
@ -283,8 +252,6 @@ func main() {
|
|||
}))
|
||||
|
||||
signupButton.Call("addEventListener", "click", js.FuncOf(func(this js.Value, args []js.Value) interface{} {
|
||||
js.Global().Get("swipe").Get("classList").Call("add", "swipe-animate")
|
||||
time.Sleep(sleepTime)
|
||||
js.Global().Get("window").Get("location").Call("replace", "/signup"+js.Global().Get("window").Get("location").Get("search").String())
|
||||
return nil
|
||||
}))
|
||||
|
|
|
@ -9,7 +9,6 @@ import (
|
|||
"encoding/hex"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"encoding/json"
|
||||
|
@ -58,34 +57,10 @@ func pow(resource string) (string, string, error) {
|
|||
}
|
||||
|
||||
func main() {
|
||||
// Transition in
|
||||
js.Global().Get("document").Get("body").Set("style", "display: initial")
|
||||
js.Global().Get("swipe-out").Get("classList").Call("add", "swipe-out-animate")
|
||||
|
||||
var sleepTime = 200 * time.Millisecond
|
||||
if js.Global().Get("window").Call("matchMedia", "(prefers-reduced-motion: reduce)").Get("matches").Bool() {
|
||||
sleepTime = 500 * time.Millisecond
|
||||
}
|
||||
|
||||
time.Sleep(sleepTime)
|
||||
|
||||
// Parse the url parameters using url.ParseQuery
|
||||
dashboard := false
|
||||
_, err := url.ParseQuery(strings.TrimPrefix(js.Global().Get("window").Get("location").Get("search").String(), "?"))
|
||||
if err != nil {
|
||||
dashboard = true
|
||||
}
|
||||
|
||||
// Redirect to app if already signed in
|
||||
localStorage := js.Global().Get("localStorage")
|
||||
if !localStorage.Call("getItem", "DONOTSHARE-secretKey").IsNull() {
|
||||
js.Global().Get("swipe").Get("classList").Call("add", "swipe-animate")
|
||||
time.Sleep(sleepTime)
|
||||
if !dashboard {
|
||||
js.Global().Get("window").Get("location").Call("replace", "/authorize"+js.Global().Get("window").Get("location").Get("search").String())
|
||||
} else {
|
||||
js.Global().Get("window").Get("location").Call("replace", "/dashboard")
|
||||
}
|
||||
}
|
||||
|
||||
var usernameBox = js.Global().Get("document").Call("getElementById", "usernameBox")
|
||||
|
@ -204,13 +179,7 @@ func main() {
|
|||
// Redirect to app
|
||||
statusBox.Set("innerText", "Welcome!")
|
||||
time.Sleep(time.Second)
|
||||
js.Global().Get("swipe").Get("classList").Call("add", "swipe-animate")
|
||||
time.Sleep(sleepTime)
|
||||
if !dashboard {
|
||||
js.Global().Get("window").Get("location").Call("replace", "/authorize"+js.Global().Get("window").Get("location").Get("search").String())
|
||||
} else {
|
||||
js.Global().Get("window").Get("location").Call("replace", "/dashboard")
|
||||
}
|
||||
} else if response.StatusCode == 409 {
|
||||
// Username taken
|
||||
showElements(true, inputContainer, signupButton, loginButton)
|
||||
|
@ -230,8 +199,6 @@ func main() {
|
|||
}))
|
||||
|
||||
loginButton.Call("addEventListener", "click", js.FuncOf(func(this js.Value, args []js.Value) interface{} {
|
||||
js.Global().Get("swipe").Get("classList").Call("add", "swipe-animate")
|
||||
time.Sleep(sleepTime)
|
||||
js.Global().Get("window").Get("location").Call("replace", "/login"+js.Global().Get("window").Get("location").Get("search").String())
|
||||
return nil
|
||||
}))
|
||||
|
|
|
@ -17,7 +17,6 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
"syscall/js"
|
||||
"time"
|
||||
)
|
||||
|
||||
func sha256Base64(s string) string {
|
||||
|
@ -47,22 +46,9 @@ func randomChars(length int) (string, error) {
|
|||
}
|
||||
|
||||
func main() {
|
||||
// Transition in
|
||||
js.Global().Get("document").Get("body").Set("style", "display: initial")
|
||||
js.Global().Get("swipe-out").Get("classList").Call("add", "swipe-out-animate")
|
||||
|
||||
var sleepTime = 200 * time.Millisecond
|
||||
if js.Global().Get("window").Call("matchMedia", "(prefers-reduced-motion: reduce)").Get("matches").Bool() {
|
||||
sleepTime = 500 * time.Millisecond
|
||||
}
|
||||
|
||||
time.Sleep(sleepTime)
|
||||
|
||||
// Redirect to log-in if not signed in
|
||||
localStorage := js.Global().Get("localStorage")
|
||||
if localStorage.Call("getItem", "DONOTSHARE-secretKey").IsNull() {
|
||||
js.Global().Get("swipe").Get("classList").Call("add", "swipe-animate")
|
||||
time.Sleep(sleepTime)
|
||||
js.Global().Get("window").Get("location").Call("replace", "/login"+js.Global().Get("window").Get("location").Get("search").String())
|
||||
}
|
||||
|
||||
|
@ -102,8 +88,6 @@ func main() {
|
|||
}
|
||||
|
||||
// Redirect to log-out if not signed in
|
||||
js.Global().Get("swipe").Get("classList").Call("add", "swipe-animate")
|
||||
time.Sleep(sleepTime)
|
||||
js.Global().Get("window").Get("location").Call("replace", "/logout"+js.Global().Get("window").Get("location").Get("search").String())
|
||||
return
|
||||
} else if response.StatusCode == 500 {
|
||||
|
@ -233,8 +217,6 @@ func main() {
|
|||
localStorage.Call("setItem", "TESTER-privateKey", base64.StdEncoding.EncodeToString(privateKey.Bytes()))
|
||||
|
||||
// Redirect to the client key exchange endpoint
|
||||
js.Global().Get("swipe").Get("classList").Call("add", "swipe-animate")
|
||||
time.Sleep(sleepTime)
|
||||
js.Global().Get("window").Get("location").Call("replace", "/clientKeyShare?ecdhPublicKey="+base64.URLEncoding.EncodeToString(privateKey.PublicKey().Bytes())+"&accessToken="+responseMap["access_token"].(string))
|
||||
return
|
||||
} else if response.StatusCode != 500 {
|
||||
|
@ -335,8 +317,6 @@ func main() {
|
|||
localStorage.Call("setItem", "TESTER-verifier", verifier)
|
||||
|
||||
// Redirect to the authorization page
|
||||
js.Global().Get("swipe").Get("classList").Call("add", "swipe-animate")
|
||||
time.Sleep(sleepTime)
|
||||
js.Global().Get("window").Get("location").Call("replace", "/authorize?response_type=code&client_id=TestApp-DoNotUse&redirect_uri="+url.QueryEscape(js.Global().Get("window").Get("location").Get("origin").String()+"/testApp")+"&code_challenge="+verifierChallenge+"&code_challenge_method=S256")
|
||||
}()
|
||||
return nil
|
||||
|
|
Loading…
Add table
Reference in a new issue