ai-cfia / membrane-backend

Membrane Backend: A centralized authentication service for Single Sign-On (SSO) enabling seamless token-based email verification across multiple client applications.
MIT License
1 stars 0 forks source link

Implement JWT Encoding, Decoding, and Stack Trace Handling #13

Closed CFIALeronB closed 1 year ago

CFIALeronB commented 1 year ago

Description:

We need to enhance our current JWT token handling by adding encoding, decoding functionalities, and improved error handling.

Tasks:

Implement encode_jwt_token to encode the payload:

Use the RS256 algorithm.
Employ the respective private key for encoding.

Implement decode_jwt_token to decode JWT tokens:

Decode the token using the appropriate public key.
Make use of the app_id to determine the appropriate public key.

Configuration:

Introduce and use the environment variables: PUBLIC_KEYS_DIRECTORY, PRIVATE_KEYS_DIRECTORY, and APP_ID.

Improve Error Handling:

Integrate stack trace handling in the verify_token route to gracefully handle errors.
Ensure any JWT related errors are reported back to the user/client.

Testing:

Update existing unit tests to reflect the new implementations.
Ensure tests validate the encoding and decoding processes, as well as error handling.