TripleParity / docks-api

RESTful API Server for Docks
https://tripleparity.github.io/docks-api/stack-api-spec.html
GNU General Public License v3.0
0 stars 0 forks source link

Rename `username` claim to `sub` in JWT #47

Open egeldenhuys opened 6 years ago

egeldenhuys commented 6 years ago

RFC 7519 Section 4.1.2 states

The "sub" (subject) claim identifies the principal that is the subject of the JWT. The claims in a JWT are normally statements about the subject. The subject value MUST either be scoped to be locally unique in the context of the issuer or be globally unique. The processing of this claim is generally application specific. The "sub" value is a case-sensitive string containing a StringOrURI value. Use of this claim is OPTIONAL.

This is exactly what we use the username claim for at the moment. It would be better to use the proposed claim of sub for this purpose.

Proposed JWT structure

{
  "sub": "<username>"
}