aboutsummaryrefslogtreecommitdiff
path: root/ci/container
diff options
context:
space:
mode:
Diffstat (limited to 'ci/container')
-rw-r--r--ci/container/Dockerfile17
-rw-r--r--ci/container/Taskfile.yaml17
-rw-r--r--ci/container/config-templates/Essentials.Accounts-template.json76
-rw-r--r--ci/container/config-templates/PageRouter-template.json6
-rw-r--r--ci/container/config-templates/SessionProvider-template.json25
-rw-r--r--ci/container/config-templates/SimpleBookmark-template.json35
-rw-r--r--ci/container/config-templates/config-template.json170
-rw-r--r--ci/container/docker-compose.yaml20
-rw-r--r--ci/container/run.sh3
-rw-r--r--ci/container/static/routes.xml46
10 files changed, 27 insertions, 388 deletions
diff --git a/ci/container/Dockerfile b/ci/container/Dockerfile
index 33de6f1..f8cdfa3 100644
--- a/ci/container/Dockerfile
+++ b/ci/container/Dockerfile
@@ -42,28 +42,29 @@ WORKDIR /app
#default to 8080 for TLS on TCP
EXPOSE 8080/tcp
-VOLUME /app/data
-VOLUME /app/ssl
+VOLUME /app/data \
+ /app/ssl \
#expose an assets directory for custom assets install
-VOLUME /app/usr/assets
+ /app/usr/assets
#disable dotnet invariant culture on alpine
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=0
#add helper/required libraries
#ENV VNLIB_SHARED_HEAP_FILE_PATH=/app/lib/libvn_rpmalloc.so not ready yet, still need to debug
-ENV VNLIB_ARGON2_DLL_PATH=/app/lib/libargon2.so
+ENV VNLIB_ARGON2_DLL_PATH=/app/lib/libargon2.so \
+ COMPRESSION_LIB_PATH=/app/lib/libvn_compress.so
#set default env variables
-ENV MAX_BOOKMARKS=5000 \
- REG_TOKEN_DURATION_MIN=360
+ENV MAX_BOOKMARKS=5000 \
+ MAX_CONTENT_LENGTH=5120000 \
+ REG_TOKEN_DURATION_MIN=360 \
+ MAX_LOGIN_ATTEMPS=10
#SQL Config
ENV SQL_LIB_PATH=VNLib.Plugins.Extensions.Sql.SQLite.dll
ENV SQL_CONNECTION_STRING="Data Source=data/simple-bookmark.db;"
-#ACCOUNTS
-ENV MAX_LOGIN_ATTEMPS=10
#HC Vault
ENV HC_VAULT_ADDR="" \
diff --git a/ci/container/Taskfile.yaml b/ci/container/Taskfile.yaml
index 1d52697..40c08ea 100644
--- a/ci/container/Taskfile.yaml
+++ b/ci/container/Taskfile.yaml
@@ -24,18 +24,12 @@ tasks:
HOSTNAME:
sh: echo $HOSTNAME
- #build stage generates the following libraries
- generates:
- - "{{.USER_WORKING_DIR}}/out/libargon2.so"
- - "{{.USER_WORKING_DIR}}/out/libvn_rpmalloc.so"
- - "{{.USER_WORKING_DIR}}/out/libvn_compress.so"
-
cmds:
#build argon2 native library
- cd lib/argon2/ && task && cp build/libargon2.so {{.OUT_DIR}}/libargon2.so
- #build rpmalloc library
- - cd lib/vnlib_rpmalloc/ && task && cp build/libvn_rpmalloc.so {{.OUT_DIR}}/libvn_rpmalloc.so
- #build compression
+ #build rpmalloc library and rewrite to a standard .dll extension
+ - cd lib/vnlib_rpmalloc/ && task && cp build/libvn_rpmalloc.so {{.OUT_DIR}}/libvn_rpmalloc.so
+ #build compression and rewrite to a standard .dll extension
- cd lib/vnlib_compress/ && task && cp build/libvn_compress.so {{.OUT_DIR}}/libvn_compress.so
#create a fresh self-signed cert for the container during build
@@ -76,11 +70,10 @@ tasks:
- powershell -Command "mkdir build, build/app, build/app/config-templates/, build/app/static/ -Force"
#copy the existing linux-x64 build to the build folder, this will be the container base
- powershell -Command "cp -Recurse -Force ../build/linux-x86_64/* build/app/"
- #copy local scripts and config data into the build folder
+ #copy local scripts and raw config templates into the build folder
- powershell -Command "cp -Force run.sh, Taskfile.yaml build/app/"
- powershell -Command "cp -Force Dockerfile, docker-compose.yaml build/"
- - powershell -Command "cp -Force static/* build/app/static/"
- - powershell -Command "cp -Force config-templates/* build/app/config-templates/"
+ - powershell -Command "cp -Force ../config-templates/* build/app/config-templates/"
prune-sql-runtimes:
internal: true
diff --git a/ci/container/config-templates/Essentials.Accounts-template.json b/ci/container/config-templates/Essentials.Accounts-template.json
deleted file mode 100644
index 68568a9..0000000
--- a/ci/container/config-templates/Essentials.Accounts-template.json
+++ /dev/null
@@ -1,76 +0,0 @@
-{
- "debug": ${DEBUG_PLUGINS},
-
- //endpoints
-
- "login_endpoint": {
- "path": "/api/account/login",
- "max_login_attempts": ${MAX_LOGIN_ATTEMPS}, //10 failed attempts in 10 minutes
- "failed_attempt_timeout_sec": 600 //10 minutes
- },
-
- "keepalive_endpoint": {
- "path": "/api/account/keepalive",
- //Regen token every 10 mins along with cookies
- "token_refresh_sec": 600 //10 minutes
- },
-
- "profile_endpoint": {
- "path": "/api/account/profile"
- },
-
- "password_endpoint": {
- "path": "/api/account/reset"
- },
-
- "mfa_endpoint": {
- "path": "/api/account/mfa"
- },
-
- "logout_endpoint": {
- "path": "/api/account/logout"
- },
-
- "pki_auth_endpoint": {
- "path": "/api/account/pki",
- "jwt_time_dif_sec": 30,
- "max_login_attempts": 10,
- "failed_attempt_timeout_sec": 600,
- //Configures the PATCH and DELETE methods to update the user's stored key when logged in
- "enable_key_update": true
- },
-
- //If mfa is defined, configures mfa enpoints and enables mfa logins
- "mfa": {
- "upgrade_expires_secs": 180,
- "nonce_size": 64,
-
- //Defines totp specific arguments
- "totp": {
- "digits": 6,
- "issuer": "Simple-Bookmark",
- "period_secs": 30,
- "algorithm": "sha1",
- "secret_size": 32,
- "window_size": 2
- }
- },
-
- //Defines the included account provider
- "account_security": {
- //Time in seconds before a session is considered expired
- "session_valid_for_sec": 3600,
- //Path/domain for all security cookies
- "cookie_domain": "",
- "cookie_path": "/",
- "status_cookie_name": "li", //front-end cookie name must match to detect login status
- "otp_header_name": "X-Web-Token", //Front-end header name must match
- "otp_time_diff_sec": 30,
- "otp_key_size": 64,
- "pubkey_cookie_name": "client-id",
- "pubkey_signing_key_size": 32,
- "strict_origin": false,
- "strict_path": true, //Can be enabled if front-end is running on the same server
- //"allowed_origins": [""]
- }
-} \ No newline at end of file
diff --git a/ci/container/config-templates/PageRouter-template.json b/ci/container/config-templates/PageRouter-template.json
deleted file mode 100644
index 98dded3..0000000
--- a/ci/container/config-templates/PageRouter-template.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "debug": ${DEBUG_PLUGINS},
- "store": {
- "route_file": "static/routes.xml"
- }
-} \ No newline at end of file
diff --git a/ci/container/config-templates/SessionProvider-template.json b/ci/container/config-templates/SessionProvider-template.json
deleted file mode 100644
index 328f06f..0000000
--- a/ci/container/config-templates/SessionProvider-template.json
+++ /dev/null
@@ -1,25 +0,0 @@
-{
-
- "debug": ${DEBUG_PLUGINS},
-
- //Provider assemblies to load
- "provider_assemblies": [ "VNLib.Plugins.Sessions.VNCache.dll" ],
-
- //Web session provider, valid format for VNCache and also memory sessions
- "web": {
- //Cache system key prefix
- "cache_prefix": "websessions",
- //The session cookie name
- "cookie_name": "sb-session",
- //Size in bytes for generated session ids
- "cookie_size": 40,
- //time (in seconds) a session is valid for
- "valid_for_sec": 3600,
- //The maxium number of connections waiting for the cache server responses
- "max_waiting_connections": 100,
- //Enforce strict cross-origin session checks
- "strict_cors": true,
- ///Enforces strict TLS to help prevent tls downgrades based on stored session variables (privacy note: this can be leaked through brute-forced if session id is stolen)
- "strict_tls_protocol": true
- }
-} \ No newline at end of file
diff --git a/ci/container/config-templates/SimpleBookmark-template.json b/ci/container/config-templates/SimpleBookmark-template.json
deleted file mode 100644
index 8736d8d..0000000
--- a/ci/container/config-templates/SimpleBookmark-template.json
+++ /dev/null
@@ -1,35 +0,0 @@
-{
-
- //Comments are allowed
- "debug": ${DEBUG_PLUGINS}, //Enables obnoxious debug logging
-
- "bm_endpoint": {
-
- "path": "/api/bookmarks", //Path for the bookmarks endpoint
-
- "config": {
- "max_limit": 100, //Max results per page
- "default_limit": 20, //Default results per page
- "user_quota": ${MAX_BOOKMARKS} //Max bookmarks per user
- }
- },
-
- //System website lookup endpoint (aka curl)
- "curl": {
- "path": "/api/lookup",
- "exe_path": "curl", //Path to the curl executable
- "extra_args": [
- "--globoff", //Disables unsafe url globbing
- "--no-keepalive", //Disables keepalive, uneeded for a single lookup request
- "--max-filesize", "100K", //Max file size 100K
- "--max-redirs", "5", //Max redirects 5
- "--location" //Follow redirects
- ]
- },
-
- "registration": {
- "path": "/api/register", //Path for the registration endpoint
- "token_lifetime_mins": ${REG_TOKEN_DURATION_MIN}, //Token lifetime in minutes
- "key_regen_interval_mins": ${REG_TOKEN_DURATION_MIN}0 //Signing key regeneration interval in minutes
- }
-} \ No newline at end of file
diff --git a/ci/container/config-templates/config-template.json b/ci/container/config-templates/config-template.json
deleted file mode 100644
index 0bd0ddb..0000000
--- a/ci/container/config-templates/config-template.json
+++ /dev/null
@@ -1,170 +0,0 @@
-{
-
- //Host application config, config is loaded as a read-only DOM that is available
- //to the host and loaded child plugins, all elements are available to plugins via the 'HostConfig' property
-
- "http": {
- //The defaut HTTP version to being requests with (does not support http/2 yet)
- "default_version": "HTTP/1.1",
- //The maxium size (in bytes) of response messges that will be compressed
- "compression_limit": 512000,
- //Minium response size (in bytes) to compress
- "compression_minimum": 2048,
- //The size of the buffer to use when parsing multipart/form data uploads
- "multipart_max_buf_size": 8192,
- //The maxium ammount of data (in bytes) allows for mulitpart/form data file uploads
- "multipart_max_size": 80240,
- //Absolute maximum size (in bytes) of the request entity body (exludes headers)
- "max_entity_size": 1024000,
- //Keepalive ms for HTTP1.1 keepalive connections
- "keepalive_ms": 1000000,
- //The buffer size to use when parsing headers (also the maxium request header size allowed)
- "header_buf_size": 8128,
- //The maxium number of headers allowed in an HTTP request message
- "max_request_header_count": 50,
- //The maxium number of allowed network connections, before 503s will be issued automatically and connections closed
- "max_connections": 5000,
- //The size in bytes of the buffer to use when writing response messages
- "response_buf_size": 4096,
- //time (in ms) to wait for a response from an active connection in recv mode, before dropping it
- "recv_timeout_ms": 5000,
- //Time in ms to wait for the client to accept transport data before terminating the connection
- "send_timeout_ms": 60000,
- //The size (in bytes) of the buffer used to store all response header data
- "response_header_buf_size": 16384,
- //Max number of file uploads allowed per request
- "max_uploads_per_request": 10
- },
-
- //Compression is installed in the container at lib/ directory along with the native library supporting gzip and brotli
- "compression_lib": "lib/vnlib.net.compression/VNLib.Net.Compression.dll",
-
- //Setup the native lib
- "vnlib.net.compression": {
- "lib_path": "lib/libvn_compress.so",
- "level": 1
- },
-
-
- //Maxium ammount of time a request is allowed to be processed (includes loading or waiting for sessions) before operations will be cancelled and a 503 returned
- "max_execution_time_ms": 20000,
-
- //Collection of objects to define hosts+interfaces to build server listeners from
- "virtual_hosts": [
- {
-
- "trace": ${HTTP_TRACE_ON},
-
- //The interface to bind to, you may not mix TLS and non-TLS connections on the same interface
- "interface": {
- "address": "0.0.0.0",
- "port": 8080
- },
-
- //Collection of "trusted" servers to allow proxy header support from
- "downstream_servers": ${HTTP_DOWNSTREAM_SERVERS},
-
- //The hostname to listen for, "*" as wildcard, and "[system]" as the default hostname for the current machine
- "hostname": "*",
- "path": "dist/",
-
- //A list of file extensions to deny access to, if a resource is requested and has one of the following extensions, a 404 is returned
- "deny_extensions": [ ".ts", ".json", ".htaccess", ".php" ],
- //The default file extensions to append to a resource that does not have a file extension
- "default_files": [ "index.html", "index.htm" ],
-
- //A list of error file objects, files are loaded into memory (and watched for changes) and returned when the specified error code occurs
- "error_files": [],
-
- //The default
- "cache_default_sec": 864000,
-
- "ssl": ${SSL_JSON},
- }
- ],
-
-
- //Defines the directory where plugin's are to be loaded from
- "plugins": {
- //Hot-reload creates collectable assemblies that allow full re-load support in the host application, should only be used for development purposes!
- "hot_reload": false,
- "path": "plugins/",
- "config_dir": "config/",
- "assets": "plugins/assets/"
- },
-
- "sys_log": {
- "path": "data/logs/sys-log.txt",
- "flush_sec": 5,
- "retained_files": 31,
- "file_size_limit": 10485760,
- "interval": "infinite"
- },
-
- "app_log": {
- "path": "data/logs/app-log.txt",
- "flush_sec": 5,
- "retained_files": 31,
- "file_size_limit": 10485760,
- "interval": "infinite"
- },
-
- //HASHICORP VAULT
- "hashicorp_vault": {
- "url": "${HC_VAULT_ADDR}",
- "token": "${HC_VAULT_TOKEN}",
- "trust_certificate": ${HC_VAULT_TRUST_CERT},
- },
-
- //SQL CONFIG
- "sql": {
- "provider": "${SQL_LIB_PATH}",
- "connection_string": "${SQL_CONNECTION_STRING}"
- },
-
- //VNCACHE global config
- //Enable vncache as the providers above rely on the object caching server
- "cache": {
-
- "assembly_name": "${CACHE_ASM_PATH}",
- "url": "${REDIS_CONNECTION_STRING}",
-
- //Max size (in bytes) of allowed data to be stored in each user's session object
- "max_object_size": 8128,
-
- //Request timeout
- "request_timeout_sec": 10,
-
- //Time delay between cluster node discovery
- "discovery_interval_sec": 120,
-
- //Initial nodes to discover from
- "initial_nodes": ${VNCACHE_INITIAL_NODES},
-
- //Disable TLS
- "use_tls": false,
-
- //Setting this value to true will cause the cache store to load a memory-only instance, without remote backing
- "memory_only": ${MEMCACHE_ONLY},
-
- //enable memory cache
- "memory_cache": {
- "buckets": 20,
- "bucket_size": 5000,
- "max_age_sec": 600,
- "refresh_interval_sec": 60,
- "zero_all": false,
- "max_object_size": 8128
- }
- },
-
- "secrets": {
- //Special key used by the loading library for access to the PasswordHashing library to pepper password hashes
- "passwords": "${PASSWORD_PEPPER}",
- "db_password": "${DATABASE_PASSWORD}",
- "client_private_key": "${VNCACHE_CLIENT_PRIVATE_KEY}",
- "cache_public_key": "${VNCACHE_CACHE_PUBLIC_KEY}",
- "redis_password": "${REDIS_PASSWORD}"
- }
-}
-
diff --git a/ci/container/docker-compose.yaml b/ci/container/docker-compose.yaml
index fa6b0aa..4262db6 100644
--- a/ci/container/docker-compose.yaml
+++ b/ci/container/docker-compose.yaml
@@ -19,6 +19,8 @@ services:
environment:
MAX_BOOKMARKS: "5000"
REG_TOKEN_DURATION_MIN: "360" #6 hours
+ MAX_CONTENT_LENGTH: 5120000 #5MB max upload size
+ MAX_LOGIN_ATTEMPS: "10" #max login attempts before user account is locked out
#SQL Config
SQL_LIB_PATH: "VNLib.Plugins.Extensions.Sql.SQLite.dll"
@@ -36,27 +38,25 @@ services:
#at least one node required if MEMCACHE_ONLY is false
VNCACHE_INITIAL_NODES: "[]"
- #Accounts plugin config
- MAX_LOGIN_ATTEMPS: "10"
-
#SECRETS
- #All secrets may be a raw value, read from a file,
- #an environment variable, or a vault path
+ # All secrets may be a raw value, read from a file,
+ # an environment variable, or a vault path
# file://mysecret.txt reads the secret from a file (case sensitive)
# env://MY_SECRET reads the secret from an environment variable (case sensitive)
# vault://kv/data/secret?secret=value reads the value of the mysecret key in the secret/data path
+
PASSWORD_PEPPER: "" #Must be a base64 encoded value, of realtivley any size
- DATABASE_PASSWORD: ""
- REDIS_PASSWORD: ""
+ DATABASE_PASSWORD: "" #overrides the 'Password' field in the SQL connection string
+ REDIS_PASSWORD: "" #only required if using a password protected redis server
#if MEMCACHE_ONLY is false, then the following keys are required to connect to a VNCACHE cluster
VNCACHE_CLIENT_PRIVATE_KEY: ""
VNCACHE_CACHE_PUBLIC_KEY: ""
#HTTP
- HTTP_DOWNSTREAM_SERVERS: '[]' #a comma separated list of downstream ip addresses
- HTTP_TRACE_ON: "false" #enable http trace logging, requires --debug CLI flag
+ HTTP_DOWNSTREAM_SERVERS: '[]' #a comma separated list of downstream (proxy) server ip addresses
+ HTTP_TRACE_ON: "false" #enable http trace logging, requires you to set --debug to SERVER_ARGS variable below
- #Very Verbose plugin logging, required --debug CLI flag, prints literally everything to the logger
+ #Very Verbose plugin logging, required --debug CLI flag, prints literally everything to the logger (it's annoying)
DEBUG_PLUGINS: "false"
SERVER_ARGS: "--setup" #remove the setup flag after you are done setting up the server
diff --git a/ci/container/run.sh b/ci/container/run.sh
index b452f2a..d829509 100644
--- a/ci/container/run.sh
+++ b/ci/container/run.sh
@@ -6,6 +6,9 @@ echo "Generating configuration files"
rm -rf config && mkdir config
+#move the routes xml file to the output config dir
+cp config-templates/routes.xml config/routes.xml
+
#substitude all -template files in the config-templates dir and write them to the config dir
for file in config-templates/*-template.json; do
envsubst < $file > config/$(basename $file -template.json).json
diff --git a/ci/container/static/routes.xml b/ci/container/static/routes.xml
deleted file mode 100644
index 85f9830..0000000
--- a/ci/container/static/routes.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-
-<!--Routes container element holds a collection of route elements-->
-<routes>
- <!--
- Example route configuration for a single page app
- where the tree looks like this:
- / (index.html)
- /assets (assets directory) (css and js files)
-
- Wildcard hosts match all hosts that do not have rules with more specific hosts
- -->
-
- <!--
- Allow assets directory to pass through for all requests, using the Continue routine (1)
-
- Because this route has a more specific path than the catch all route
- it will be processed first
- -->
- <route routine="1" privilege="0">
-
- <!--Wildcard host-->
- <hostname>*</hostname>
-
- <!--All paths that start with /assets/ will be matched-->
- <path>/assets/*</path>
- </route>
-
- <!--Show the index file when navigating to /-->
- <route routine="4" privilege="0">
- <hostname>*</hostname>
- <path>/</path>
- <alternate>index.html</alternate>
- </route>
-
- <!--Redirect all other pages back to the app (homepage)-->
- <route routine="2" privilege="0">
- <hostname>*</hostname>
- <path>/*</path>
- <alternate>/</alternate>
- </route>
-
-
- <!--All routes that do not match will be allowed, this is only / since it does not have a matching rule-->
-
-</routes> \ No newline at end of file