commit
aff50d785d
@ -1,4 +1,20 @@
|
||||
<?php
|
||||
|
||||
// Patch for when using nginx instead of apache, source: http://php.net/manual/en/function.getallheaders.php#84262
|
||||
if (!function_exists('getallheaders')) {
|
||||
function getallheaders() {
|
||||
$headers = '';
|
||||
|
||||
foreach ($_SERVER as $name => $value) {
|
||||
if (substr($name, 0, 5) == 'HTTP_') {
|
||||
$headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $headers;
|
||||
}
|
||||
}
|
||||
|
||||
// Log an action. If $itemId is set, it is an item action.
|
||||
function logAction($comment, $oldValue, $newValue, $itemId=null) {
|
||||
$activity = R::dispense('activity');
|
||||
@ -27,8 +43,8 @@ function setUserToken($user, $expires) {
|
||||
function getUser() {
|
||||
global $jsonResponse;
|
||||
|
||||
if (isset(apache_request_headers()['Authorization'])) {
|
||||
$hash = apache_request_headers()['Authorization'];
|
||||
if (isset(getallheaders()['Authorization'])) {
|
||||
$hash = getallheaders()['Authorization'];
|
||||
try {
|
||||
$payload = JWT::decode($hash, getJwtKey());
|
||||
$user = R::load('user', $payload->uid);
|
||||
@ -46,7 +62,7 @@ function getUser() {
|
||||
// Get all users.
|
||||
function getUsers($sanitize = true) {
|
||||
try {
|
||||
$hash = apache_request_headers()['Authorization'];
|
||||
$hash = getallheaders()['Authorization'];
|
||||
$payload = JWT::decode($hash, getJwtKey());
|
||||
|
||||
$users = R::findAll('user');
|
||||
@ -246,8 +262,8 @@ function validateToken($requireAdmin = false) {
|
||||
function checkDbToken() {
|
||||
$user = getUser();
|
||||
if (null != $user) {
|
||||
if (isset(apache_request_headers()['Authorization'])) {
|
||||
$hash = apache_request_headers()['Authorization'];
|
||||
if (isset(getallheaders()['Authorization'])) {
|
||||
$hash = getallheaders()['Authorization'];
|
||||
return $hash == $user->token;
|
||||
}
|
||||
}
|
||||
@ -259,7 +275,7 @@ function clearDbToken() {
|
||||
$payload = null;
|
||||
|
||||
try {
|
||||
$payload = JWT::decode(apache_request_headers()['Authorization'], getJwtKey());
|
||||
$payload = JWT::decode(getallheaders()['Authorization'], getJwtKey());
|
||||
} catch (Exception $e) {}
|
||||
|
||||
if (null != $payload) {
|
||||
@ -358,3 +374,5 @@ function updateItemFromAction(&$item, $action) {
|
||||
}
|
||||
R::store($item);
|
||||
}
|
||||
|
||||
|
||||
|
||||
22
build/Dockerfile
Normal file
22
build/Dockerfile
Normal file
@ -0,0 +1,22 @@
|
||||
# Dockerfile for Taskboard with nginx and sqlite.
|
||||
|
||||
FROM ubuntu:trusty
|
||||
MAINTAINER Alex van den Hoogen <alex.van.den.hoogen@geodan.nl>
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -yq --no-install-recommends git wget nginx php5-fpm php5-sqlite sqlite3 ca-certificates pwgen && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN echo "cgi.fix_pathinfo = 0;" >> /etc/php5/fpm/php.ini && \
|
||||
echo "daemon off;" >> /etc/nginx/nginx.conf && \
|
||||
mkdir -p /var/www
|
||||
|
||||
RUN git clone https://github.com/kiswa/TaskBoard.git /var/www && \
|
||||
chmod 777 $(find /var/www -type d)
|
||||
|
||||
ADD nginx.conf /etc/nginx/sites-available/default
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
CMD service php5-fpm start && nginx
|
||||
0
build/build-all
Normal file → Executable file
0
build/build-all
Normal file → Executable file
0
build/clean
Normal file → Executable file
0
build/clean
Normal file → Executable file
0
build/minify-app
Normal file → Executable file
0
build/minify-app
Normal file → Executable file
0
build/minify-libs
Normal file → Executable file
0
build/minify-libs
Normal file → Executable file
Reference in New Issue
Block a user