Why is UserAuthName with @ symbol not added to the jwt token in ServiceStack JwtAuthProvider?

Viewed 33

In method CreateJwtPayload() in JwtAuthProvider.cs (https://github.com/ServiceStack/ServiceStack/blob/45108614b77c37185e3fe471ad49a462b825354c/ServiceStack/src/ServiceStack/Auth/JwtAuthProvider.cs#L361) are usernames with "@" symbol not setted to the payload "preferred_username".

Code snippet:

    if (!string.IsNullOrEmpty(session.UserName))
        jwtPayload["preferred_username"] = session.UserName;
    else if (!string.IsNullOrEmpty(session.UserAuthName) && !session.UserAuthName.Contains("@"))
        jwtPayload["preferred_username"] = session.UserAuthName;

Usernames in our system may contain "@" symbol, and are now not added the payload "preferred_username".

Is there a reason why UserAuthName "@" is not added to the payload in this JswAuthProvider of ServiceStack?

1 Answers

Usernames with a @ is what's used to determine whether a Username is an email in ServiceStack.

You can use the CreatePayloadFilter to modify the JWT payload to populate it yourself.

Related