Conversation
Using shared secrets, external services can ask for CBRAIN API tokens for users.
|
I will provide precise instructions on how to review/test this new code. |
|
Step 1: when checking out this branch, make sure to run "bundle install" because there are changes in the Gemfile. the "jwt" gem has been upgraded and the "shannon" gem is new. |
|
Step 2. In the rails console, pick a NormalUser of your choice and provide them with a secret: |
|
Step 3: in the console, built yourself a token as if you were "loris": (btw, you can also just use the variable "secret" in the second argument) Copy the resulting string to your clipboard, we'll use it with curl in the next step |
|
Step 4: send the JWT encoded token (the string you got in step 3) to CBRAIN using curl: Curl should print out CBRAIN's answer, a similary JSON output. |
|
Step 5: Check the rails logs and try bad things The rails logs shoudl have lines that say: Now try many other requests by editing the curl command-line you can test once this has worked:
|
|
This is a great addition @prioux! The JWT mechanism is a perfect fit for the CBRAIN-CLI v1.0 roadmap. It aligns perfectly with my proposed XDG compliant config manager ( I will be following the merge of #1604 closely to ensure the Lazy-Auth Interceptor I am building is fully compatible with this new endpoint! |
|
@AviJxn This PR has nothing to do with the CLI client, and provides no functionality that would help the CLi client. I do not understand why you are even talking about a schema for shared secrets, given that any users of the CLI client already has a mechanism to authenticate that works perfectly well. This PR was implemented as a feature to help out another project. Some research group is deploying the LORIS Data Query Tool, and they wanted to be able to obtain a token and let users of the DQT send data to CBRAIN. Given LORIS servers have their own user namespace, and they are deployed in environments where CORS aren't readily usable, my API entry point was pretty much the only way to provide the feature. Please don't waste time implementing anything for the CLI related to this token mechanism. I would prefer the cli stand on its own as a traditional API client with any form of SSO. |
|
Thanks for the context @prioux! I will stay away from the JWT/SSO side of things and keep the CLI focused on being a solid traditional API client. I am shifting my focus entirely back to the v1.0 production standards we need, specifically the move to argparse for zero-dependency and the XDG config structure. I want to make sure the CLI is as robust and 'standalone' as possible for researchers using it in the field. |
|
For information I needed to add
|
|
@natacha-beck Good catch, indeed I forgot about |
Using shared secrets, external services can ask for CBRAIN API tokens for users.