Skip to content

Commit 6967d19

Browse files
Eshan PateldiningPhilosopher64
Eshan Patel
authored andcommitted
Moving Token-Based Authentication to React infrastructure
1 parent ed76aa0 commit 6967d19

37 files changed

+676
-476
lines changed

SECURITY.md

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ This token can be provided to the server in 2 ways:
7272
```
7373
Once provided, this information is cached in the browser and will be used in subsequent interactions
7474

75-
2. Through the password field on the page that is presented when the user is not already logged in.
76-
<p align="left">
77-
<img width="600" src="./img/token_authentication_page.png">
75+
2. Through the auth token input field in the Status Information dialogue box that is presented when the user is not already logged in.
76+
<p align="center">
77+
<img width="800" src="./img/token_authentication_page.png">
7878
</p>
7979

8080
**NOTE** : Its highly recommended to use this feature along with SSL enabled as shown [here](#use-token-authentication-with-ssl-enabled).
@@ -182,20 +182,16 @@ $ ssh test-user@usermachine
182182
For servers for which `Token-Based Authentication` were enabled, the URLs above will include their tokens.
183183
You can use them to gain access to your server as described in the [Introduction](#introduction).
184184

185-
#### **Recover token from a previously authenticated browser session**
185+
#### **Retrieve token from a previously authenticated browser session**
186186

187-
1. Navigate to a browser window in which you had previously used the server.
188-
```bash
189-
# Lets assume this was the server:
190-
http://127.0.0.1:36537/test
191-
```
192-
1. Edit the URL to access the endpoint `mwi_auth_token`
193-
```html
194-
http://127.0.0.1:36537/test/get_mwi_auth_token
195-
```
196-
This should take you to a screen which prints the `mwi_auth_token` for that server, as shown below:
197-
<p align="left">
198-
<img width="600" src="./img/recover_mwi_auth_token.png">
187+
1. Click on the `View Token` link to see the token
188+
<p align="center">
189+
<img width="600" src="./img/retrieve_token.png">
190+
</p>
191+
192+
2. Click on the `Hide Token` link to hide the token
193+
<p align="center">
194+
<img width="600" src="./img/retrieved_token.png">
199195
</p>
200196

201197
## Security Best Practices

gui/public/authorization.html

Lines changed: 0 additions & 115 deletions
This file was deleted.

gui/public/bootstrap.3.4.1.min.css

Lines changed: 0 additions & 6 deletions
This file was deleted.

gui/public/index.html

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,6 @@
11
<!-- Copyright (c) 2020-2022 The MathWorks, Inc. -->
22
<!DOCTYPE html>
33
<html lang="en">
4-
<script>
5-
function isServerAuthenticated() {
6-
// Check whether server is authorized
7-
var url_string = document.URL
8-
var base_url = url_string.split("index.html")[0]
9-
var url = new URL(url_string);
10-
var token = url.searchParams.get("mwi_auth_token");
11-
var auth_endpoint = base_url + "authenticate_request"
12-
if (token) {
13-
auth_endpoint += "?mwi_auth_token=" + token
14-
}
15-
console.log("auth_endpoint: " + auth_endpoint);
16-
fetch(auth_endpoint)
17-
.then(function (response) {
18-
if (response.ok) {
19-
console.log('This page is authorized!')
20-
return;
21-
} else {
22-
console.log('This page is NOT authorized!')
23-
console.log("Redirecting to :" + base_url)
24-
window.location.replace(base_url)
25-
}
26-
}).catch(function (error) {
27-
console.log(error);
28-
});
29-
}
30-
</script>
314

325
<head>
336
<meta charset="utf-8" />
@@ -39,7 +12,7 @@
3912
<title>MATLAB</title>
4013
</head>
4114

42-
<body onload="isServerAuthenticated()">
15+
<body>
4316
<noscript>You need to enable JavaScript to run this app.</noscript>
4417
<div id="root"></div>
4518
</body>

gui/public/navbar.css

Lines changed: 0 additions & 8 deletions
This file was deleted.

gui/public/signin.css

Lines changed: 0 additions & 42 deletions
This file was deleted.

gui/public/token.html

Lines changed: 0 additions & 123 deletions
This file was deleted.

0 commit comments

Comments
 (0)