Compare commits
No commits in common. "04fb803330755703f00aaaec70ab41e27b2c1562" and "9e029804152925d861c1c81e42fb8850da33603a" have entirely different histories.
04fb803330
...
9e02980415
3 changed files with 38 additions and 8 deletions
|
@ -129,6 +129,11 @@ func main() {
|
|||
http.Redirect(writer, request, redirectURL, http.StatusSeeOther)
|
||||
})
|
||||
|
||||
// for tests, can access only with valid token (when logged in)
|
||||
http.HandleFunc("/protected", logic.ValidateToken(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write([]byte("Hello, I'm protected"))
|
||||
}, srv))
|
||||
|
||||
// can access only with valid token (when logged in), deletes client
|
||||
http.HandleFunc("/delete", logic.ValidateToken(func(w http.ResponseWriter, r *http.Request) {
|
||||
id := r.Header.Get("client_id")
|
||||
|
@ -198,11 +203,6 @@ func main() {
|
|||
outputHTML(w, r, "static/register.html")
|
||||
})
|
||||
|
||||
// can access only with valid token (when logged in)
|
||||
http.HandleFunc("/verify", logic.ValidateToken(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
}, srv))
|
||||
|
||||
log.Fatal(http.ListenAndServe(":"+strconv.Itoa(config.AuthServerPort), nil))
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<body>
|
||||
<div class="container">
|
||||
<h1>Sign In</h1>
|
||||
<form action="/login" method="GET">
|
||||
<form id="loginForm" action="/login" method="GET">
|
||||
<input type="hidden" name="grant_type" value="client_credentials" />
|
||||
<input type="hidden" name="scope" value="all" />
|
||||
<div class="form-group">
|
||||
|
@ -25,10 +25,29 @@
|
|||
</div>
|
||||
<button type="submit" class="btn btn-success">Sign In</button>
|
||||
</form>
|
||||
<form action="/register.html" method="GET">
|
||||
<form id="registerForm" action="/register.html" method="GET">
|
||||
<button type="submit" class="btn btn-primary">Register</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function submitFormWithReferer(formId) {
|
||||
var form = document.getElementById(formId);
|
||||
var referrer = document.referrer || "";
|
||||
form.insertAdjacentHTML('beforeend', '<input type="hidden" name="referer" value="' + referrer + '">');
|
||||
form.submit();
|
||||
}
|
||||
|
||||
document.getElementById("loginForm").addEventListener("submit", function (event) {
|
||||
event.preventDefault();
|
||||
submitFormWithReferer("loginForm");
|
||||
});
|
||||
|
||||
document.getElementById("registerForm").addEventListener("submit", function (event) {
|
||||
event.preventDefault();
|
||||
submitFormWithReferer("registerForm");
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
@ -37,4 +56,4 @@
|
|||
.btn-primary {
|
||||
margin-top: 10px;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
|
11
auth-server/static/redirect.html
Normal file
11
auth-server/static/redirect.html
Normal file
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Redirect</title>
|
||||
<meta http-equiv="refresh" content="0;url=http://localhost:9096/login.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>If you are not redirected, <a href="http://localhost:9096/login.html">click here</a>.</p>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in a new issue