mirror of https://github.com/Requarks/wiki.git
Nicolas Giard
5 years ago
33 changed files with 463 additions and 191 deletions
Split View
Diff Options
-
10client/components/admin/admin-api.vue
-
5client/components/admin/admin-auth.vue
-
41client/components/admin/admin-dev.vue
-
8client/components/admin/admin-general.vue
-
8client/components/admin/admin-groups-edit-permissions.vue
-
2client/components/admin/admin-locale.vue
-
5client/components/admin/admin-logging.vue
-
2client/components/admin/admin-search.vue
-
2client/components/admin/admin-storage.vue
-
10client/components/editor.vue
-
2client/components/editor/editor-markdown.vue
-
4client/graph/admin/auth/auth-mutation-save-strategies.gql
-
1client/scss/app.scss
-
81client/scss/pages/_unauthorized.scss
-
14client/static/svg/icon-delete-shield.svg
-
33client/static/svg/icon-safety-float.svg
-
3client/static/svg/motif-diagonals.svg
-
6client/themes/default/components/page.vue
-
12dev/examples/Dockerfile
-
66dev/examples/docker-compose.yml
-
9server/app/data.yml
-
41server/controllers/common.js
-
88server/core/auth.js
-
2server/core/config.js
-
47server/db/migrations/2.0.0-beta.1.js
-
11server/db/seeds/settings.js
-
7server/graph/resolvers/authentication.js
-
9server/graph/schemas/authentication.graphql
-
5server/master.js
-
72server/middlewares/auth.js
-
15server/models/users.js
-
20server/setup.js
-
13server/views/unauthorized.pug
@ -0,0 +1,81 @@ |
|||
.unauthorized { |
|||
background: linear-gradient(to bottom, darken(mc('blue', '900'), 10%) 0%, mc('red', '500') 100%); |
|||
height: 100%; |
|||
display: flex; |
|||
flex-direction: column; |
|||
justify-content: center; |
|||
align-items: center; |
|||
color: mc('grey', '50'); |
|||
|
|||
&::before { |
|||
content: ''; |
|||
display:block; |
|||
width: 100%; |
|||
height: 100%; |
|||
position: absolute; |
|||
top: 0; |
|||
left: 0; |
|||
background-image: url('../static/svg/motif-diagonals.svg'); |
|||
background-position: center center; |
|||
background-repeat: repeat; |
|||
background-size: 50px; |
|||
z-index: 0; |
|||
opacity: .75; |
|||
animation: onboardingBgReveal 50s linear infinite; |
|||
|
|||
@include keyframes(onboardingBgReveal) { |
|||
0% { |
|||
background-position-y: 0; |
|||
} |
|||
100% { |
|||
background-position-y: -2000px; |
|||
} |
|||
} |
|||
} |
|||
|
|||
&::after { |
|||
content: ''; |
|||
position: absolute; |
|||
background-color: transparent; |
|||
background-image: url('../static/svg/motif-overlay.svg'); |
|||
background-attachment: fixed; |
|||
background-size: cover; |
|||
opacity: .5; |
|||
top: 0; |
|||
left: 0; |
|||
width: 100vw; |
|||
height: 100vh; |
|||
} |
|||
|
|||
&-content { |
|||
display: flex; |
|||
flex-direction: column; |
|||
justify-content: center; |
|||
align-items: center; |
|||
z-index: 2; |
|||
} |
|||
|
|||
img { |
|||
height: 250px; |
|||
margin-bottom: 3rem; |
|||
z-index: 2; |
|||
animation-duration: 2s; |
|||
|
|||
@include until($tablet) { |
|||
height: 200px; |
|||
} |
|||
} |
|||
|
|||
h1 { |
|||
font-size: 1.5rem; |
|||
margin-bottom: 1rem; |
|||
z-index: 2; |
|||
} |
|||
h2 { |
|||
margin-bottom: 3rem; |
|||
z-index: 2; |
|||
} |
|||
.v-btn { |
|||
z-index: 2; |
|||
} |
|||
} |
@ -0,0 +1,14 @@ |
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
|||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> |
|||
<svg width="100%" height="100%" viewBox="0 0 128 128" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:1.41421;"> |
|||
<g> |
|||
<g> |
|||
<path d="M64,116c-0.5,0 -1,-0.1 -1.5,-0.4c-26,-15.4 -41.5,-42.6 -41.5,-72.7l0,-15.1c0,-1.3 0.8,-2.4 2,-2.8l40,-14.8c0.7,-0.2 1.4,-0.2 2.1,0l39.9,14.8c1.2,0.4 2,1.6 2,2.8l0,15.1c0,7.8 -1.1,15.6 -3.2,23.1c-0.4,1.6 -2.1,2.5 -3.7,2.1c-1.6,-0.4 -2.5,-2.1 -2.1,-3.7c2,-6.9 2.9,-14.1 2.9,-21.4l0,-13l-36.9,-13.8l-37,13.7l0,13c0,28 14.4,53.2 38.5,67.5c1.4,0.8 1.9,2.7 1.1,4.1c-0.6,1 -1.6,1.5 -2.6,1.5Z" style="fill:#fff;fill-rule:nonzero;"/> |
|||
<path d="M64,116c-1,0 -2,-0.5 -2.6,-1.5c-0.8,-1.4 -0.4,-3.3 1.1,-4.1c3.2,-1.9 6.3,-4 9.2,-6.3c1.3,-1 3.2,-0.8 4.2,0.5c1,1.3 0.8,3.2 -0.5,4.2c-3.1,2.5 -6.4,4.8 -9.9,6.8c-0.5,0.3 -1,0.4 -1.5,0.4Z" style="fill:#fff;fill-rule:nonzero;"/> |
|||
<path d="M64,101.6c-0.6,0 -1.3,-0.2 -1.8,-0.6c-15.9,-11.7 -26,-29 -28.6,-48.5c-0.2,-1.6 0.9,-3.1 2.6,-3.4c1.6,-0.2 3.1,0.9 3.4,2.6c2.3,17.1 10.9,32.3 24.4,43c15.9,-12.6 25,-31.4 25,-51.9l0,-4.6l-25,-9.2l-27,10c-1.6,0.6 -3.3,-0.2 -3.9,-1.8c-0.6,-1.6 0.2,-3.3 1.8,-3.9l28.1,-10.3c0.7,-0.2 1.4,-0.2 2.1,0l28,10.4c1.2,0.4 2,1.6 2,2.8l0,6.7c0,23.2 -10.6,44.4 -29.2,58.1c-0.6,0.4 -1.3,0.6 -1.9,0.6Z" style="fill:#d0d4d8;fill-rule:nonzero;"/> |
|||
</g> |
|||
<path d="M64,25.8l0,72.8c17.7,-13.1 28,-33.4 28,-55.7l0,-6.7l-28,-10.4Z" style="fill:#d0d4d8;fill-rule:nonzero;"/> |
|||
<path d="M89.857,82.858c7.805,-7.805 20.478,-7.805 28.284,0c7.805,7.805 7.805,20.479 0,28.284c-7.806,7.805 -20.479,7.805 -28.284,0c-7.806,-7.805 -7.806,-20.479 0,-28.284Z" style="fill:#ff5576;"/> |
|||
<path d="M110.9,100l-14,0c-1.7,0 -3,-1.3 -3,-3c0,-1.7 1.3,-3 3,-3l14,0c1.7,0 3,1.3 3,3c0,1.7 -1.3,3 -3,3Z" style="fill:#fff;fill-rule:nonzero;"/> |
|||
</g> |
|||
</svg> |
@ -0,0 +1,33 @@ |
|||
<?xml version="1.0" encoding="iso-8859-1"?> |
|||
<!-- Generator: Adobe Illustrator 22.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> |
|||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Layer_1" x="0px" y="0px" viewBox="0 0 128 128" style="enable-background:new 0 0 128 128;" xml:space="preserve" width="128px" height="128px"> |
|||
<path style="fill:#FFFFFF;" d="M64,14c-27.6,0-50,22.4-50,50s22.4,50,50,50s50-22.4,50-50S91.6,14,64,14z M64,89 c-13.8,0-25-11.2-25-25s11.2-25,25-25s25,11.2,25,25S77.8,89,64,89z"/> |
|||
<g> |
|||
<path style="fill:#FF5576;" d="M14,64c0,6.5,1.2,12.7,3.5,18.4l22.7-10.6C39.4,69.3,39,66.7,39,64c0-9,4.7-16.8,11.8-21.2L40.2,20 C24.6,28.5,14,45,14,64z"/> |
|||
</g> |
|||
<g> |
|||
<path style="fill:#FF5576;" d="M64,14c-6.5,0-12.7,1.2-18.4,3.5l10.6,22.7c2.4-0.8,5.1-1.2,7.8-1.2c9,0,16.8,4.7,21.2,11.8 L108,40.2C99.5,24.6,83,14,64,14z"/> |
|||
</g> |
|||
<path style="fill:#C3DBEA;" d="M55,37.5L52.4,32c-1.9,0.7-3.7,1.6-5.4,2.6l2.5,5.5C51.2,39,53,38.2,55,37.5z"/> |
|||
<g> |
|||
<path style="fill:#FF5576;" d="M64,89c-9,0-16.8-4.7-21.2-11.8L20,87.8c8.5,15.6,25,26.2,44,26.2c6.5,0,12.7-1.2,18.4-3.5 L71.8,87.8C69.3,88.6,66.7,89,64,89z"/> |
|||
</g> |
|||
<g> |
|||
<path style="fill:#FF5576;" d="M114,64c0-6.5-1.2-12.7-3.5-18.4L87.8,56.2c0.8,2.4,1.2,5.1,1.2,7.8c0,9-4.7,16.8-11.8,21.2 L87.8,108C103.4,99.5,114,83,114,64z"/> |
|||
</g> |
|||
<path style="fill:#C3DBEA;" d="M81.1,107.8c1.9-0.7,3.7-1.6,5.4-2.5L84,99.8c-1.7,1-3.6,1.8-5.4,2.5L81.1,107.8z"/> |
|||
<path style="fill:#FFFFFF;" d="M21.5,55.7c-0.3,0-0.5,0-0.8-0.1c-1.6-0.4-2.6-2.1-2.1-3.7c2.5-9.5,7.9-17.9,15.6-24.2 c1.3-1.1,3.2-0.9,4.2,0.4c1.1,1.3,0.9,3.2-0.4,4.2c-6.7,5.5-11.4,12.8-13.6,21.1C24,54.8,22.8,55.7,21.5,55.7z"/> |
|||
<path style="fill:#FFFFFF;" d="M20,67c-0.8,0-1.6-0.3-2.1-0.9c-0.1-0.1-0.3-0.3-0.4-0.4c-0.1-0.2-0.2-0.3-0.3-0.5 c-0.1-0.2-0.1-0.4-0.2-0.6c0-0.2-0.1-0.4-0.1-0.6c0-0.8,0.3-1.6,0.9-2.1c1.1-1.1,3.1-1.1,4.2,0c0.6,0.6,0.9,1.3,0.9,2.1 c0,0.8-0.3,1.6-0.9,2.1C21.6,66.7,20.8,67,20,67z"/> |
|||
<path style="fill:#DB3E64;" d="M33,67c-1.7,0-3-1.3-3-3c0-18.7,15.3-34,34-34c1.7,0,3,1.3,3,3s-1.3,3-3,3c-2.7,0-5.3,2.6-7.8,4.2 c0,0-1.4-1.4-2.9-0.7c-0.9,0.4-1.9,2.9-2.5,3.2l-2.9,1.5C39.8,49.1,36,53.9,36,64C36,65.7,34.7,67,33,67z"/> |
|||
<path style="fill:#FF5576;" d="M56.2,40.2L52.4,32c-1.9,0.7-3.7,1.5-5.4,2.6l3.8,8.2C52.5,41.7,54.3,40.9,56.2,40.2z"/> |
|||
<path style="fill:#DB3E64;" d="M64,111c-1.7,0-3-1.3-3-3s1.3-3,3-3c22.6,0,41-18.4,41-41c0-1.7,1.3-3,3-3s3,1.3,3,3 c0,16.2-8.2,30.5-20.7,39c-1.2,0.8-1.2,4.3-2.4,5c-0.7,0.4-2.7-1.1-3.5-0.8c-1.1,0.5-0.9,2.9-2,3.3c-1.3,0.5-3.8-1.8-5.2-1.4 C73,110.3,68.6,111,64,111z"/> |
|||
<path style="fill:#FF5576;" d="M82.4,110.5c1.9-0.7,3.7-1.6,5.4-2.5L84,99.8c-1.7,1-3.6,1.8-5.4,2.5L82.4,110.5z"/> |
|||
<path style="fill:#444B54;" d="M111,64c0,16.8-8.9,31.6-22.2,39.9c-1.3,0.8-1.8,2.4-1.1,3.8l0,0c0.8,1.6,2.8,2.2,4.3,1.3 c15-9.4,25-26,25-45c0-5.7-0.9-11.3-2.6-16.4c-0.6-1.7-2.5-2.6-4.1-1.8l0,0c-1.4,0.6-2,2.2-1.6,3.7C110.2,54,111,58.9,111,64z"/> |
|||
<path style="fill:#444B54;" d="M64,111c-16.8,0-31.6-8.9-39.9-22.2c-0.8-1.3-2.4-1.8-3.8-1.1l0,0c-1.6,0.8-2.2,2.8-1.3,4.3 c9.4,15,26,25,45,25c5.7,0,11.3-0.9,16.4-2.6c1.7-0.6,2.6-2.5,1.8-4.1l0,0c-0.6-1.4-2.2-2-3.7-1.6C74,110.2,69.1,111,64,111z"/> |
|||
<path style="fill:#444B54;" d="M42,64c0-6.9,3.2-13,8.1-17.1c1.1-0.9,1.5-2.4,0.9-3.6l0,0c-0.8-1.8-3.1-2.3-4.6-1.1 C40.1,47.3,36,55.2,36,64c0,1.9,0.2,3.7,0.5,5.5c0.4,1.9,2.5,2.9,4.2,2.1l0,0c1.2-0.6,1.9-1.9,1.7-3.2C42.1,66.9,42,65.5,42,64z"/> |
|||
<path style="fill:#444B54;" d="M64,42c6.9,0,13,3.2,17.1,8.1c0.9,1.1,2.4,1.5,3.6,0.9l0,0c1.8-0.8,2.3-3.1,1.1-4.6 C80.7,40.1,72.8,36,64,36c-1.9,0-3.7,0.2-5.5,0.5c-1.9,0.4-2.9,2.5-2.1,4.2l0,0c0.6,1.2,1.9,1.9,3.2,1.7C61.1,42.1,62.5,42,64,42z"/> |
|||
<path style="fill:#444B54;" d="M64,86c-6.9,0-13-3.2-17.1-8.1c-0.9-1.1-2.4-1.5-3.6-0.9l0,0c-1.8,0.8-2.3,3.1-1.1,4.6 C47.3,87.9,55.2,92,64,92c1.9,0,3.7-0.2,5.5-0.5c1.9-0.4,2.9-2.5,2.1-4.2l0,0c-0.6-1.2-1.9-1.9-3.2-1.7C66.9,85.9,65.5,86,64,86z"/> |
|||
<path style="fill:#444B54;" d="M86,64c0,6.9-3.2,13-8.1,17.1c-1.1,0.9-1.5,2.4-0.9,3.6l0,0c0.8,1.8,3.1,2.3,4.6,1.1 C87.9,80.7,92,72.8,92,64c0-1.9-0.2-3.7-0.5-5.5c-0.4-1.9-2.5-2.9-4.2-2.1l0,0c-1.2,0.6-1.9,1.9-1.7,3.2C85.9,61.1,86,62.5,86,64z"/> |
|||
<path style="fill:#444B54;" d="M17,64c0-16.8,8.9-31.6,22.2-39.9c1.3-0.8,1.8-2.4,1.1-3.8l0,0c-0.8-1.6-2.8-2.2-4.3-1.3 c-15,9.4-25,26-25,45c0,5.7,0.9,11.3,2.6,16.4c0.6,1.7,2.5,2.6,4.1,1.8l0,0c1.4-0.6,2-2.2,1.6-3.7C17.8,74,17,69.1,17,64z"/> |
|||
<path style="fill:#444B54;" d="M64,17c16.8,0,31.6,8.9,39.9,22.2c0.8,1.3,2.4,1.8,3.8,1.1l0,0c1.6-0.8,2.2-2.8,1.3-4.3 c-9.4-15-26-25-45-25c-5.7,0-11.3,0.9-16.4,2.6c-1.7,0.6-2.6,2.5-1.8,4.1l0,0c0.6,1.4,2.2,2,3.7,1.6C54,17.8,58.9,17,64,17z"/> |
|||
</svg> |
@ -0,0 +1,3 @@ |
|||
<svg width="100%" height="100%" viewBox="0 0 40 40" xmlns="http://www.w3.org/2000/svg"> |
|||
<path d="M40,0l-40,40l0,-20l20,-20l20,0Zm0,40l0,-20l-20,20l20,0Z" fill='#FFFFFF' fill-opacity='0.03' fill-rule='evenodd' /> |
|||
</svg> |
@ -1,12 +0,0 @@ |
|||
FROM requarks/wiki:latest |
|||
|
|||
# Replace with your email address: |
|||
ENV WIKI_ADMIN_EMAIL admin@example.com |
|||
|
|||
WORKDIR /var/wiki |
|||
|
|||
# Replace your-config.yml with the path to your config file: |
|||
ADD your-config.yml config.yml |
|||
|
|||
EXPOSE 3000 |
|||
ENTRYPOINT [ "node", "server" ] |
@ -1,19 +1,53 @@ |
|||
version: '3' |
|||
# -- DEV DOCKER-COMPOSE -- |
|||
# -- DO NOT USE IN PRODUCTION! -- |
|||
|
|||
version: "3" |
|||
services: |
|||
wikidb: |
|||
image: mongo |
|||
expose: |
|||
- '27017' |
|||
command: '--smallfiles --logpath=/dev/null' |
|||
volumes: |
|||
- ./data/mongo:/data/db |
|||
wikijs: |
|||
image: 'requarks/wiki:latest' |
|||
links: |
|||
- wikidb |
|||
ports: |
|||
- '80:3000' |
|||
|
|||
redis: |
|||
image: redis:4-alpine |
|||
logging: |
|||
driver: "none" |
|||
networks: |
|||
- wikinet |
|||
|
|||
db: |
|||
image: postgres:9-alpine |
|||
environment: |
|||
WIKI_ADMIN_EMAIL: admin@example.com |
|||
POSTGRES_DB: wiki |
|||
POSTGRES_PASSWORD: wikijsrocks |
|||
POSTGRES_USER: wikijs |
|||
logging: |
|||
driver: "none" |
|||
volumes: |
|||
- ./config.yml:/var/wiki/config.yml |
|||
- db-data:/var/lib/postgresql/data |
|||
networks: |
|||
- wikinet |
|||
|
|||
wiki: |
|||
image: requarks/wiki:beta |
|||
depends_on: |
|||
- db |
|||
- redis |
|||
environment: |
|||
PORT: 3000 # DO NOT CHANGE! Use ports below to specify listening port. |
|||
DB_TYPE: postgres |
|||
DB_HOST: db |
|||
DB_PORT: 5432 |
|||
DB_USER: wikijs |
|||
DB_PASS: wikijsrocks |
|||
DB_NAME: wiki |
|||
REDIS_HOST: redis |
|||
REDIS_PORT: 6379 |
|||
REDIS_DB: 0 |
|||
REDIS_PASS: '' |
|||
networks: |
|||
- wikinet |
|||
ports: |
|||
- "3000:3000" # <-- replace with "80:3000" to listen on port 80 instead |
|||
|
|||
networks: |
|||
wikinet: |
|||
|
|||
volumes: |
|||
db-data: |
@ -1,11 +0,0 @@ |
|||
exports.seed = (knex, Promise) => { |
|||
return knex('settings') |
|||
.insert([ |
|||
{ key: 'auth', value: {} }, |
|||
{ key: 'features', value: {} }, |
|||
{ key: 'logging', value: {} }, |
|||
{ key: 'site', value: {} }, |
|||
{ key: 'theme', value: {} }, |
|||
{ key: 'uploads', value: {} } |
|||
]) |
|||
} |
@ -1,72 +0,0 @@ |
|||
const jwt = require('jsonwebtoken') |
|||
const moment = require('moment') |
|||
|
|||
const securityHelper = require('../helpers/security') |
|||
|
|||
/* global WIKI */ |
|||
|
|||
/** |
|||
* Authentication middleware |
|||
*/ |
|||
module.exports = { |
|||
jwt(req, res, next) { |
|||
WIKI.auth.passport.authenticate('jwt', {session: false}, async (err, user, info) => { |
|||
if (err) { return next() } |
|||
|
|||
// Expired but still valid within 7 days, just renew
|
|||
if (info instanceof Error && info.name === 'TokenExpiredError' && moment().subtract(14, 'days').isBefore(info.expiredAt)) { |
|||
const jwtPayload = jwt.decode(securityHelper.extractJWT(req)) |
|||
try { |
|||
const newToken = await WIKI.models.users.refreshToken(jwtPayload.id) |
|||
user = newToken.user |
|||
|
|||
// Try headers, otherwise cookies for response
|
|||
if (req.get('content-type') === 'application/json') { |
|||
res.set('new-jwt', newToken.token) |
|||
} else { |
|||
res.cookie('jwt', newToken.token, { expires: moment().add(365, 'days').toDate() }) |
|||
} |
|||
} catch (err) { |
|||
return next() |
|||
} |
|||
} |
|||
|
|||
// JWT is NOT valid
|
|||
if (!user) { return next() } |
|||
|
|||
// JWT is valid
|
|||
req.logIn(user, { session: false }, (err) => { |
|||
if (err) { return next(err) } |
|||
next() |
|||
}) |
|||
})(req, res, next) |
|||
}, |
|||
checkPath(req, res, next) { |
|||
// Is user authenticated ?
|
|||
|
|||
if (!req.isAuthenticated()) { |
|||
if (WIKI.config.public !== true) { |
|||
return res.redirect('/login') |
|||
} else { |
|||
// req.user = rights.guest
|
|||
res.locals.isGuest = true |
|||
} |
|||
} else { |
|||
res.locals.isGuest = false |
|||
} |
|||
|
|||
// Check permissions
|
|||
|
|||
// res.locals.rights = rights.check(req)
|
|||
|
|||
// if (!res.locals.rights.read) {
|
|||
// return res.render('error-forbidden')
|
|||
// }
|
|||
|
|||
// Expose user data
|
|||
|
|||
res.locals.user = req.user |
|||
|
|||
return next() |
|||
} |
|||
} |
@ -0,0 +1,13 @@ |
|||
extends master.pug |
|||
|
|||
block body |
|||
#root.is-fullscreen |
|||
v-app |
|||
.unauthorized |
|||
.unauthorized-content |
|||
img.animated.fadeIn(src='/svg/icon-delete-shield.svg', alt='Unauthorized') |
|||
.headline= t('unauthorized.title') |
|||
.subheading.mt-3= t('unauthorized.action.' + action) |
|||
v-btn.mt-5(color='red lighten-4', href='javascript:window.history.go(-1);', large, outline) |
|||
v-icon(left) arrow_back |
|||
span= t('unauthorized.goback') |
Write
Preview
Loading…
Cancel
Save