diff --git a/app/views/login.pug b/app/views/login.pug index 758f4c0..fd7e573 100644 --- a/app/views/login.pug +++ b/app/views/login.pug @@ -1,6 +1,6 @@ html head - title Flitter + title Login | #{_app.name} meta(name="viewport" content="width=device-width, initial-scale=1") link(rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous") script(src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous") @@ -73,19 +73,23 @@ html a.btn.btn-login.btn-light(href="/auth/flitter/login") i.icons.fas.fa-sign-in-alt span Local Login + div + a.btn.btn-login.btn-light(href="/auth/starship_oauth/login") + i.icons.fas.fa-rocket + span Login with Starship CoreID div a.btn.btn-login.btn-light(href="/auth/github_oauth/login") i.icons.fab.fa-github span Login with GitHub - div + //div a.btn.btn-login.btn-light.disabled(href="google.com") i.icons.fab.fa-google span Login with Google - div + //div a.btn.btn-login.btn-light.disabled(href="microsoft.com") i.icons.fab.fa-microsoft span Login with Microsoft - div + //div a.btn.btn-login.btn-light.disabled(href="apple.com") i.icons.fab.fa-apple span Login with Apple diff --git a/app/views/welcome.pug b/app/views/welcome.pug index 7c00660..1fc806b 100644 --- a/app/views/welcome.pug +++ b/app/views/welcome.pug @@ -1,6 +1,6 @@ html head - title Flitter + title Welcome | #{_app.name} style(type="text/css"). @import url('https://fonts.googleapis.com/css?family=Rajdhani'); html, @@ -22,7 +22,7 @@ html } .flitter-name { - font-family: "Rajdhani"; + font-family: "Rajdhani", sans-serif; font-size: 50pt; margin-left: 35px; color: #00323d; @@ -30,7 +30,7 @@ html } .flitter-text { - font-family: "Rajdhani"; + font-family: "Rajdhani", sans-serif; font-size: 24pt; color: #00323d; } @@ -43,4 +43,4 @@ html p.flitter-text Welcome, #{user.uid}! Log out. else .flitter-container - p.flitter-text New to #{_app.name}? Start here. + p.flitter-text New to #{_app.name}? Start here. diff --git a/config/auth.config.js b/config/auth.config.js index 2c2dd6e..2dcc45a 100644 --- a/config/auth.config.js +++ b/config/auth.config.js @@ -98,6 +98,76 @@ const auth_config = { }, }, + starship_oauth: { + type: 'Oauth2Provider', + enable: env('AUTH_COREID_ENABLE', false), + + source_name: env('AUTH_COREID_SOURCE_NAME', 'Starship CoreID'), + source_client_id: env('AUTH_COREID_CLIENT_ID'), + source_client_secret: env('AUTH_COREID_CLIENT_SECRET'), + + // Login page destination where the user will be redirected to on login + // %c will be interpolated with the client id + // %r will be interpolated with the redirect callback url + // NOTE: This url is the same as the login page - /auth/oauth2/login + source_login_page: env('AUTH_COREID_LOGIN_REDIRECT', 'https://coreid.garrettmills.dev/auth/service/oauth2/authorize?client_id=%c&redirect_uri=%r'), + + // Information about the OAuth2 Callback + callback: { + // URL query parameter name with the authorization_code token + // e.g. ?code=XXXXXXXXXX + token_key: 'code', + }, + + // Information about the endpoint flitter-auth will use to redeem + // the authorization_code token for a bearer token + source_token: { + endpoint: 'https://coreid.garrettmills.dev/auth/service/oauth2/redeem', + + // Field name where the authorization_code token will be specified in the request + token_key: 'code', + + // Field name for the client id + client_id_key: 'client_id', + + // Field name for the client secret + client_secret_key: 'client_secret', + + // Field name for the grant_type ('authorization_type') + grant_type_key: 'grant_type', + + // Field name where the bearer token will be specified in the response + response_token_key: 'access_token', + }, + + // Information about the endpoint flitter-auth will use to get + // user information after it retrieves a bearer token + user_data: { + endpoint: 'https://coreid.garrettmills.dev/api/v1/auth/users/me', + method: 'get', // 'get' or 'post' only + + // In the response data, what key is the user data in? + // e.g. if 'data', then {'data': { ... }} + // Set falsy to assume the data exists in the root: { ... } + data_root: 'data', + + // Value that prefixes the token in the 'Authorization: ' header. + // e.g. 'token ' would mean 'token a0fw93ja0w93ja093wj' + // 'Bearer ' would be 'Bearer 0329j0239dj209j3209jd' + // token_prefix: 'token ', + + // Mapping of user model attributes to OAuth2 return data from the endpoint + // Note that uuid is not allowed, and uid is required + attributes: { + uid: 'username', + first_name: 'first_name', + last_name: 'last_name', + email: 'email', + roles: 'group_ids', + }, + }, + }, + github_oauth: { type: 'Oauth2Provider', enable: env('AUTH_OAUTH2_ENABLE', true), diff --git a/example.env b/example.env index ea62fcb..15d35d5 100644 --- a/example.env +++ b/example.env @@ -22,3 +22,8 @@ AUTH_FLITTER_ENABLE=true #insert client ID for oauth AUTH_OAUTH2_CLIENT_ID= AUTH_OAUTH2_CLIENT_SECRET= + +#starship coreid login config +AUTH_COREID_ENABLE=true +AUTH_COREID_CLIENT_ID= +AUTH_COREID_CLIENT_SECRET= \ No newline at end of file