Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JWT authentication for rest-api #181

Merged
merged 12 commits into from
Sep 27, 2021
Merged

JWT authentication for rest-api #181

merged 12 commits into from
Sep 27, 2021

Conversation

rkrenn
Copy link
Collaborator

@rkrenn rkrenn commented Sep 9, 2021

JWT authentication introduces a dedicated "/tools/login" endpoint to authenticate a user with credentials provided via http "basic authentication" header. it will return a secure token ("JWT") string, that can be passed to subsequent rest-api requests via the "bearer authentication" header. The token authenticity is verifyied using the groupkey of the user's department, so no new keys had to be introduced (generated).

since the phoenix database stores subject PII data encrypted with PBE (password-based encryption) with the department group key, every service method requires to provide the user credentials (to encrypt/decrypt the group key and then the subject PII). for JWT authentication this means veryfying a JWT validity is not enough, the JWT token also has to carry the credentials in order to run servicemethods.

This is achieved by including the RSA-encrypted password to the JWT token payload. In phoenix every user already owns an internal RSA keypair (for signing eCRFs), which is re-used here. The private key is used to encrypt the password, while the public key is used to decrpyt. The security holds as long an attacker does not hold both public key and a captured JWT in his hands, therefore http ("bearer") header containing the JWT string should not be recorded in the http server logs.

it's up to the rest-api consumer ther to include a "validity_secs" query parameter when creating the JWT. Eg. "/tools/login?validity_secs=300" will render a token that is accepted up to 5 minutues only, until it has to be renewed.

@sonarcloud
Copy link

sonarcloud bot commented Sep 24, 2021

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability B 4 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 10 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@rkrenn rkrenn merged commit 9d02931 into master Sep 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant