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

Commit

Permalink
Add support for new CEGA usernames in auth
Browse files Browse the repository at this point in the history
Co-authored-by: norling <[email protected]>
  • Loading branch information
dbampalikis and norling committed Oct 31, 2022
1 parent 3b64c1b commit 238c86e
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 238c86e

Please sign in to comment.