secret config, rm run script

This commit is contained in:
Paul Liverman III 2018-09-10 06:30:17 -07:00
parent 0c03891fe4
commit 9cbbbd594f
4 changed files with 9 additions and 16 deletions

1
.gitignore vendored
View File

@ -1 +0,0 @@
db/

View File

@ -6,6 +6,12 @@ import Users from require "models"
import api, abort, assert_model from require "helpers"
class extends lapis.Application
[console: "/console/#{config.secret}"]: =>
if Users\count! < 1 or @session.id == 1
return console.make(env: "all")(@)
else
return status: 401, "401 - Unauthorized"
[authenticate: "/0/auth"]: api {
POST: =>
-- find user by name or id if specified
@ -39,6 +45,7 @@ class extends lapis.Application
return name: user.name, id: user.id
}
[name: "/0/:id[%d]"]: api {
GET: =>
if user = Users\find id: @params.id

View File

@ -1,6 +1,7 @@
config = require "lapis.config"
postgres_password = os.getenv "POSTGRES_PASSWORD"
secret_value = os.getenv "SESSION_SECRET"
config "development", ->
postgres ->
@ -10,5 +11,6 @@ config "development", ->
password postgres_password
num_workers 2
code_cache "on"
secret secret_value or "insecure"
digest_rounds 12

15
run
View File

@ -1,15 +0,0 @@
#!/usr/bin/env bash
docker stop passwd0
docker rm passwd0
docker stop passwd-db
docker rm passwd-db
docker network create web
docker network create passwd-db
docker build -t passwd0 .
docker run -d --restart always --name passwd-db --network passwd-db \
-v "$PWD/db":/var/lib/postgresql/data postgres:10.5-alpine
sleep 5 # give Postgres time to start
docker run -d --restart always --name passwd0 --network passwd-db \
passwd0:latest
docker network connect web passwd0