-
Notifications
You must be signed in to change notification settings - Fork 53
feat: token exchange as part of VSC login #1240
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
base: master
Are you sure you want to change the base?
Conversation
This is my first time writing elixir code 😅 |
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.
LGTM, will wait for Richard to take another look at it as I'm not too familiar with authentication in SA
lib/cadet/code_exchange.ex
Outdated
alias Cadet.Accounts.User | ||
|
||
schema "token_exchange" do | ||
field(:code, :string) |
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.
Minor nit: Possibly make this a primary key?
FYP: Source Academy as Visual Studio Code Extension
The Visual Studio Code extension for Source Academy requires a slight change to the login flow.
Idea
Here is the big picture of why this PR is needed, as well as why it is as such.
IFrames
/login/callback
)Security
Modified login flow for VSC
User runs the "Login" command from within VSC, opening a browser window
Normal SAML flow
api.sourceacademy.nus.edu.sg/sso/auth/signin/student?target_url=<url in (3)>
vafs.u.nus.edu
api.sourceacademy.nus.edu.sg/sso/sp/consume/...
New backend endpoints and behaviour
api.sourceacademy.nus.edu.sg/auth/saml_redirect_vscode?provider=<provider>
token_exchange
table with 1 minute expiryvscode_redirect_url_prefix
in app vars (vscode://source-academy.source-academy/sso?code=<code>&provider=<provider>
)User's VSC extension handles and opens the iframe
api.sourceacademy.nus.edu.sg/auth/exchange?code=<code>&provider=<provider>
sourceacademy.nus.edu.sg/login/vscode_callback?access_token=<access_token>&refresh_token=<refresh_token>
. This route saves tokens into Redux store and redirects users to/welcome
.