Skip to content

Commit

Permalink
Merge branch 'next' into feature-zms-3460-endpoint-for-grouped-offices
Browse files Browse the repository at this point in the history
  • Loading branch information
manjencic committed Jan 27, 2025
2 parents 6f47aa1 + 21a1b2f commit 38889db
Show file tree
Hide file tree
Showing 12 changed files with 221 additions and 88 deletions.
5 changes: 5 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### Pull Request Checklist (Feature Branch to `next`):

- [ ] Ich habe die neuesten Änderungen aus dem `next` Branch in meinen Feature-Branch gemergt.
- [ ] Das Code-Review wurde abgeschlossen.
- [ ] Fachliche Tests wurden durchgeführt und sind abgeschlossen.
46 changes: 19 additions & 27 deletions .github/workflows/static.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
# Workflow for deploying zmsapi PHP and Node.js static content to Pages
name: Deploy zmsapi static content to Pages
# Workflow for deploying API documentation to Pages
name: Deploy API Documentation to Pages

on:
# Runs on pushes targeting the default branch (main)
push:
branches: ["main"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
concurrency:
group: "pages"
cancel-in-progress: false
Expand All @@ -28,64 +23,61 @@ jobs:
runs-on: ubuntu-latest

steps:
# Step 1: Checkout the repository
- name: Checkout
uses: actions/checkout@v4

# Step 2: Set up PHP environment
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0' # Specify PHP version as per your requirement
php-version: '8.0'
extensions: mbstring, json
tools: composer

# Step 3: Install PHP dependencies for zmsapi
- name: Install PHP dependencies
run: |
composer install --working-dir=zmsapi
composer install --working-dir=zmscitizenapi
# Step 4: Run PHP post-install scripts for zmsapi
- name: Run PHP post-install scripts
run: |
cd zmsapi && bin/configure && composer run-script post-install-cmd && cd ..
cd zmscitizenapi && bin/configure && composer run-script post-install-cmd && cd ..
# Step 5: Set up Node.js environment
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '16' # Specify Node.js version as needed
node-version: '16'

# Step 6: Install Node.js dependencies for zmsapi
- name: Install Node.js dependencies for zmsapi
- name: Install Node.js dependencies
run: |
cd zmsapi
npm install
cd zmsapi && npm install && cd ..
cd zmscitizenapi && npm install && cd ..
# Step 7: Build the project for zmsapi
- name: Build zmsapi
- name: Build projects
run: |
cd zmsapi
npm run build
cd zmsapi && npm run build && cd ..
cd zmscitizenapi && npm run build && cd ..
# Step 8: Generate Swagger documentation for zmsapi
- name: Generate Swagger documentation
run: |
cd zmsapi
npm run doc
npx swagger-cli bundle -o public/doc/swagger.json public/doc/swagger.yaml
cd ..
cd zmscitizenapi
npm run doc
npx swagger-cli bundle -o public/doc/swagger.json public/doc/swagger.yaml
cd ..
# Step 9: Set up GitHub Pages for deployment
- name: Setup Pages
uses: actions/configure-pages@v5

# Step 10: Upload the static content to GitHub Pages
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: '.' # Upload the entire repository, including the generated docs
path: '.'

# Step 11: Deploy to GitHub Pages
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
27 changes: 12 additions & 15 deletions zmsadmin/src/Zmsadmin/Oidc.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,42 +23,40 @@ public function readResponse(
$state = $request->getParam("state");
$authKey = \BO\Zmsclient\Auth::getKey();

// Log state validation attempt
error_log(json_encode([
\App::$log->info('OIDC state validation', [
'event' => 'oauth_state_validation',
'timestamp' => date('c'),
'provider' => \BO\Zmsclient\Auth::getOidcProvider(),
'application' => 'zmsadmin',
'state_match' => ($state == $authKey)
]));
]);

if ($state == $authKey) {
try {
$workstation = \App::$http->readGetResult('/workstation/', ['resolveReferences' => 2])->getEntity();
$username = $workstation->getUseraccount()->id . '@' . \BO\Zmsclient\Auth::getOidcProvider();

// Log workstation access with username
error_log(json_encode([
\App::$log->info('OIDC workstation access', [
'event' => 'oauth_workstation_access',
'timestamp' => date('c'),
'provider' => \BO\Zmsclient\Auth::getOidcProvider(),
'application' => 'zmsadmin',
'username' => $username,
'workstation_id' => $workstation->id ?? 'unknown'
]));
]);

$departmentCount = $workstation->getUseraccount()->getDepartmentList()->count();

// Log department check with username
error_log(json_encode([
\App::$log->info('OIDC department check', [
'event' => 'oauth_department_check',
'timestamp' => date('c'),
'provider' => \BO\Zmsclient\Auth::getOidcProvider(),
'application' => 'zmsadmin',
'username' => $username,
'department_count' => $departmentCount,
'has_departments' => ($departmentCount > 0)
]));
]);

if (0 == $departmentCount) {
return \BO\Slim\Render::redirect(
Expand All @@ -76,38 +74,37 @@ public function readResponse(
);
} catch (\Exception $e) {
// Log workstation access error
error_log(json_encode([
\App::$log->error('OIDC workstation error', [
'event' => 'oauth_workstation_error',
'timestamp' => date('c'),
'provider' => \BO\Zmsclient\Auth::getOidcProvider(),
'application' => 'zmsadmin',
'error' => $e->getMessage(),
'code' => $e->getCode()
]));
]);
throw $e;
}
}

// Log invalid state
error_log(json_encode([
\App::$log->error('OIDC invalid state', [
'event' => 'oauth_invalid_state',
'timestamp' => date('c'),
'provider' => \BO\Zmsclient\Auth::getOidcProvider(),
'application' => 'zmsadmin'
]));
]);

throw new \BO\Slim\Exception\OAuthInvalid();

} catch (\Exception $e) {
// Log any uncaught exceptions
error_log(json_encode([
\App::$log->error('OIDC error', [
'event' => 'oauth_error',
'timestamp' => date('c'),
'provider' => \BO\Zmsclient\Auth::getOidcProvider(),
'application' => 'zmsadmin',
'error' => $e->getMessage(),
'code' => $e->getCode()
]));
]);
throw $e;
}
}
Expand Down
3 changes: 2 additions & 1 deletion zmsadmin/templates/block/emergency/emergency.twig
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
data-state="clear"
data-source="">
<h2 class="aural">Notruf</h2>
{% if workstation.name %}
<button class="button button--emergency emergency__button-trigger" >
<i class="fas fa-bell" aria-hidden="true"></i> NOTRUF
</button>

{% endif %}
<div class="emergency__overlay">
<div class="block emergency__overlay-layout" role="dialog" aria-labelledby="emergency__overlay_title">
{% embed "block/scaffholding/board.twig" with {'class': "emergency__display-box"} %} {# do NOT use class exception here! #}
Expand Down
4 changes: 3 additions & 1 deletion zmsapi/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,20 @@
"scripts": {
"clean": "rm -f public/doc/assets/*.* && rm -f public/_test/assets/*.*",
"command": "bin/configure",
"prepare-dirs": "mkdir -p public/_test/assets && mkdir -p public/doc/assets",
"wget-files": [
"wget https://eappointment.gitlab.io/zmsapi/doc/swagger.json -O public/doc/swagger.json",
"wget https://eappointment.gitlab.io/zmsapi/doc/assets/redoc.min.js -O public/doc/assets/redoc.min.js",
"wget https://eappointment.gitlab.io/zmsapi/_test/assets/swagger-ui-bundle.js -O public/_test/assets/swagger-ui-bundle.js",
"wget https://eappointment.gitlab.io/zmsapi/_test/assets/swagger-ui.css -O public/_test/assets/swagger-ui.css",
"wget https://eappointment.gitlab.io/zmsapi/_test/assets/swagger-ui-standalone-preset.js -O public/_test/assets/swagger-ui-standalone-preset.js",
"sha256sum --status -c checksums.txt"
],
"post-install-cmd": [
"@prepare-dirs",
"@wget-files"
],
"post-update-cmd": [
"@prepare-dirs",
"@wget-files"
]
},
Expand Down
4 changes: 4 additions & 0 deletions zmscitizenapi/checksums.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
7f700a62cf9c402a09313486b461a06233a4f46ed29d8e38f27f07668fc60591 public/doc/assets/redoc.min.js
73cc9ec630f285bebd75544742055fa89792543ef989e985cbfed217412f6d34 public/_test/assets/swagger-ui-bundle.js
f9e1d39b7fe5b0b472743b42be2b472249feae67c89d63593ce72674c33ca4dd public/_test/assets/swagger-ui.css
68a210d666aa74d72f3001757474a52ba3c5dd03deac11803d2e9ec9c8d6a3c1 public/_test/assets/swagger-ui-standalone-preset.js
10 changes: 10 additions & 0 deletions zmscitizenapi/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,20 @@
"scripts": {
"clean": "rm -f public/doc/assets/*.* && rm -f public/_test/assets/*.*",
"command": "bin/configure",
"prepare-dirs": "mkdir -p public/_test/assets && mkdir -p public/doc/assets",
"wget-files": [
"wget https://eappointment.gitlab.io/zmsapi/doc/assets/redoc.min.js -O public/doc/assets/redoc.min.js",
"wget https://eappointment.gitlab.io/zmsapi/_test/assets/swagger-ui-bundle.js -O public/_test/assets/swagger-ui-bundle.js",
"wget https://eappointment.gitlab.io/zmsapi/_test/assets/swagger-ui.css -O public/_test/assets/swagger-ui.css",
"wget https://eappointment.gitlab.io/zmsapi/_test/assets/swagger-ui-standalone-preset.js -O public/_test/assets/swagger-ui-standalone-preset.js",
"sha256sum --status -c checksums.txt"
],
"post-install-cmd": [
"@prepare-dirs",
"@wget-files"
],
"post-update-cmd": [
"@prepare-dirs",
"@wget-files"
]
},
Expand Down
2 changes: 1 addition & 1 deletion zmsdb/src/Zmsdb/Helper/CalculateSlots.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public function writePostProcessingByScope(\BO\Zmsentities\Scope $scope, \DateTi
}
}

public function writeCanceledSlots(\DateTimeInterface $now, $modify = '+10 minutes')
public function writeCanceledSlots(\DateTimeInterface $now, $modify = '+5 minutes')
{
\BO\Zmsdb\Connection\Select::getWriteConnection();
$slotQuery = new \BO\Zmsdb\Slot();
Expand Down
2 changes: 1 addition & 1 deletion zmsslim/src/Slim/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Application
* if debug is enabled, an exception is shown with a backtrace
*/
const DEBUG = false;
const DEBUGLEVEL = 'WARNING';
const DEBUGLEVEL = 'DEBUG';

const SESSION_DURATION = ZMS_SESSION_DURATION;

Expand Down
24 changes: 21 additions & 3 deletions zmsslim/src/Slim/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use App;
use Monolog\Formatter\JsonFormatter;
use Monolog\Handler\ErrorLogHandler;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
use Slim\HttpCache\CacheProvider;
use BO\Slim\Factory\ResponseFactory;
Expand Down Expand Up @@ -76,8 +76,26 @@ protected function configureLogger(string $level, string $identifier): void
{
App::$log = new Logger($identifier);
$level = $this->parseDebugLevel($level);
$handler = new ErrorLogHandler(ErrorLogHandler::OPERATING_SYSTEM, $level);
$handler->setFormatter(new JsonFormatter());
$handler = new StreamHandler('php://stderr', $level);

$formatter = new JsonFormatter();

// Add processor to format time_local first
App::$log->pushProcessor(function ($record) {
return array(
'time_local' => (new \DateTime())->format('Y-m-d\TH:i:sP'),
'client_ip' => $_SERVER['REMOTE_ADDR'] ?? '',
'remote_addr' => $_SERVER['HTTP_X_FORWARDED_FOR'] ?? $_SERVER['REMOTE_ADDR'] ?? '',
'remote_user' => '',
'application' => 'zmsslim',
'message' => $record['message'],
'level' => $record['level_name'],
'context' => $record['context'],
'extra' => $record['extra']
);
});

$handler->setFormatter($formatter);
App::$log->pushHandler($handler);
}

Expand Down
Loading

0 comments on commit 38889db

Please sign in to comment.