-
Notifications
You must be signed in to change notification settings - Fork 31
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
feat(jwt): implement JWT auth for asset downloads #719
Conversation
0885942
to
edf9455
Compare
67861de
to
727c77d
Compare
f65d610
to
8c2f4b5
Compare
Looks like I have some itest cleanup to check on or something. |
itests are fixed, turned out to be a small and silly issue. |
src/main/java/io/cryostat/net/web/http/api/beta/AbstractJwtConsumingHandler.java
Show resolved
Hide resolved
JWT-consumers are likely to need to send back files or write streams to the client, which is not supported by the abstract V2 handler
…to latest download-flow branch
🎉 Great news! Looks like all the dependencies have been resolved: 💡 To add or remove a dependency please update this issue/PR description. Brought to you by Dependent Issues (:robot: ). Happy coding! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Fixes #718
Depends on cryostatio/cryostat-web#319
This PR primarily adds a new
POST /api/beta/auth/token
API handler. This handler takes the usualAuthorization
andX-JMX-Authorization
headers as well as theresource
multipart form attribute and delegates off to theAssetJwtHelper
. These three factors are encoded into a JWT, which is then symmetrically encrypted. The handler then responds back to the client with aresourceUrl
likehttp://cryostat.example:1234/api/beta/reports/foo.jfr?token=thetoken
. All the client needs to do is then issue aGET http://cryostat.example:1234/api/beta/reports/foo.jfr?token=thetoken
and the requested resource will be sent - assuming that by the time this is done the token is still valid, since they expire somewhat quickly. TheAuthorization
header encoded into the token is checked at the time of theGET
request to ensure that the user bearing the token has the required permissions for the resource they are requesting, and theX-JMX-Authorization
header content encoded into the token is used if needed when establishing any potential JMX connection opened by the request, and the request URL is checked against the originalresource
attribute to ensure the token was generated for this exact resource. If any of these checks fail then the client receives a401
response. There areGET /api/beta/recordings/:recordingName
,GET /api/beta/targets/:targetId/recordings/:recordingName
,GET /api/beta/reports/:recordingName
,GET /api/beta/targets/:targetId/reports/:recordingName
, andGET /api/beta/targets/:targetId/templates/:templateName/type/:templateType
handlers implemented which all accept the JWT rather than requiringAuthorization
/X-JMX-Authorization
headers.