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

User Authentication Management #37

Conversation

PreetinderSinghBadesha
Copy link
Collaborator

@PreetinderSinghBadesha PreetinderSinghBadesha commented Jun 20, 2024

This pull request is related to #17 and implements essential user authentication features in the backend. The following functionalities have been added:

Generation of JWT:
Added functionality to generate a JSON Web Token (JWT) with parameter username
The JWT contains user-specific information and is set to expire after a predefined duration.

Validation of JWT:
Implemented middleware to validate incoming JWTs.
Ensures that only authenticated requests can access protected endpoints by verifying the token's signature and expiration.

Registration of User:
Added a user registration endpoint to allow new users to create accounts.

Redirecting User After Logging In:
Upon successful login, the user is provided with a JWT and redirected to the appropriate dashboard or homepage.

backend/main.go Outdated
r.HandleFunc("/links/all", router.GetAllLinks).Methods(http.MethodOptions, http.MethodGet)
r.HandleFunc("/generate-token", auth.GenerateJWT).Methods(http.MethodOptions, http.MethodGet)
Copy link
Member

Choose a reason for hiding this comment

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

token should be generated on login only

"os"
"time"

"github.com/dgrijalva/jwt-go"
Copy link
Member

Choose a reason for hiding this comment

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

This jwt implementation is no longer maintained
use this instead github.com/golang-jwt/jwt - publicly maintained version of the same project

http.Redirect(w, r, url, http.StatusSeeOther)
}

func Register(w http.ResponseWriter, r *http.Request) {
Copy link
Member

Choose a reason for hiding this comment

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

instead of register, give a add new user functionality to the admin

JeevantVerma and others added 23 commits June 25, 2024 17:23
adding login page and auth to existing code
Copy link

@accesslint accesslint bot left a comment

Choose a reason for hiding this comment

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

There are accessibility issues in these changes.

QR Code
</Button>
<Grid>
<img src={qrimage}/>
Copy link

Choose a reason for hiding this comment

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

This image is missing a text alternative. This is a problem for people using screen readers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants