Skip to content

Commit 671dd20

Browse files
authored
docs: Update explanation and instructions
1 parent 7788814 commit 671dd20

File tree

1 file changed

+32
-39
lines changed

1 file changed

+32
-39
lines changed

README.md

Lines changed: 32 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,12 @@
3838
<summary>Table of Contents</summary>
3939

4040
- [About The Project](#about-the-project)
41-
- [Supports](#supports)
4241
- [Getting Started](#getting-started)
4342
- [Prerequisites](#prerequisites)
4443
- [Installation](#installation)
45-
- [Usage](#usage)
44+
- [How to use](#how-to-use)
45+
- [How does this work?](#how-does-this-work)
46+
- [Why heimdall as a service?](#why-heimdall-as-a-service)
4647
- [Maintainer(s)](#maintainers)
4748
- [Contact](#contact)
4849
- [Additional documentation](#additional-documentation)
@@ -60,21 +61,7 @@
6061
</a>
6162
</div>
6263

63-
_Heimdall checks the client's IP to know whether the request has originated from inside the IIT Kharagpur network and verifies their institute email ID. This helps to ascertain if the client is a current member of the institute and should have access to certain information._
64-
65-
<p align="right">(<a href="#top">back to top</a>)</p>
66-
67-
<div id="supports"></div>
68-
69-
### Supports:
70-
71-
<!-- UPDATE -->
72-
73-
1. Shells
74-
- `bash`
75-
- `zsh`
76-
2. OS(s)
77-
- any `*nix`[`GNU+Linux` and `Unix`]
64+
_Heimdall checks the client's IP to know whether the request has originated from inside the IIT Kharagpur network and verifies their institute email ID. This helps to ascertain if the client is a current member of the institute and should have access to the information provided by metaKGP services protected by Heimdall._
7865

7966
<p align="right">(<a href="#top">back to top</a>)</p>
8067

@@ -86,16 +73,16 @@ To set up a local instance of the application, follow the steps below.
8673

8774
The following dependencies are required to be installed for the project to function properly:
8875

89-
<!-- UPDATE -->
90-
9176
- [go](https://go.dev/)
9277
- [nodejs](https://nodejs.org/en/download/package-manager)
9378

94-
To create credentials.json file, create the [OAuth consent screen](https://developers.google.com/workspace/guides/configure-oauth-consent#configure_oauth_consent) and then create [OAuth client ID credentials](https://developers.google.com/workspace/guides/create-credentials#oauth-client-id) by following the steps provided there. While creating OAuth client ID credentials, set redirect URL to any port of the localhost. Then save downloaded json file as credentials.json in the project's root folder.
95-
96-
Then enable [Gmail API](https://console.cloud.google.com/apis/library/gmail.googleapis.com) to enable receiving OTP.
79+
To create the `credentials.json` file, set up the things below by following the respective guides:
80+
- [OAuth consent screen](https://developers.google.com/workspace/guides/configure-oauth-consent#configure_oauth_consent).
81+
- [OAuth client ID credentials](https://developers.google.com/workspace/guides/create-credentials#oauth-client-id).
82+
- While creating OAuth client ID credentials, set the redirect URL to any port of localhost.
83+
- Save the downloaded JSON file as `credentials.json` in the project's root directory.
84+
- Then enable [Gmail API](https://console.cloud.google.com/apis/library/gmail.googleapis.com) to enable receiving OTP.
9785

98-
9986
<p align="right">(<a href="#top">back to top</a>)</p>
10087

10188
### Installation
@@ -113,9 +100,9 @@ _Now that the environment has been set up and configured to properly compile and
113100
cd ./heimdall
114101
cp .env.template .env
115102
```
116-
Choose a strong JWT_SECRET_KEY and edit the .env file accordingly.
103+
Choose a strong JWT_SECRET_KEY and edit the `.env` file accordingly.
117104

118-
3. Install go dependencies
105+
3. Install Go dependencies
119106
```sh
120107
go mod download
121108
```
@@ -128,29 +115,27 @@ _Now that the environment has been set up and configured to properly compile and
128115
./heimdall
129116
```
130117

131-
When prompted to enter authorization code, visit the link provided in terminal which will redirect to localhost. Then inspect the url after redirection and copy the string after `code=` and paste it in the terminal. This will create `token.json` file. You need to create this token only once and it will be valid for 6 months.
118+
When prompted to enter the authorization code, visit the link provided in the terminal, which will redirect to localhost. Then, inspect the URL after redirection and copy the string after `code=` and paste it in the terminal. This will create a `token.json` file. You need to create this token only once, and it will be valid for 6 months.
132119

133-
Above steps set up the backend server required for Heimdall. Now, to get access to services [Naarad](https://github.com/metakgp/naarad) and [Chillzone](https://github.com/metakgp/chillzone), enter the institute mail id at the frontend. To launch the frontend, please refer the instructions [here](https://github.com/metakgp/heimdall/blob/master/frontend/README.md)
120+
The above steps set up the backend server required for Heimdall. To launch the frontend, please refer to the instructions [here](https://github.com/metakgp/heimdall/blob/master/frontend/README.md)
134121

135122
<p align="right">(<a href="#top">back to top</a>)</p>
136123

137124
### How to use?
138125

139-
Enter your institute mail id in the box provided on screen. You will receive an OTP if the provided mail id is a valid institute mail id. In that case, enter the OTP received at the provided email address and verify. These verifies that you are a current member of the institute.
126+
Enter your institute mail ID in the box provided on the screen. You will receive an OTP if the provided mail ID is a valid institute mail ID. In that case, enter the OTP received at the provided email address and verify. This verifies that you are a present member of the institute.
140127

141-
Next, you will have access to services like [Naarad](https://github.com/metakgp/naarad) and [Chillzone](https://github.com/metakgp/chillzone) which are available only for KGPians. These can be accessed via the campus network.
128+
Next, you will have access to services like [Naarad](https://github.com/metakgp/naarad) and [Chillzone](https://github.com/metakgp/chillzone), which are available only for KGPians. These can be accessed via the campus network.
142129

143130
<p align="right">(<a href="#top">back to top</a>)</p>
144131

145132
<!-- BACKGROUND INFORMATION -->
146133

147134
## How does this work?
148135

149-
<!-- UPDATE -->
136+
IIT Kharagpur has its internal campus network, which is the primary source of Internet for its students, staff, and faculty.
150137

151-
IIT Kharagpur has its internal campus network which is the primary source of Internet for its students, staff and faculty.
152-
153-
For connection to the outside network (normal internet services), it uses a [NAT Gateway](https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat-gateway.html) which handles all requests going outside. While doing so, the client IP address in those requests is changed from the internal IP to any one of the pool of public IP addresses assigned to IIT Kharagpur.
138+
For connection to the outside network (normal internet services), it uses a [NAT Gateway](https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat-gateway.html), which handles all requests going outside. While doing so, the client IP address in those requests is changed from the internal IP to one of the pool of public IP addresses assigned to IIT Kharagpur.
154139

155140
So, to check whether a request has originated from inside the IIT Kharagpur network, we just check whether the client's IP address belongs to one of those public IPs.
156141

@@ -161,24 +146,32 @@ While just doing this would have sufficed, we do not know whether these Public I
161146
<img width="80%" alt="image" src="./assets/whois.png">
162147
</a>
163148

164-
_For complete Whois information check [here](https://whois.domaintools.com/203.110.242.30)._
149+
_For complete Whois information, check [here](https://whois.domaintools.com/203.110.242.30)._
165150
</div>
166151

167-
<p align="right">(<a href="#top">back to top</a>)</p>
152+
> [!Note]
153+
> The above functionality is implemented in the main (`/`) route
168154
169-
When user enters institute mail id and verifies using OTP, a cookie is generated which is valid only for the domain `.metakgp.org` (including its subdomains like `naarad.metakgp`, `gyft.metakgp`, etc.). This cookie contains user's institute mail id, which can be retrieved from it.
155+
When the user enters the institute mail ID, an OTP is sent (`/get-otp`) and once they verify the OTP (`/verfiy-otp`), a cookie is generated which is valid only for the domain `*.metakgp.org` (including its subdomains like `naarad.metakgp`, `gyft.metakgp`, etc.). This cookie contains the user's institute mail ID, which can be retrieved from it.
170156

171-
The endpoint `/validate-jwt` validates the cookie which is sent along with the request to access internal services like Naarad and Gyft. Once user's mail id is verified, he/she can access above services, making sure that they are accessible only to institute students.
157+
The endpoint `/validate-jwt` validates the cookie that is sent along with the request to access internal services like Naarad and Gyft. Once the user's mail ID is verified, they can access the above services, making sure that they are accessible only to institute students.
172158

173-
All this time you might be wondering why you need a different server to just check this. Can't we do this in any project where such a feature is required?
159+
### Why heimdall as a service?
174160

175-
Well yes. Provided it has a backend server. This cannot be done in the front-end because the Web Browser does not provide the IP information to the Javascript engine. So for projects that do not need a backend, like [Chillzone](https://github.com/metakgp/chillzone) or [ERP Auto Login](https://github.com/metakgp/iitkgp-erp-auto-login), this simple API call can do the required work.
161+
All this time, you might be wondering why you need a different server to just check this. Can't we do this in any project where such a feature is required?
162+
163+
Well yes. Provided it has a backend server. This cannot be done in the front-end because the Web Browser does not provide the IP information to the JavaScript engine. So, for projects that do not need a backend, like [Chillzone](https://github.com/metakgp/chillzone) or [ERP Auto Login](https://github.com/metakgp/iitkgp-erp-auto-login), this simple API call can do the required work.
164+
165+
Also, one service - to protect all of our services. Reducing code repetition and easy integration.
166+
167+
<p align="right">(<a href="#top">back to top</a>)</p>
176168

177169
## Maintainer(s)
178170

179171
<!-- UPDATE -->
180172

181173
- [Chirag Ghosh](https://github.com/chirag-ghosh)
174+
- [Arpit Bhardwaj](https://github.com/proffapt)
182175

183176
<p align="right">(<a href="#top">back to top</a>)</p>
184177

0 commit comments

Comments
 (0)