Skip to content

Commit

Permalink
Merge pull request #22 from natron-io/fix_auth
Browse files Browse the repository at this point in the history
fix logged in issue
  • Loading branch information
janlauber authored Jan 23, 2022
2 parents 93efc8d + 6b0091c commit 2f54c5b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions controllers/authController.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ func LoggedIn(c *fiber.Ctx, githubData string) error {
githubTeamSlugs = append(githubTeamSlugs, githubTeam["slug"].(string))
}

if githubTeamSlugs == nil {
// return unauthorized
return c.Status(401).JSON(fiber.Map{
"message": "Unauthorized",
})
}

claims := jwt.MapClaims{
"github_team_slugs": githubTeamSlugs,
}
Expand Down Expand Up @@ -93,6 +100,11 @@ func CheckAuth(c *fiber.Ctx) []string {

claims := token.Claims.(jwt.MapClaims)

if claims["github_team_slugs"] == nil {
util.WarningLogger.Printf("IP %s is not authorized", c.IP())
return nil
}

var githubTeamSlugs []string
for _, githubTeam := range claims["github_team_slugs"].([]interface{}) {
githubTeamSlugs = append(githubTeamSlugs, githubTeam.(string))
Expand Down

0 comments on commit 2f54c5b

Please sign in to comment.