Setup Backend & Basic Auth
This commit is contained in:
13
.gitignore
vendored
Normal file
13
.gitignore
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
# Virtuoso files /data/db
|
||||
/data/db/*
|
||||
!/data/db/virtuoso.ini
|
||||
!/data/db/toLoad
|
||||
!/data/db/toLoad/*
|
||||
/data/files/*
|
||||
docker-compose.override.yml
|
||||
.idea
|
||||
*.iml
|
||||
|
||||
/data/elasticsearch/**
|
||||
/tmp
|
||||
.DS_STORE
|
||||
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
19
README.md
Normal file
19
README.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# Contact Hub
|
||||
|
||||
Backend for the Contact Hub application based on the mu.semte.ch microservices stack.
|
||||
|
||||
## How to
|
||||
|
||||
### Boot up the system in DEV environment
|
||||
|
||||
cd /path/to/mu-project
|
||||
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up
|
||||
|
||||
You can shut down using `docker-compose stop` and remove everything using `docker-compose rm`.
|
||||
|
||||
|
||||
## Change default username/password
|
||||
|
||||
By default, username/password is equal to root/root. To change it:
|
||||
|
||||
`docker run --rm --entrypoint htpasswd registry:2.7.0 -bn root root > ./config/proxy/nginx.htpasswd`
|
||||
30
config/authorization/config.ex
Normal file
30
config/authorization/config.ex
Normal file
@@ -0,0 +1,30 @@
|
||||
alias Acl.Accessibility.Always, as: AlwaysAccessible
|
||||
alias Acl.GraphSpec.Constraint.Resource, as: ResourceConstraint
|
||||
alias Acl.GraphSpec.Constraint.ResourceFormat, as: ResourceFormatConstraint
|
||||
alias Acl.Accessibility.ByQuery, as: AccessByQuery
|
||||
alias Acl.GraphSpec, as: GraphSpec
|
||||
alias Acl.GroupSpec, as: GroupSpec
|
||||
alias Acl.GroupSpec.GraphCleanup, as: GraphCleanup
|
||||
|
||||
defmodule Acl.UserGroups.Config do
|
||||
def user_groups do
|
||||
[
|
||||
%GroupSpec{
|
||||
name: "public",
|
||||
useage: [:read],
|
||||
access: %AlwaysAccessible{},
|
||||
graphs: [ %GraphSpec{
|
||||
graph: "http://mu.semte.ch/graphs/public",
|
||||
constraint: %ResourceConstraint{
|
||||
resource_types: [
|
||||
# todo add classes
|
||||
]
|
||||
} } ] },
|
||||
%GraphCleanup{
|
||||
originating_graph: "http://mu.semte.ch/application",
|
||||
useage: [:read, :write],
|
||||
name: "clean"
|
||||
}
|
||||
]
|
||||
end
|
||||
end
|
||||
256
config/db/virtuoso.ini
Executable file
256
config/db/virtuoso.ini
Executable file
@@ -0,0 +1,256 @@
|
||||
;
|
||||
; virtuoso.ini
|
||||
;
|
||||
; Configuration file for the OpenLink Virtuoso VDBMS Server
|
||||
;
|
||||
; To learn more about this product, or any other product in our
|
||||
; portfolio, please check out our web site at:
|
||||
;
|
||||
; http://virtuoso.openlinksw.com/
|
||||
;
|
||||
; or contact us at:
|
||||
;
|
||||
; general.information@openlinksw.com
|
||||
;
|
||||
; If you have any technical questions, please contact our support
|
||||
; staff at:
|
||||
;
|
||||
; technical.support@openlinksw.com
|
||||
;
|
||||
|
||||
;
|
||||
; Database setup
|
||||
;
|
||||
[Database]
|
||||
DatabaseFile = /usr/local/virtuoso-opensource/var/lib/virtuoso/db/virtuoso.db
|
||||
ErrorLogFile = /usr/local/virtuoso-opensource/var/lib/virtuoso/db/virtuoso.log
|
||||
LockFile = /usr/local/virtuoso-opensource/var/lib/virtuoso/db/virtuoso.lck
|
||||
TransactionFile = /usr/local/virtuoso-opensource/var/lib/virtuoso/db/virtuoso.trx
|
||||
xa_persistent_file = /usr/local/virtuoso-opensource/var/lib/virtuoso/db/virtuoso.pxa
|
||||
ErrorLogLevel = 7
|
||||
FileExtend = 200
|
||||
MaxCheckpointRemap = 2000
|
||||
Striping = 0
|
||||
TempStorage = TempDatabase
|
||||
|
||||
|
||||
[TempDatabase]
|
||||
DatabaseFile = /usr/local/virtuoso-opensource/var/lib/virtuoso/db/virtuoso-temp.db
|
||||
TransactionFile = /usr/local/virtuoso-opensource/var/lib/virtuoso/db/virtuoso-temp.trx
|
||||
MaxCheckpointRemap = 2000
|
||||
Striping = 0
|
||||
|
||||
|
||||
;
|
||||
; Server parameters
|
||||
;
|
||||
[Parameters]
|
||||
ServerPort = 1111
|
||||
LiteMode = 0
|
||||
DisableUnixSocket = 1
|
||||
DisableTcpSocket = 0
|
||||
;SSLServerPort = 2111
|
||||
;SSLCertificate = cert.pem
|
||||
;SSLPrivateKey = pk.pem
|
||||
;X509ClientVerify = 0
|
||||
;X509ClientVerifyDepth = 0
|
||||
;X509ClientVerifyCAFile = ca.pem
|
||||
MaxClientConnections = 10
|
||||
CheckpointInterval = 60
|
||||
O_DIRECT = 0
|
||||
TraceOn = errors ; log errors
|
||||
TransactionAfterImageLimit = 150000000 ; max 150MB transaction, total transient consumption is 450MB (roll forward + roll back)
|
||||
CaseMode = 2
|
||||
MaxStaticCursorRows = 5000
|
||||
CheckpointAuditTrail = 0
|
||||
AllowOSCalls = 0
|
||||
SchedulerInterval = 10
|
||||
DirsAllowed = ., /usr/local/virtuoso-opensource/share/virtuoso/vad
|
||||
ThreadCleanupInterval = 10
|
||||
ThreadThreshold = 10
|
||||
ResourcesCleanupInterval = 10
|
||||
FreeTextBatchSize = 100000
|
||||
SingleCPU = 0
|
||||
VADInstallDir = /usr/local/virtuoso-opensource/share/virtuoso/vad/
|
||||
PrefixResultNames = 0
|
||||
RdfFreeTextRulesSize = 100
|
||||
IndexTreeMaps = 256
|
||||
MaxMemPoolSize = 200000000
|
||||
PrefixResultNames = 0
|
||||
MacSpotlight = 0
|
||||
IndexTreeMaps = 64
|
||||
MaxQueryMem = 2G ; memory allocated to query processor
|
||||
VectorSize = 1000 ; initial parallel query vector (array of query operations) size
|
||||
MaxVectorSize = 1000000 ; query vector size threshold.
|
||||
AdjustVectorSize = 1
|
||||
ThreadsPerQuery = 4
|
||||
AsyncQueueMaxThreads = 10
|
||||
;;
|
||||
;; When running with large data sets, one should configure the Virtuoso
|
||||
;; process to use between 2/3 to 3/5 of free system memory and to stripe
|
||||
;; storage on all available disks.
|
||||
;;
|
||||
;; Uncomment next two lines if there is 2 GB system memory free
|
||||
NumberOfBuffers = 170000
|
||||
MaxDirtyBuffers = 130000
|
||||
;; Uncomment next two lines if there is 4 GB system memory free
|
||||
;NumberOfBuffers = 340000
|
||||
; MaxDirtyBuffers = 250000
|
||||
;; Uncomment next two lines if there is 8 GB system memory free
|
||||
;NumberOfBuffers = 680000
|
||||
;MaxDirtyBuffers = 500000
|
||||
;; Uncomment next two lines if there is 16 GB system memory free
|
||||
;NumberOfBuffers = 1360000
|
||||
;MaxDirtyBuffers = 1000000
|
||||
;; Uncomment next two lines if there is 32 GB system memory free
|
||||
;NumberOfBuffers = 2720000
|
||||
;MaxDirtyBuffers = 2000000
|
||||
;; Uncomment next two lines if there is 48 GB system memory free
|
||||
;NumberOfBuffers = 4000000
|
||||
;MaxDirtyBuffers = 3000000
|
||||
;; Uncomment next two lines if there is 64 GB system memory free
|
||||
;NumberOfBuffers = 5450000
|
||||
;MaxDirtyBuffers = 4000000
|
||||
|
||||
|
||||
[HTTPServer]
|
||||
ServerPort = 8890
|
||||
ServerRoot = /usr/local/virtuoso-opensource/var/lib/virtuoso/vsp
|
||||
MaxClientConnections = 10
|
||||
DavRoot = DAV
|
||||
EnabledDavVSP = 0
|
||||
HTTPProxyEnabled = 0
|
||||
TempASPXDir = 0
|
||||
DefaultMailServer = localhost:25
|
||||
ServerThreads = 10
|
||||
MaxKeepAlives = 10
|
||||
KeepAliveTimeout = 10
|
||||
MaxCachedProxyConnections = 10
|
||||
ProxyConnectionCacheTimeout = 15
|
||||
HTTPThreadSize = 280000
|
||||
HttpPrintWarningsInOutput = 0
|
||||
Charset = UTF-8
|
||||
;;HTTPLogFile = http.log
|
||||
MaintenancePage = atomic.html
|
||||
EnabledGzipContent = 1
|
||||
|
||||
|
||||
[AutoRepair]
|
||||
BadParentLinks = 0
|
||||
|
||||
[Client]
|
||||
SQL_PREFETCH_ROWS = 100
|
||||
SQL_PREFETCH_BYTES = 16000
|
||||
SQL_QUERY_TIMEOUT = 0
|
||||
SQL_TXN_TIMEOUT = 0
|
||||
;SQL_NO_CHAR_C_ESCAPE = 1
|
||||
;SQL_UTF8_EXECS = 0
|
||||
;SQL_NO_SYSTEM_TABLES = 0
|
||||
;SQL_BINARY_TIMESTAMP = 1
|
||||
;SQL_ENCRYPTION_ON_PASSWORD = -1
|
||||
|
||||
[VDB]
|
||||
ArrayOptimization = 0
|
||||
NumArrayParameters = 10
|
||||
VDBDisconnectTimeout = 1000
|
||||
KeepConnectionOnFixedThread = 0
|
||||
|
||||
[Replication]
|
||||
ServerName = db-D602566B774E
|
||||
ServerEnable = 1
|
||||
QueueMax = 50000
|
||||
|
||||
|
||||
;
|
||||
; Striping setup
|
||||
;
|
||||
; These parameters have only effect when Striping is set to 1 in the
|
||||
; [Database] section, in which case the DatabaseFile parameter is ignored.
|
||||
;
|
||||
; With striping, the database is spawned across multiple segments
|
||||
; where each segment can have multiple stripes.
|
||||
;
|
||||
; Format of the lines below:
|
||||
; Segment<number> = <size>, <stripe file name> [, <stripe file name> .. ]
|
||||
;
|
||||
; <number> must be ordered from 1 up.
|
||||
;
|
||||
; The <size> is the total size of the segment which is equally divided
|
||||
; across all stripes forming the segment. Its specification can be in
|
||||
; gigabytes (g), megabytes (m), kilobytes (k) or in database blocks
|
||||
; (b, the default)
|
||||
;
|
||||
; Note that the segment size must be a multiple of the database page size
|
||||
; which is currently 8k. Also, the segment size must be divisible by the
|
||||
; number of stripe files forming the segment.
|
||||
;
|
||||
; The example below creates a 200 meg database striped on two segments
|
||||
; with two stripes of 50 meg and one of 100 meg.
|
||||
;
|
||||
; You can always add more segments to the configuration, but once
|
||||
; added, do not change the setup.
|
||||
;
|
||||
[Striping]
|
||||
Segment1 = 100M, db-seg1-1.db, db-seg1-2.db
|
||||
Segment2 = 100M, db-seg2-1.db
|
||||
;...
|
||||
|
||||
;[TempStriping]
|
||||
;Segment1 = 100M, db-seg1-1.db, db-seg1-2.db
|
||||
;Segment2 = 100M, db-seg2-1.db
|
||||
;...
|
||||
|
||||
;[Ucms]
|
||||
;UcmPath = <path>
|
||||
;Ucm1 = <file>
|
||||
;Ucm2 = <file>
|
||||
;...
|
||||
|
||||
|
||||
[Zero Config]
|
||||
ServerName = virtuoso (D602566B774E)
|
||||
;ServerDSN = ZDSN
|
||||
;SSLServerName =
|
||||
;SSLServerDSN =
|
||||
|
||||
|
||||
[Mono]
|
||||
;MONO_TRACE = Off
|
||||
;MONO_PATH = <path_here>
|
||||
;MONO_ROOT = <path_here>
|
||||
;MONO_CFG_DIR = <path_here>
|
||||
;virtclr.dll =
|
||||
|
||||
|
||||
[URIQA]
|
||||
DynamicLocal = 0
|
||||
DefaultHost = localhost:8890
|
||||
|
||||
|
||||
[SPARQL]
|
||||
;ExternalQuerySource = 1
|
||||
;ExternalXsltSource = 1
|
||||
;DefaultGraph = http://localhost:8890/dataspace
|
||||
;ImmutableGraphs = http://localhost:8890/dataspace
|
||||
ResultSetMaxRows = 10000
|
||||
MaxQueryCostEstimationTime = 400 ; in seconds
|
||||
MaxQueryExecutionTime = 60 ; in seconds
|
||||
DefaultQuery = select distinct ?Concept where {[] a ?Concept} LIMIT 100
|
||||
DeferInferenceRulesInit = 0 ; controls inference rules loading
|
||||
;PingService = http://rpc.pingthesemanticweb.com/
|
||||
|
||||
|
||||
[Plugins]
|
||||
LoadPath = /usr/local/virtuoso-opensource/lib/virtuoso/hosting
|
||||
;Load1 = plain, wikiv
|
||||
;Load2 = plain, mediawiki
|
||||
;Load3 = plain, creolewiki
|
||||
;Load4 = plain, im
|
||||
;Load5 = plain, wbxml2
|
||||
;Load6 = plain, hslookup
|
||||
;Load7 = attach, libphp5.so
|
||||
;Load8 = Hosting, hosting_php.so
|
||||
;Load9 = Hosting,hosting_perl.so
|
||||
;Load10 = Hosting,hosting_python.so
|
||||
;Load11 = Hosting,hosting_ruby.so
|
||||
;Load12 = msdtc,msdtc_sample
|
||||
21
config/dispatcher/dispatcher.ex
Normal file
21
config/dispatcher/dispatcher.ex
Normal file
@@ -0,0 +1,21 @@
|
||||
defmodule Dispatcher do
|
||||
use Matcher
|
||||
|
||||
define_accept_types [
|
||||
html: ["text/html", "application/xhtml+html"],
|
||||
json: ["application/json", "application/vnd.api+json"],
|
||||
upload: ["multipart/form-data"],
|
||||
any: [ "*/*" ],
|
||||
]
|
||||
|
||||
define_layers [ :api, :frontend, :not_found ]
|
||||
|
||||
###############################################################
|
||||
# errors
|
||||
###############################################################
|
||||
match "/*_path", %{ accept: [:any], layer: :not_found} do
|
||||
send_resp( conn, 404, "{\"error\": {\"code\": 404}")
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
2
config/proxy/nginx.htpasswd
Normal file
2
config/proxy/nginx.htpasswd
Normal file
@@ -0,0 +1,2 @@
|
||||
root:$apr1$x9yMUyVV$w2FZk76C0mbKOlDHdLDV30
|
||||
|
||||
24
config/proxy/web.conf
Normal file
24
config/proxy/web.conf
Normal file
@@ -0,0 +1,24 @@
|
||||
events {
|
||||
|
||||
}
|
||||
|
||||
http {
|
||||
server {
|
||||
listen 80 default_server;
|
||||
listen [::]:80 default_server;
|
||||
server_name dev.contacthub.lblod.info;
|
||||
|
||||
location / {
|
||||
auth_basic "Contact Hub realm";
|
||||
auth_basic_user_file /etc/nginx/conf.d/nginx.htpasswd;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-For $remote_addr;
|
||||
proxy_pass http://identifier;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
0
data/db/virtuoso.ini
Executable file
0
data/db/virtuoso.ini
Executable file
12
docker-compose.dev.yml
Normal file
12
docker-compose.dev.yml
Normal file
@@ -0,0 +1,12 @@
|
||||
version: '3.4'
|
||||
|
||||
services:
|
||||
web:
|
||||
ports:
|
||||
- "80:80"
|
||||
triplestore:
|
||||
ports:
|
||||
- "8890:8890"
|
||||
environment:
|
||||
ENABLE_ENDPOINT_SELECTOR: "true"
|
||||
DEFAULT_SPARQL_ENDPOINT: "http://localhost:8890/sparql"
|
||||
66
docker-compose.yml
Normal file
66
docker-compose.yml
Normal file
@@ -0,0 +1,66 @@
|
||||
version: '3.4'
|
||||
|
||||
x-logging:
|
||||
&default-logging
|
||||
driver: "json-file"
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
|
||||
services:
|
||||
identifier:
|
||||
image: semtech/mu-identifier:1.8.1
|
||||
environment:
|
||||
DEFAULT_ACCESS_CONTROL_ALLOW_ORIGIN_HEADER: "*"
|
||||
DEFAULT_MU_AUTH_ALLOWED_GROUPS_HEADER: "[{\"variables\":[],\"name\":\"public\"}]"
|
||||
labels:
|
||||
- "logging=true"
|
||||
restart: always
|
||||
logging: *default-logging
|
||||
web:
|
||||
image: nginx
|
||||
volumes:
|
||||
- ./config/proxy:/etc/nginx/conf.d
|
||||
- ./config/proxy/web.conf:/etc/nginx/nginx.conf:ro
|
||||
links:
|
||||
- identifier:identifier
|
||||
dispatcher:
|
||||
image: semtech/mu-dispatcher:latest
|
||||
volumes:
|
||||
- ./config/dispatcher:/config
|
||||
labels:
|
||||
- "logging=true"
|
||||
restart: always
|
||||
logging: *default-logging
|
||||
triplestore:
|
||||
image: tenforce/virtuoso:1.3.2-virtuoso7.2.2
|
||||
environment:
|
||||
SPARQL_UPDATE: "true"
|
||||
DEFAULT_GRAPH: "http://mu.semte.ch/application"
|
||||
volumes:
|
||||
- ./data/db:/data
|
||||
- ./config/db/virtuoso.ini:/data/virtuoso.ini
|
||||
labels:
|
||||
- "logging=true"
|
||||
restart: always
|
||||
logging: *default-logging
|
||||
db:
|
||||
image: semtech/mu-authorization:0.6.0-beta.5
|
||||
environment:
|
||||
MU_SPARQL_ENDPOINT: "http://triplestore:8890/sparql"
|
||||
LOG_OUTGOING_SPARQL_QUERIES: "true"
|
||||
LOG_INCOMING_SPARQL_QUERIES: "true"
|
||||
LOG_ACCESS_RIGHTS: "true"
|
||||
volumes:
|
||||
- ./config/authorization:/config
|
||||
migrations:
|
||||
image: semtech/mu-migrations-service
|
||||
links:
|
||||
- triplestore:database
|
||||
volumes:
|
||||
- ./config/migrations:/data/migrations
|
||||
labels:
|
||||
- "logging=true"
|
||||
restart: always
|
||||
logging: *default-logging
|
||||
|
||||
Reference in New Issue
Block a user