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

feat(auth): added jwt logic to the auth #86

Merged
merged 29 commits into from
Dec 10, 2021
Merged

feat(auth): added jwt logic to the auth #86

merged 29 commits into from
Dec 10, 2021

Conversation

Sanix-Darker
Copy link
Member

@Sanix-Darker Sanix-Darker commented Nov 26, 2021

What

  • implement the jwt on the auth
  • removed the github token return by the jwt

impact

In the future, to protect a route with the jwt token, we're going to use app.IsAuthorized(targethandler)

@Sanix-Darker Sanix-Darker added the need review Need some reviews label Nov 26, 2021
@Sanix-Darker Sanix-Darker self-assigned this Nov 26, 2021
@netlify
Copy link

netlify bot commented Nov 26, 2021

👷 Deploy Preview for infallible-rosalind-15c59f processing.

🔨 Explore the source changes: 6306947

🔍 Inspect the deploy log: https://app.netlify.com/sites/infallible-rosalind-15c59f/deploys/61a14c938960da000787eeee

// IsAuthorized This function will check the authorization from a given token in Bearer
func IsAuthorized(endpoint func(c *gin.Context)) gin.HandlerFunc {
fn := func(c *gin.Context) {

Copy link
Member

@DipandaAser DipandaAser Nov 27, 2021

Choose a reason for hiding this comment

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

These news lines are unecessary. this will fail during linting.
Delete it

	fn := func(c *gin.Context) {
		if c.GetHeader("Authorization") != "" {
			token, err := jwt.Parse(c.GetHeader("Authorization"), func(token *jwt.Token) (interface{}, error) {

Copy link
Member Author

Choose a reason for hiding this comment

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

Don't get it... what is unecessary ?
which lines ?

@DipandaAser
Copy link
Member

the linting check notice that the file are format with go fmt.
To format please run

$> make fmt

tokenString, err := token.SignedString(jwtSigningKey)

if err != nil {
fmt.Errorf("Something Went Wrong: %s", err.Error())
Copy link
Member

Choose a reason for hiding this comment

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

you nedd to recupere 🤣 the value returned by fmt.Errorf()

	if err != nil {
		err = fmt.Errorf("Something Went Wrong: %s", err.Error())
		return "", err
	}

Copy link
Member Author

@Sanix-Darker Sanix-Darker Nov 27, 2021

Choose a reason for hiding this comment

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

updated based on the return of the method :

if err != nil {
    return "", err
}

@Sanix-Darker Sanix-Darker changed the title feat(auth): added jwt logic feat(auth): added jwt logic to the auth Dec 4, 2021
@Sanix-Darker Sanix-Darker merged commit 19a35bf into main Dec 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need review Need some reviews
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants