mirror of
https://github.com/kataras/iris.git
synced 2025-12-18 10:27:06 +00:00
improve the example and add jwt authentication on handshake or server connect event or any other event
as requested a long time ago at: https://github.com/kataras/iris/issues/1229#issuecomment-484791181 Former-commit-id: 17259069bc5decc022bf3b706b0654c8f473d3c8
This commit is contained in:
@@ -17,6 +17,17 @@
|
||||
var port = document.location.port ? ":" + document.location.port : "";
|
||||
var wsURL = scheme + "://" + document.location.hostname + port + "/echo";
|
||||
|
||||
const enableJWT = true;
|
||||
if (enableJWT) {
|
||||
// This is just a signature and a payload of an example content,
|
||||
// please replace this with your logic.
|
||||
//
|
||||
// Add a random letter in front of the token to make it
|
||||
// invalid and see that this client is not allowed to dial the websocket server.
|
||||
const token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjozMjEzMjF9.8waEX7-vPKACa-Soi1pQvW3Rl8QY-SUFcHKTLZI4mvU";
|
||||
wsURL += "?token=" + token;
|
||||
}
|
||||
|
||||
var outputTxt = document.getElementById("output");
|
||||
function addMessage(msg) {
|
||||
outputTxt.innerHTML += msg + "\n";
|
||||
@@ -24,7 +35,7 @@
|
||||
|
||||
function handleError(reason) {
|
||||
console.log(reason);
|
||||
window.alert(reason);
|
||||
window.alert("error: see the dev console");
|
||||
}
|
||||
|
||||
function handleNamespaceConnectedConn(nsConn) {
|
||||
|
||||
Reference in New Issue
Block a user