From 3abd2f917c020e7a1fa489ffc7f95af072bcb823 Mon Sep 17 00:00:00 2001 From: Nicolas Giard Date: Mon, 8 Oct 2018 00:17:31 -0400 Subject: [PATCH] feat: auth jwt, permissions, login ui (wip) --- Makefile | 2 +- client/client-app.js | 6 +- client/components/common/nav-footer.vue | 28 +- client/components/common/nav-header.vue | 7 +- client/components/login.vue | 459 ++++++------------ .../admin/auth/auth-query-strategies.gql | 2 +- client/graph/login/login-mutation-login.gql | 1 + client/graph/login/login-query-strategies.gql | 5 +- client/scss/app.scss | 3 + client/scss/base/base.scss | 7 + client/scss/base/material.scss | 27 ++ client/scss/layout/_md2.scss | 7 + client/static/svg/auth-icon-auth0.svg | 6 +- client/static/svg/auth-icon-cas.svg | 6 + client/static/svg/auth-icon-oidc.svg | 1 + client/static/svg/auth-icon-okta.svg | 5 + client/static/svg/auth-icon-saml.svg | 5 + client/static/svg/motif-overlay.svg | 17 +- dev/templates/master.pug | 2 +- package.json | 2 + server/controllers/auth.js | 9 +- server/core/auth.js | 44 +- server/db/migrations/2.0.0.js | 19 +- server/graph/directives/auth.js | 54 +++ server/graph/index.js | 7 +- server/graph/resolvers/authentication.js | 6 +- server/graph/schemas/authentication.graphql | 11 +- server/graph/schemas/common.graphql | 4 + server/helpers/security.js | 14 + server/master.js | 17 +- server/middlewares/auth.js | 88 +++- server/models/authentication.js | 8 +- server/models/users.js | 34 +- .../authentication/auth0/definition.yml | 1 + .../authentication/azure/definition.yml | 1 + .../modules/authentication/cas/definition.yml | 1 + .../authentication/discord/definition.yml | 1 + .../authentication/dropbox/definition.yml | 1 + .../authentication/facebook/definition.yml | 1 + .../authentication/github/definition.yml | 1 + .../authentication/google/definition.yml | 1 + .../authentication/ldap/definition.yml | 1 + .../authentication/local/definition.yml | 1 + .../authentication/microsoft/definition.yml | 1 + .../authentication/oauth2/definition.yml | 1 + .../authentication/oidc/definition.yml | 1 + .../authentication/okta/definition.yml | 1 + .../authentication/saml/definition.yml | 1 + .../authentication/slack/definition.yml | 1 + .../authentication/twitch/definition.yml | 1 + server/setup.js | 43 +- server/views/master.pug | 2 +- yarn.lock | 13 +- 53 files changed, 550 insertions(+), 438 deletions(-) create mode 100644 client/scss/layout/_md2.scss create mode 100644 client/static/svg/auth-icon-cas.svg create mode 100644 client/static/svg/auth-icon-oidc.svg create mode 100644 client/static/svg/auth-icon-okta.svg create mode 100644 client/static/svg/auth-icon-saml.svg create mode 100644 server/graph/directives/auth.js diff --git a/Makefile b/Makefile index 726d056a..8ae711c4 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ stop: ## Stop Wiki.js restart: ## Restart Wiki.js node wiki restart -dev: ## Start Wiki.js in development mode +dev-up: ## Start Wiki.js in development mode node wiki dev build: ## Build Wiki.js client assets diff --git a/client/client-app.js b/client/client-app.js index 39d5f3ba..7fe8c56b 100644 --- a/client/client-app.js +++ b/client/client-app.js @@ -22,6 +22,7 @@ import VueMoment from 'vue-moment' import VueTour from 'vue-tour' import VueTreeNavigation from 'vue-tree-navigation' import store from './store' +import Cookies from 'js-cookie' // ==================================== // Load Modules @@ -74,7 +75,10 @@ const graphQLLink = createPersistedQueryLink().concat( options.body = JSON.stringify(body) // Inject authentication token - options.headers.Authorization = `Bearer TODO` + const jwtToken = Cookies.get('jwt') + if (jwtToken) { + options.headers.Authorization = `Bearer ${jwtToken}` + } return fetch(uri, options) } diff --git a/client/components/common/nav-footer.vue b/client/components/common/nav-footer.vue index c4d6a94c..0322c8e7 100644 --- a/client/components/common/nav-footer.vue +++ b/client/components/common/nav-footer.vue @@ -1,14 +1,14 @@ @@ -111,6 +111,7 @@