Authentication

PrairieLearn currently has a few ways to do user authentication.

Google OAuth 2

Take a look in apps/prairielearn/src/pages/authLoginOAuth2/authLoginOAuth2.js and apps/prairielearn/src/pages/authCallbackOAuth2/authCallbackOAuth2.js to get an idea of what variables you need to modify.

To start create a Google Cloud account and then:

  • Click console to login to your console.
  • Create a project then got to APIs & Services.
    • Go to OAuth consent screen and complete the consent form.
    • Proceed to Credentials and create a new OAuth client ID.
    • Select Web application.
    • Under Authorized JavaScript origins, click ADD URI and add in your domain address.
    • Under Authorized redirect URIs, click ADD URI and add https://yourdomain/pl/oauth2callback which is the route to the Google OAuth callback.
    • Click Create which will give you a Client ID and a Client Secret. WARNING: DO NOT UPLOAD THESE KEYS ANYWHERE

Now add the keys to config.json:

{
  "googleClientId": "Your Client ID key",
  "googleClientSecret": "Your Client Secret key",
  "googleRedirectUrl": "https://yourdomain/pl/oauth2callback",
  "hasOauth": true
}

That's it, you should be up and running with Google OAuth 2!

Shibboleth

Take a look in apps/prairielearn/src/pages/authCallbackShib/authCallbackShib.js to get a sense of what headers you will need your reverse proxy to pass.

LTI

Check out the course instance LTI docs to learn more about LTI.