REST API Endpoints with optional authentication
Posted: Wed May 28, 2025 5:13 pm
Good day,
I'm looking for opinions on how to deal with the REST API endpoint authentication in a scenario where it would require JWT validation if a user is logged in, and it would not if they are not logged in.
The few ways I could think of this working is either by:
- Setting Ignore Top Level Security in the endpoints to "checked" and then manually checking the JWT Token passed in the RDML for validity. No token means, the user is not logged in and an invalid token means it's a bad request.
- Creating a separate endpoint for each existing one and adding either "/auth" or "/secure" to it to differentiate between an authenticated and non-authenticated route. For example: "/orders/auth" - requires authentication and "/orders" - does not require authentication
All of our Server Module APis have already been built and mostly requires authentication. Just trying to think now of which method would be less-intrusive to the already built code, without compromising on the quality of the authentication structure and creating security risks.
I'm looking for opinions on how to deal with the REST API endpoint authentication in a scenario where it would require JWT validation if a user is logged in, and it would not if they are not logged in.
The few ways I could think of this working is either by:
- Setting Ignore Top Level Security in the endpoints to "checked" and then manually checking the JWT Token passed in the RDML for validity. No token means, the user is not logged in and an invalid token means it's a bad request.
- Creating a separate endpoint for each existing one and adding either "/auth" or "/secure" to it to differentiate between an authenticated and non-authenticated route. For example: "/orders/auth" - requires authentication and "/orders" - does not require authentication
All of our Server Module APis have already been built and mostly requires authentication. Just trying to think now of which method would be less-intrusive to the already built code, without compromising on the quality of the authentication structure and creating security risks.