Skip to content

Commit

Permalink
Moving Token-Based Authentication to React infrastructure
Browse files Browse the repository at this point in the history
  • Loading branch information
Eshan Patel authored and diningPhilosopher64 committed Apr 5, 2023
1 parent ed76aa0 commit 6967d19
Show file tree
Hide file tree
Showing 37 changed files with 676 additions and 476 deletions.
28 changes: 12 additions & 16 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ This token can be provided to the server in 2 ways:
```
Once provided, this information is cached in the browser and will be used in subsequent interactions

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

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

#### **Recover token from a previously authenticated browser session**
#### **Retrieve token from a previously authenticated browser session**

1. Navigate to a browser window in which you had previously used the server.
```bash
# Lets assume this was the server:
http://127.0.0.1:36537/test
```
1. Edit the URL to access the endpoint `mwi_auth_token`
```html
http://127.0.0.1:36537/test/get_mwi_auth_token
```
This should take you to a screen which prints the `mwi_auth_token` for that server, as shown below:
<p align="left">
<img width="600" src="./img/recover_mwi_auth_token.png">
1. Click on the `View Token` link to see the token
<p align="center">
<img width="600" src="./img/retrieve_token.png">
</p>

2. Click on the `Hide Token` link to hide the token
<p align="center">
<img width="600" src="./img/retrieved_token.png">
</p>

## Security Best Practices
Expand Down
115 changes: 0 additions & 115 deletions gui/public/authorization.html

This file was deleted.

6 changes: 0 additions & 6 deletions gui/public/bootstrap.3.4.1.min.css

This file was deleted.

29 changes: 1 addition & 28 deletions gui/public/index.html
Original file line number Diff line number Diff line change
@@ -1,33 +1,6 @@
<!-- Copyright (c) 2020-2022 The MathWorks, Inc. -->
<!DOCTYPE html>
<html lang="en">
<script>
function isServerAuthenticated() {
// Check whether server is authorized
var url_string = document.URL
var base_url = url_string.split("index.html")[0]
var url = new URL(url_string);
var token = url.searchParams.get("mwi_auth_token");
var auth_endpoint = base_url + "authenticate_request"
if (token) {
auth_endpoint += "?mwi_auth_token=" + token
}
console.log("auth_endpoint: " + auth_endpoint);
fetch(auth_endpoint)
.then(function (response) {
if (response.ok) {
console.log('This page is authorized!')
return;
} else {
console.log('This page is NOT authorized!')
console.log("Redirecting to :" + base_url)
window.location.replace(base_url)
}
}).catch(function (error) {
console.log(error);
});
}
</script>

<head>
<meta charset="utf-8" />
Expand All @@ -39,7 +12,7 @@
<title>MATLAB</title>
</head>

<body onload="isServerAuthenticated()">
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
Expand Down
8 changes: 0 additions & 8 deletions gui/public/navbar.css

This file was deleted.

42 changes: 0 additions & 42 deletions gui/public/signin.css

This file was deleted.

123 changes: 0 additions & 123 deletions gui/public/token.html

This file was deleted.

Loading

0 comments on commit 6967d19

Please sign in to comment.