Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: litmus-portal authentication server #2867

Merged

Conversation

DarthBenro008
Copy link
Contributor

Authentication Server Refactor

Part of #2483 and GSoC Project

This PR comprehends a full re-write of litmus-portal's golang authentication server.

The server has been developed keeping in mind that the litmus-portal frontend does not need to make any change in request/response.

Routes Included

Type of Request Routes Functionality Authorisation Required
POST /login Logs in the user and generates JWT Token No
GET /users Fetches all the users to be displayed Yes
POST /create Allows admin to create a user Yes (with admin role)
POST /update/password Update password of logged in user Yes
POST /reset/password Allows admins to reset user's password Yes (with admin role)
POST /update/details Allows user to update email and name Yes

Dependencies Used

go 1.16
require (	
        github.com/dgrijalva/jwt-go v3.2.0+incompatible	
        github.com/gin-contrib/cors v1.3.1	
        github.com/gin-gonic/gin v1.7.2	
        github.com/sirupsen/logrus v1.4.2	
        go.mongodb.org/mongo-driver v1.5.3	
        golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a
)

Results

The current authentication server and the re-written server were deployed on Okteto and tested

Performance Gain

The current authentication server took 14 seconds for an average response

litmus_current_auth_marked

The re-written authentication server took 0.3 seconds for an average response

marked_new

This is a boost in performance of almost 46 times meanwhile keeping the functionality and the security the same.

Easier Packaging of Code

The packages and folders have been completely simplified. Everything in the codebase has been decoupled for easier development and access.

Before:
old_directory

After:
new_directory

Try out

You can find this codebase deployed on https://litmusportal-production-frontend-service-darthbenro008.cloud.okteto.net/
Username: admin
Password: litmus

Alternatively, you can also deploy this codebase on your own Okteto Cluster by clicking here

ToDo

  • Unit Testing and DB Mocking

Signed-off-by: Hemanth Krishna <hkpdev008@gmail.com>
Signed-off-by: Hemanth Krishna (DarthBenro008) <hkpdev008@gmail.com>
Signed-off-by: Hemanth Krishna (DarthBenro008) <hkpdev008@gmail.com>
Signed-off-by: Hemanth Krishna (DarthBenro008) <hkpdev008@gmail.com>
Signed-off-by: Hemanth Krishna (DarthBenro008) <hkpdev008@gmail.com>
Signed-off-by: Hemanth Krishna (DarthBenro008) <hkpdev008@gmail.com>
Signed-off-by: Hemanth Krishna (DarthBenro008) <hkpdev008@gmail.com>
Signed-off-by: Hemanth Krishna (DarthBenro008) <hkpdev008@gmail.com>
Signed-off-by: Hemanth Krishna (DarthBenro008) <hkpdev008@gmail.com>
Signed-off-by: Hemanth Krishna (DarthBenro008) <hkpdev008@gmail.com>
Signed-off-by: Hemanth Krishna (DarthBenro008) <hkpdev008@gmail.com>
Signed-off-by: Hemanth Krishna (DarthBenro008) <hkpdev008@gmail.com>
Signed-off-by: Hemanth Krishna (DarthBenro008) <hkpdev008@gmail.com>
Signed-off-by: Hemanth Krishna (DarthBenro008) <hkpdev008@gmail.com>
Signed-off-by: Hemanth Krishna (DarthBenro008) <hkpdev008@gmail.com>
@DarthBenro008 DarthBenro008 changed the title Refactor/portal/authentication refactor: litmus-portal authentication server Jun 7, 2021
Signed-off-by: Hemanth Krishna <hkpdev008@gmail.com>
Copy link
Contributor

@SarthakJain26 SarthakJain26 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left few comments, PTAL

Signed-off-by: Hemanth Krishna <hkpdev008@gmail.com>
@DarthBenro008
Copy link
Contributor Author

Hey @SarthakJain26 , Thank you for the comments. I have addressed/resolved the same.

@DarthBenro008
Copy link
Contributor Author

@ishangupta-ds @SarthakJain26 @rajdas98 All the requested changes have been addressed and resolved 😃

@DarthBenro008 DarthBenro008 force-pushed the refactor/portal/authentication branch from 9cc7655 to efe9c0e Compare June 9, 2021 16:50
Signed-off-by: Hemanth Krishna (DarthBenro008) <hkpdev008@gmail.com>
@DarthBenro008 DarthBenro008 force-pushed the refactor/portal/authentication branch from efe9c0e to 02b2ab0 Compare June 9, 2021 16:51
Copy link
Member

@ishangupta-ds ishangupta-ds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Signed-off-by: DarthBenro008 <hkpdev008@gmail.com>
@imrajdas imrajdas requested a review from gdsoumya June 22, 2021 15:10
Signed-off-by: DarthBenro008 <hkpdev008@gmail.com>
@DarthBenro008
Copy link
Contributor Author

@gdsoumya @rajdas98, the sample deployment of the codebase can be found at: https://litmusportal-production-frontend-service-darthbenro008.cloud.okteto.net

Username: admin
Password: litmus

Strict policy check has been enabled for this deployment and can be tested by changing credentials.

Signed-off-by: DarthBenro008 <hkpdev008@gmail.com>
@DarthBenro008 DarthBenro008 requested a review from gdsoumya June 23, 2021 09:29
@imrajdas imrajdas merged commit 9204af1 into litmuschaos:master Jun 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants