Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
rudivanhierden committed Aug 25, 2022
2 parents b6eeaf6 + d4b2935 commit 8ddfd7a
Show file tree
Hide file tree
Showing 6 changed files with 18,485 additions and 4,698 deletions.
14 changes: 9 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Nodejs 10.16.0 / alpine 3.9.4
FROM node:10.16.0-alpine
FROM node:16.16.0-alpine

# Label for tracking
LABEL nl.openstad.container="auth" nl.openstad.version="0.0.1-beta" nl.openstad.release-date="2020-05-07"
Expand Down Expand Up @@ -29,7 +28,12 @@ ENV FROM_EMAIL=""


# Install all base dependencies.
RUN apk add --no-cache --update openssl g++ make python musl-dev bash
RUN apk add --no-cache --update openssl g++ make python3 musl-dev bash

# symlink python to python3
RUN ln -s /usr/bin/python3 /usr/bin/python && \
ln -s /usr/bin/pip3 /usr/bin/pip


# Set the working directory to the root of the container
WORKDIR /home/app
Expand All @@ -43,10 +47,10 @@ RUN npm config set unsafe-perm true
# This packages must be installed seperatly to prevent crash
# @since node 10.16
RUN npm install -g node-gyp
RUN npm install bcrypt
RUN npm install bcrypt --legacy-peer-deps

# Install all npm packages
RUN npm install
RUN npm install --legacy-peer-deps

# ----------------------------------------------
RUN npm install knex -g
Expand Down
20 changes: 16 additions & 4 deletions app-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,24 @@ const sessionStore = new MySQLStore({
*/


const mongoCredentials = {
host: process.env.MONGO_DB_HOST || 'localhost',
port: process.env.MONGO_DB_PORT || 27017,
function getMongoDbConnectionString () {
// Allow the connection string builder to be overridden by an environment variable
if (process.env.MONGO_DB_CONNECTION_STRING) {
return process.env.MONGO_DB_CONNECTION_STRING;
}

const host = process.env.MONGO_DB_HOST || 'localhost';
const port = process.env.MONGO_DB_PORT || 27017;
const user = process.env.MONGO_DB_USER || '';
const password = process.env.MONGO_DB_PASSWORD || '';
const authSource = process.env.MONGO_DB_AUTHSOURCE || '';

const useAuth = user && password;

return `mongodb://${useAuth ? `${user}:${password}@` : ''}${host}:${port}/sessions${authSource ? `?authSource=${authSource}` : ''}`;
}

const url = 'mongodb://'+ mongoCredentials.host +':'+mongoCredentials.port+'/sessions';
const url = getMongoDbConnectionString();

const sessionStore = new MongoStore({
url: url,
Expand Down
2 changes: 1 addition & 1 deletion controllers/auth/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const updateUser = async (user, email) => {
}

const getUser = async (email) => {
return new User({email}).fetch();
return new User({email}).fetch();
}

exports.postLogin = async (req, res, next) => {
Expand Down
10 changes: 10 additions & 0 deletions models/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ bookshelf.plugin(jsonColumns);

const Client = bookshelf.Model.extend({
tableName: 'clients',
requireFetch: false,
hasTimestamps: ['createdAt', 'updatedAt'],
jsonColumns: ['authTypes', 'requiredFields'],
getAuthTypes: (model) => {
Expand All @@ -21,38 +22,45 @@ const Client = bookshelf.Model.extend({

const LoginToken = bookshelf.Model.extend({
tableName: 'login_tokens',
requireFetch: false,
hasTimestamps: ['createdAt', 'updatedAt']
});

const AccessToken = bookshelf.Model.extend({
tableName: 'access_tokens',
requireFetch: false,
hasTimestamps: ['createdAt', 'updatedAt']
});

const UniqueCode = bookshelf.Model.extend({
tableName: 'unique_codes',
requireFetch: false,
hasTimestamps: ['createdAt', 'updatedAt']
});

const Role = bookshelf.Model.extend({
tableName: 'roles',
requireFetch: false,
hasTimestamps: ['createdAt', 'updatedAt']
});

const UserRole = bookshelf.Model.extend({
tableName: 'user_roles',
requireFetch: false,
hasTimestamps: ['createdAt', 'updatedAt']
});

const PasswordResetToken = bookshelf.Model.extend({
tableName: 'password_reset_tokens',
requireFetch: false,
hasTimestamps: ['createdAt', 'updatedAt']
});

const userKeysToSanitize = ['firstName', 'lastName', 'email', 'phoneNumber', 'extraData', 'streetName', 'houseNumber', 'city', 'suffix', 'postcode', 'password', 'resetPasswordToken']

const User = bookshelf.Model.extend({
tableName: 'users',
requireFetch: false,
hasTimestamps: ['createdAt', 'updatedAt'],
// jsonColumns: ['extraData'],
roles() {
Expand All @@ -71,11 +79,13 @@ const User = bookshelf.Model.extend({

const ActionLog = bookshelf.Model.extend({
tableName: 'action_log',
requireFetch: false,
hasTimestamps: ['createdAt', 'updatedAt']
});

const ExternalCsrfToken = bookshelf.Model.extend({
tableName: 'external_csrf_tokens',
requireFetch: false,
hasTimestamps: ['createdAt', 'updatedAt']
});

Expand Down
Loading

0 comments on commit 8ddfd7a

Please sign in to comment.