Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Commit

Permalink
Merge pull request #285 from neicnordic/feature/new-cega-usernames
Browse files Browse the repository at this point in the history
Add support for new CEGA usernames in auth
  • Loading branch information
dbampalikis authored Oct 31, 2022
2 parents 3b64c1b + 238c86e commit 9d297f0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions userauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,10 @@ func (u *ValidateFromToken) Authenticate(r *http.Request) (claims jwt.MapClaims,
re = regexp.MustCompile("/([^/]+)/")
username := re.FindStringSubmatch(r.URL.Path)[1]
//nolint:nestif
// Case for Elixir usernames - Remove everything after @ character
// Case for Elixir and CEGA usernames: Replace @ with _ character
if strings.Contains(fmt.Sprintf("%v", claims["sub"]), "@") {
claimString := fmt.Sprintf("%v", claims["sub"])
if claimString[:strings.Index(claimString, "@")] != username {
if strings.ReplaceAll(claimString, "@", "_") != username {
return nil, fmt.Errorf("token supplied username %s but URL had %s",
claims["sub"], username)
}
Expand Down

0 comments on commit 9d297f0

Please sign in to comment.