Authentication, Tokens & RBAC
Verifying who a user is, issuing and validating tokens safely, and enforcing what each user is allowed to do — on the server, for every request.
Authentication vs. Authorization
Authentication
Verifies who the user is — for example with a password, one-time code, or identity provider sign-in.
Authorization
Decides what that verified user may do, and on which records. It must be checked on every request.
JWT, OAuth 2.0 and OpenID Connect are different things. JWT (JSON Web Token) is a token format for carrying signed claims. OAuth 2.0 is an authorization framework for granting applications delegated access to resources. OpenID Connect is an identity layer built on OAuth 2.0 that lets applications verify who the user is. An OAuth 2.0 access token may or may not be a JWT.
Authentication and Token Validation Flow
Each step is a place where we look for weaknesses during a review.
- User LoginUser submits credentials over HTTPS.
- Identity VerificationCredentials and MFA are checked; failed attempts are throttled.
- Token IssuanceShort-lived access token and a refresh token are issued.
- Token ValidationSignature, algorithm, issuer, audience, and expiry are verified.
- Permission CheckServer checks role and ownership for this action and record.
- Resource AccessOnly permitted data is returned.
Role-Based Access Control and Least Privilege
RBAC groups permissions into roles and assigns roles to users. Least privilege means each role receives only the permissions it needs. The table below is an illustrative example, not a recommended model for every system.
| Permission | Viewer | Editor | Manager | Administrator |
|---|---|---|---|---|
| View own records | Yes | Yes | Yes | Yes |
| Edit own records | No | Yes | Yes | Yes |
| View team records | No | No | Yes | Yes |
| Approve requests | No | No | Yes | No |
| Manage users and roles | No | No | No | Yes |
Note that the administrator in this example cannot approve requests: separating duties limits the impact of a single compromised account.
Tokens and Sessions
JWT and Token Validation
- Verify the signature with the expected key.
- Allow-list accepted algorithms; reject
none. - Check
iss,aud,exp, andnbf. - Signed JWTs are readable by anyone — don't put secrets in them.
Access and Refresh Tokens
- Keep access tokens short-lived.
- Store refresh tokens securely, for example in Secure, HttpOnly cookies.
- Rotate refresh tokens on use and detect reuse.
- Never place tokens in URLs or logs.
Token Expiry and Revocation
- A JWT stays valid until it expires unless the server checks revocation.
- Revoke refresh tokens on logout, password change, and role change.
- Use short expiry or a server-side check where immediate revocation matters.
Secure Session Management
- Generate a new session ID after login.
- Set Secure, HttpOnly, and SameSite cookie attributes.
- Apply idle and absolute timeouts.
- Invalidate the session on the server at logout.
Privilege Escalation and Permission Checks
Horizontal Escalation
A user accesses another user's data at the same privilege level — for example, viewing someone else's profile by changing an ID.
CheckObject-level: does this user own or have rights to this record?
Vertical Escalation
A user performs actions reserved for a higher role — for example, a viewer calling a user-management endpoint.
CheckFunction-level: does this user's role allow this action?
Enforce permissions on the server. Never trust a role ID, user ID, tenant ID, or resource ID supplied by the client — in a request body, hidden form field, header, or local storage. Derive identity from the validated token or session and look up permissions on the server for every request.
Practical Experience
FEGO's development team has worked through findings from third-party VAPT assessments of fintech mobile apps, web portals, and APIs: analyzing each report, planning fixes, and implementing them. The examples below are generalized and describe the kinds of issues we have worked on. They are not a statement about the current security of any application.
OTP verification
Making sure OTP checks are enforced by the server and cannot be skipped, with secure generation, short expiry, and limits on attempts.
Token signing
Moving from weaker token-signing configurations to stronger algorithms with properly managed keys.
Token expiry
Shortening access-token lifetimes so a stolen token is useful for less time. This has been implemented in response to a reported finding.
Personal data in tokens
Removing personal data, such as phone numbers, from token payloads, which anyone holding the token can read.
Account lockout and login limits
Limiting repeated login and OTP attempts to slow down brute-force and account takeover attempts.
Logout and session invalidation
Invalidating sessions and tokens on the server at logout, not only on the device.
Remediation and Validation
Remediation approach
- Review each finding and reproduce it safely in a test environment
- Prioritize by severity and business impact
- Agree the fix using standard references such as CWE and OWASP
- Plan the frontend, backend, and testing work for each fix
- Fix the root cause on the server, not only in the client
Validation and reporting
- Verify each fix in internal testing before release
- Track the status of every finding, from open to fixed
- Flag fixes that need a business decision or further checks
- Support retesting by the assessor or client; a finding is closed only when retesting confirms the fix
- Document what changed and any remaining risk
Explore Security Services
Strengthen Your Application Security
Let's discuss your security requirements and identify the right approach for your applications and APIs.