Closed awdeorio closed 2 years ago
I think I figured out how the AG does authentication:
https://autograder.io/api/users/current/
. If the request returns a 401 then it redirects the user to https://accounts.google.com/o/oauth2/...
It gets this URL from the WWW-Authenticate
field of the 401's response header.redirect_uri
and a client_id
. Google does lots of fun stuff to authenticate here.https://autograder.io/api/oauth2callback/
. Included in this request is a query parameter called code
. The AG uses the oauth2client
library to create an OAuth2Credentials
object using that code parameter and the data from a secrets file stored on the AG server.OAuth2Credentials
object it just made to authenticate the request.https://www.django-rest-framework.org/api-guide/authentication/
) to get a token for an existing user or create a token for a new user. It sets a cookie called token
(this is the token we care about).https://developers.google.com/identity/sign-in/web/server-side-flow has a good diagram https://developers.google.com/identity/protocols/oauth2/web-server#userconsentprompt explains the actual login process in use with OAuth 2.0
An initial (and certainly not sustainable) attempt underway in https://github.com/eecs485staff/agio-cli/tree/login-gui
~/.agtoken
It likely will only work if duo is configured to automatically push to a device, or if there is only one device set up with duo (since it tries to push the "Send me a push" button.
I think this is a high priority. A good rule of thumb is that a tool should do something "out of the box". If there's a barrier to getting started, people simply won't use the tool.
This is easy now that there's a new feature on the autograder! From James Perretta:
Alrighty, I just deployed this change along with this semester's major release. You can now go to https://autograder.io/web/__apitoken__ and be prompted to download a file with your token in it. You can also send a DELETE request to the /api/users/current/revoke_api_token/ endpoint to revoke your token. This information is also included in the API documentation (https://autograder.io/api/docs)
The present instructions for obtaining an authentication token are arcane. It would be great if this process were more user friendly.
Note that the autograder uses OAuth2 with Google's SSO.