I am working on an identity and users service in a microservices system for which a passwordless, SMS-based authentication is a hard requirement, i.e.
- User enters their phone number
- System sends the OTP via SMS
- User enters their OTP
- Registered users are given a JWT and allowed into the system, unregistered users are forced to register first
No username/email and password combination is used for security, only for profile details later in the registration process.
My own research yields these implementation options:
- Return a response status code based on which the client apps can act (e.g.
401if OTP is incorrect,403if not registered and200with JWT otherwise) - Return state in a response body information (e.g. a boolean field or custom response code/message), with JWT upon successful registration
- Return a JWT upon successful authentication, but vary the state of the JWT token itself, and control access accordingly (e.g. providing different
scopeclaim for unregistered and registered users)
I am leaning towards option 3, although it seems that the scope claim is mainly used for delegated access.
Any help would be appreciated, be it an informed opinion on the three options, or another suggestion altogether.