Maintenance commit Sat Jan 5 01:10:23 EET 2019

This commit is contained in:
Evert Prants 2019-01-05 01:10:23 +02:00
parent 681905b0a7
commit 913309c7ab
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
11 changed files with 64 additions and 46 deletions

View File

@ -2,28 +2,20 @@
Icy Network Primary Web Application - Authentication and News
## About Icy Network
Icy Network is a community network aimed at anyone who likes friendly discussions and playing multiplayer games, such as Minecraft.
Icy Network is a SSO (Single-Sign On) service provider - for communities. This application is used for authentication services such as OAuth2 in order to unite our websites with a single login and as a central news outlet for Icy Network services.
### Currently IcyNet-managed community platforms
* mc.icynet.eu - Minecraft Server
* [Discord server](https://discord.gg/Xe7MKSx)
* icynet.ml - IRC Network
## Requirements
* [Node.js](https://nodejs.org/en/)
* A running instance of [Redis](https://redis.io/)
* A database of your choice. See [knex installation](https://knexjs.org/#Installation-node) for a list of supported database drivers.
More to come!
## The Goal of this Application
This application is used for authentication services such as OAuth2 in order to unite our websites with a single login and as a central news outlet for Icy Network services.
## Setup
The first time you run the application, it will migrate the database and that may take a while. **You will also need a running instance of `redis-server` for session storage!**
### Development
1. Clone this repository and `cd` into it
2. `npm install` - Get all the dependencies
3. `cp config.example.toml config.toml` - Copy the configuration
4. `npm run watch` - Run the style and front-end script watch task
5. `npm start -- -d` - Start the application in development mode
3. `cp config.example.toml config.toml && $EDITOR config.toml` - Copy the configuration (and edit it)
4. `npm run watch` - Run the server and front-end watch task, which also starts the application in development mode
There is also a watch mode for the server. To enable `server` file tree watching you must provide both `-d` and `-w` as parameters. This task will reset all workers when any file in the `server` directory changes, enabling for live debugging.
You can run the application in development mode using `npm start -- -d` if you do not need the watch tasks.
### Production
1. `npm run build` - Build the front-end

View File

@ -1,2 +0,0 @@
#!/bin/bash
./node_modules/.bin/concurrently --kill-others "npm run watch" "npm run start -- -d -w"

View File

@ -1,6 +0,0 @@
#!/bin/bash
npm install
cp config.example.toml config.toml
$EDITOR config.toml
echo "Run the program with `./development` in development mode or build the project"
echo "using `npm run build` and then `npm start` for production!"

38
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "icynet.eu",
"version": "0.9.1",
"version": "0.9.3",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -1292,11 +1292,18 @@
"dev": true
},
"basic-auth": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.0.tgz",
"integrity": "sha1-AV2z81PgLlY3d1X5YnQuiYHnu7o=",
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz",
"integrity": "sha512-NF+epuEdnUYVlGuhaxbbq+dvJttwLnGY+YixlXlME5KpQ5W3CnXA5cVTneY3SPbPDRkcjMbifrwmFYcClgOZeg==",
"requires": {
"safe-buffer": "5.1.1"
"safe-buffer": "5.1.2"
},
"dependencies": {
"safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
}
}
},
"bcrypt-pbkdf": {
@ -5722,9 +5729,9 @@
"integrity": "sha1-4gD/TdgjcX+OBWOzLj9UgfyiYrI="
},
"merge": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/merge/-/merge-1.2.0.tgz",
"integrity": "sha1-dTHjnUlJwoGma4xabgJl6LBYlNo=",
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/merge/-/merge-1.2.1.tgz",
"integrity": "sha512-VjFo4P5Whtj4vsLzsYBu5ayHhoHJ0UqNm7ibvShmbmoz7tGi0vXaoJbGdB+GmDMLUdg8DpQXEIeVDAe8MaABvQ==",
"dev": true
},
"merge-descriptors": {
@ -5880,15 +5887,22 @@
}
},
"morgan": {
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/morgan/-/morgan-1.9.0.tgz",
"integrity": "sha1-0B+mxlhZt2/PMbPLU6OCGjEdgFE=",
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/morgan/-/morgan-1.9.1.tgz",
"integrity": "sha512-HQStPIV4y3afTiCYVxirakhlCfGkI161c76kKFca7Fk1JusM//Qeo1ej2XaMniiNeaZklMVrh3vTtIzpzwbpmA==",
"requires": {
"basic-auth": "~2.0.0",
"debug": "2.6.9",
"depd": "~1.1.1",
"depd": "~1.1.2",
"on-finished": "~2.3.0",
"on-headers": "~1.0.1"
},
"dependencies": {
"depd": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz",
"integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak="
}
}
},
"move-concurrently": {

View File

@ -1,6 +1,6 @@
{
"name": "icynet.eu",
"version": "0.9.2",
"version": "0.9.3",
"description": "Icy Network web server",
"main": "icynet.eu.js",
"scripts": {
@ -26,9 +26,9 @@
"author": "Icy Network",
"license": "MIT",
"bugs": {
"url": "https://github.com/IcyNet/IcyNet.eu/issues"
"url": "https://gitlab.icynet.eu/IcyNetwork/issues"
},
"homepage": "https://github.com/IcyNet/IcyNet.eu#readme",
"homepage": "https://icynet.eu",
"dependencies": {
"babel-core": "^6.26.3",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
@ -66,7 +66,7 @@
"concurrently": "^3.6.0",
"eslint-plugin-import": "^2.13.0",
"jquery": "^3.3.1",
"morgan": "^1.9.0",
"morgan": "^1.9.1",
"mustache": "^2.3.0",
"popper.js": "^1.14.3",
"standard": "^10.0.3",

View File

@ -10,7 +10,7 @@ function HTTP_GET (link, headers = {}, lback) {
port: parsed.port,
path: parsed.path,
headers: {
'User-Agent': 'Squeebot/Commons-2.0.0',
'User-Agent': 'Icy Network Back-end (icynet.eu)',
'Accept': '*/*',
'Accept-Language': 'en-GB,enq=0.5'
}
@ -72,7 +72,7 @@ function HTTP_POST (link, headers = {}, data) {
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': Buffer.byteLength(postData),
'User-Agent': 'Squeebot/Commons-2.0.0'
'User-Agent': 'Icy Network Back-end (icynet.eu)'
}
}

View File

@ -53,13 +53,21 @@ console.error = function () {
async function initializeLogger () {
let logPath = path.resolve(config.logger.file)
// Only throw bad permission errors
try {
await fs.access(logPath, fs.W_OK)
} catch (e) {
if (e.code !== 'ENOENT') throw e
}
try {
lfs = fs.createWriteStream(logPath, {flags: 'a'})
} catch (e) {
lfs = null
console.error('Failed to initiate log file write stream')
console.error(e.stack)
// Rethrow error
throw e
}
}
@ -78,5 +86,5 @@ module.exports = function () {
// Create log file write stream
if (!config.logger || !config.logger.write) return
initializeLogger()
initializeLogger().catch((e) => console.error(e))
}

View File

@ -195,6 +195,7 @@ apiRouter.get('/search/users', wrap(async (req, res) => {
* OAuth2 Data
* ===============
*/
apiRouter.get('/clients', wrap(async (req, res) => {
let page = parseInt(req.query.page)
if (isNaN(page) || page < 1) {

View File

@ -96,6 +96,7 @@ router.use('/oauth2', oauthRouter)
RENDER VIEWS
================
*/
router.get('/', (req, res) => {
res.render('index')
})
@ -833,7 +834,7 @@ router.use('/api', apiRouter)
router.use('/admin', adminRouter)
/*
NO ROUTES BEYOND THIS POINT
FALLBACK ROUTES BEYOND THIS POINT
*/
// Handle 'Failed to lookup view' errors

View File

@ -16,7 +16,7 @@
.form-group
label(for="privilege") Privilege
input(type="range" min="0" max="5" step="1" id="privilege" name="privilege" v-model="nw_privilege")
span {{ nw_privilege }}
span#priv-num {{ nw_privilege }}
.form-check
input.form-check-input(type="checkbox" id="activated" name="activated" v-model="activated")
label.form-check-label(for="activated") Activated

View File

@ -34,6 +34,7 @@ body
.list-item
background-color: #f5f5f5
padding: 10px
flex-wrap: nowrap
&:nth-child(even)
background-color: #fff
@ -165,3 +166,12 @@ body
form
.message
display: none
#priv-num
padding: 0 4px
vertical-align: top
input[type=range]
display: inline-block
margin: 0 15px
vertical-align: top