Fully tested the remote database
Added configurable hostname for default account email
This commit is contained in:
@@ -22,6 +22,9 @@ ADMIN_DEFAULT_USERNAME=admin
|
|||||||
# Give this a value to generate the default admin account (must be at least 8 characters)
|
# Give this a value to generate the default admin account (must be at least 8 characters)
|
||||||
ADMIN_DEFAULT_PASSWORD=password
|
ADMIN_DEFAULT_PASSWORD=password
|
||||||
|
|
||||||
|
# Give this a value to generate teh default admin account (must be a valid domain name, to pass the initial email check)
|
||||||
|
ADMIN_DEFAULT_HOSTNAME=example.com
|
||||||
|
|
||||||
# Select a "TZ database name" that suits your needs: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
|
# Select a "TZ database name" that suits your needs: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
|
||||||
DB_TIMEZONE=Australia/Sydney
|
DB_TIMEZONE=Australia/Sydney
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
FROM node:21-bookworm-slim
|
FROM node:22-bookworm-slim
|
||||||
WORKDIR "/app"
|
WORKDIR "/app"
|
||||||
COPY package*.json /app
|
COPY package*.json /app
|
||||||
RUN npm install --production
|
RUN npm install --production
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ This server is available via docker hub at krgamestudios/auth-server.
|
|||||||
|
|
||||||
# Setup
|
# Setup
|
||||||
|
|
||||||
There are multiple ways to run this app - it can run on it's own via `npm start` (for production) or `npm run dev` (for development). it can also run inside docker using `docker-compose up --build` - run `node configure-script.js` to generate docker-compose.yml and startup.sql.
|
There are multiple ways to run this app - it can run on it's own via `npm start` (for production) or `npm run dev` (for development). it can also run inside docker using `docker compose up --build` - run `node configure-script.js` to generate docker-compose.yml and startup.sql.
|
||||||
|
|
||||||
# API
|
# API
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ Cookie: refreshToken
|
|||||||
###
|
###
|
||||||
|
|
||||||
|
|
||||||
//DOCS: Retreives the private account data, results vary
|
//DOCS: Retrieves the private account data, results vary
|
||||||
GET /auth/account
|
GET /auth/account
|
||||||
Authorization: Bearer accessToken
|
Authorization: Bearer accessToken
|
||||||
|
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ const question = (prompt, def = null) => {
|
|||||||
const appMailPhysical = await question('Mail Physical');
|
const appMailPhysical = await question('Mail Physical');
|
||||||
|
|
||||||
const appDefaultUser = await question('App Default User', '');
|
const appDefaultUser = await question('App Default User', '');
|
||||||
|
const appDefaultHost = await question('App Default Host', '');
|
||||||
const appDefaultPass = await question('App Default Pass', '');
|
const appDefaultPass = await question('App Default Pass', '');
|
||||||
|
|
||||||
const appSecretAccess = await question('Access Token Secret', uuid(32));
|
const appSecretAccess = await question('Access Token Secret', uuid(32));
|
||||||
@@ -105,6 +106,7 @@ services:
|
|||||||
- MAIL_PASSWORD=${appMailPass}
|
- MAIL_PASSWORD=${appMailPass}
|
||||||
- MAIL_PHYSICAL=${appMailPhysical}
|
- MAIL_PHYSICAL=${appMailPhysical}
|
||||||
- ADMIN_DEFAULT_USERNAME=${appDefaultUser}
|
- ADMIN_DEFAULT_USERNAME=${appDefaultUser}
|
||||||
|
- ADMIN_DEFAULT_HOSTNAME=${appDefaultHost}
|
||||||
- ADMIN_DEFAULT_PASSWORD=${appDefaultPass}
|
- ADMIN_DEFAULT_PASSWORD=${appDefaultPass}
|
||||||
- SECRET_ACCESS=${appSecretAccess}
|
- SECRET_ACCESS=${appSecretAccess}
|
||||||
- SECRET_REFRESH=${appSecretRefresh}
|
- SECRET_REFRESH=${appSecretRefresh}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ module.exports = async () => {
|
|||||||
await sequelize.sync(); //this whole file is just one big BUGFIX
|
await sequelize.sync(); //this whole file is just one big BUGFIX
|
||||||
|
|
||||||
//validate env variables
|
//validate env variables
|
||||||
if (!process.env.ADMIN_DEFAULT_USERNAME || !process.env.ADMIN_DEFAULT_PASSWORD) {
|
if (!process.env.ADMIN_DEFAULT_USERNAME || !process.env.ADMIN_DEFAULT_HOSTNAME || !process.env.ADMIN_DEFAULT_PASSWORD) {
|
||||||
//skip this if arguments are missing
|
//skip this if arguments are missing
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -25,9 +25,8 @@ module.exports = async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (adminRecord == null) {
|
if (adminRecord == null) {
|
||||||
const webAddress = process.env.WEB_ADDRESS == 'localhost:3000' ? 'example.com' : process.env.WEB_ADDRESS; //can't log in as "localhost"
|
|
||||||
await accounts.create({
|
await accounts.create({
|
||||||
email: `${process.env.ADMIN_DEFAULT_USERNAME}@${webAddress}`,
|
email: `${process.env.ADMIN_DEFAULT_USERNAME}@${process.env.ADMIN_DEFAULT_HOSTNAME}`,
|
||||||
username: `${process.env.ADMIN_DEFAULT_USERNAME}`,
|
username: `${process.env.ADMIN_DEFAULT_USERNAME}`,
|
||||||
hash: await bcrypt.hash(`${process.env.ADMIN_DEFAULT_PASSWORD}`, await bcrypt.genSalt(11)),
|
hash: await bcrypt.hash(`${process.env.ADMIN_DEFAULT_PASSWORD}`, await bcrypt.genSalt(11)),
|
||||||
type: 'normal',
|
type: 'normal',
|
||||||
@@ -35,6 +34,6 @@ module.exports = async () => {
|
|||||||
mod: true
|
mod: true
|
||||||
});
|
});
|
||||||
|
|
||||||
console.warn(`Created default admin account (email: ${process.env.ADMIN_DEFAULT_USERNAME}@${webAddress}; password: ${process.env.ADMIN_DEFAULT_PASSWORD})`);
|
console.warn(`Created default admin account (email: ${process.env.ADMIN_DEFAULT_USERNAME}@${process.env.ADMIN_DEFAULT_HOSTNAME}; password: ${process.env.ADMIN_DEFAULT_PASSWORD})`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#use this while debugging
|
#use this while debugging
|
||||||
CREATE DATABASE IF NOT EXISTS auth;
|
CREATE DATABASE auth;
|
||||||
CREATE USER IF NOT EXISTS 'auth'@'%' IDENTIFIED BY 'charizard';
|
CREATE USER 'auth'@'%' IDENTIFIED BY 'charizard';
|
||||||
GRANT ALL PRIVILEGES ON auth.* TO 'auth'@'%';
|
GRANT ALL PRIVILEGES ON auth.* TO 'auth'@'%';
|
||||||
|
|||||||
Reference in New Issue
Block a user