Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
23bf431c74 | ||
|
|
4bced68a09 | ||
|
|
4d3ace9d67 | ||
|
|
e9f1b8477a | ||
| 9809b028d4 | |||
| da5d7ffa53 | |||
| 02c397bca2 | |||
| a4ae987f94 | |||
|
|
26c4f801d3 | ||
|
|
49581da52c | ||
| 57faf21a67 | |||
| 5ff90e0d78 |
2
.github/workflows/deploy.yml
vendored
2
.github/workflows/deploy.yml
vendored
@@ -15,7 +15,7 @@ jobs:
|
||||
- id: release
|
||||
uses: rymndhng/release-on-push-action@master
|
||||
with:
|
||||
bump_version_scheme: minor
|
||||
bump_version_scheme: patch
|
||||
|
||||
- name: Check Output Parameters
|
||||
run: |
|
||||
|
||||
2
.github/workflows/stale.yml
vendored
2
.github/workflows/stale.yml
vendored
@@ -10,7 +10,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/stale@v1
|
||||
- uses: actions/stale@v3
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
stale-issue-message: 'This issue has been marked as stale due to inactivity. If this issue is still ongoing, please leave a comment.'
|
||||
|
||||
@@ -13,3 +13,5 @@ OIDC_HOST = ""
|
||||
OIDC_CLIENT_ID = ""
|
||||
OIDC_CLIENT_SECRET = ""
|
||||
OIDC_DISABLE_SSL = ""
|
||||
|
||||
SENTRY_ENVIRONMENT = ""
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
{
|
||||
"require": {
|
||||
"ramsey/uuid": "^4.0",
|
||||
"vlucas/phpdotenv": "^5.0",
|
||||
"jumbojett/openid-connect-php": "^0.9.0"
|
||||
}
|
||||
"require": {
|
||||
"ramsey/uuid": "^4.0",
|
||||
"vlucas/phpdotenv": "^5.0",
|
||||
"jumbojett/openid-connect-php": "^0.9.0",
|
||||
"sentry/sdk": "^3.0"
|
||||
}
|
||||
}
|
||||
|
||||
1741
app/composer.lock
generated
1741
app/composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -6,6 +6,44 @@
|
||||
return $version;
|
||||
}
|
||||
|
||||
function oidc_set_vars($sub, $uid, $fname, $lname, $email)
|
||||
{
|
||||
$_SESSION['uuid'] = $sub;
|
||||
$_SESSION['username'] = $uid;
|
||||
$_SESSION['given_name'] = $fname;
|
||||
$_SESSION['family_name'] = $lname;
|
||||
$_SESSION['full_name'] = $fname . " " . $lname;
|
||||
$_SESSION['email'] = $email;
|
||||
}
|
||||
|
||||
function is_signed_in()
|
||||
{
|
||||
if (isset($_SESSION['is_signed_in'])) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function user_exists($db, $uuid)
|
||||
{
|
||||
try {
|
||||
$sql = $db->prepare("SELECT uuid FROM users WHERE uuid=:uuid");
|
||||
$sql->bindParam(':uuid', $uuid);
|
||||
$sql->execute();
|
||||
$sql->setFetchMode(PDO::FETCH_ASSOC);
|
||||
$result = $sql->fetchAll();
|
||||
} catch (PDOException $e) {
|
||||
throw new Exception("Error in user_exists(): " . $e->getMessage());
|
||||
die();
|
||||
}
|
||||
if (empty($result)) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function get_all_users($db)
|
||||
{
|
||||
try {
|
||||
@@ -15,7 +53,8 @@
|
||||
$sql->setFetchMode(PDO::FETCH_ASSOC);
|
||||
$result = $sql->fetchAll();
|
||||
} catch (PDOException $e) {
|
||||
echo("Error: " . $e->getMessage());
|
||||
throw new Exception("Error in get_all_users(): " . $e->getMessage());
|
||||
die();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
@@ -31,7 +70,8 @@
|
||||
$result = $sql->fetchAll();
|
||||
$usr = $result[0]['given_name'] . " " . $result[0]['family_name'];
|
||||
} catch (PDOException $e) {
|
||||
echo("Error: " . $e->getMessage());
|
||||
throw new Exception("Error in get_user_name(): " . $e->getMessage());
|
||||
die();
|
||||
}
|
||||
return $usr;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
</main>
|
||||
<footer class="footer mt-auto py-3">
|
||||
<div class="text-center text-muted">
|
||||
<?php
|
||||
echo($_ENV['APP_NAME'] . " " . get_version());
|
||||
if ($_ENV['APP_NAME'] != "FHeD") {
|
||||
echo(", powered by FHeD");
|
||||
echo("| Powered by FHeD");
|
||||
};
|
||||
?><br>
|
||||
<?php if (is_signed_in()) {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<meta name="theme-color" content="#563d7c">
|
||||
<link rel="icon" type="image/png" href="/favicon.png">
|
||||
<title><?php echo( $PAGE_TITLE ); ?></title>
|
||||
<title><?php echo($PAGE_TITLE); ?></title>
|
||||
|
||||
<!-- Bootstrap core CSS -->
|
||||
<link rel="stylesheet" href="/css/bootstrap.min.css">
|
||||
@@ -19,6 +19,8 @@
|
||||
</head>
|
||||
|
||||
<body class="d-flex flex-column h-100">
|
||||
<!-- Begin page content -->
|
||||
<main role="main" class="flex-shrink-0">
|
||||
<header>
|
||||
<!-- Fixed navbar -->
|
||||
<nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
|
||||
@@ -32,10 +34,14 @@
|
||||
<a class="nav-link" href="/">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link <?php if (!is_signed_in()) {echo(' disabled');} ?>" href="/new">New request</a>
|
||||
<a class="nav-link <?php if (!is_signed_in()) {
|
||||
echo(' disabled');
|
||||
} ?>" href="/new">New request</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link <?php if (!is_signed_in()) {echo(' disabled');} ?>" href="/existing">Existing requests</a>
|
||||
<a class="nav-link <?php if (!is_signed_in()) {
|
||||
echo(' disabled');
|
||||
} ?>" href="/existing">Existing requests</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="mt-2 mt-md-0">
|
||||
|
||||
@@ -7,17 +7,27 @@ require_once __DIR__ . "/../vendor/autoload.php";
|
||||
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__ . "/..");
|
||||
$dotenv->load();
|
||||
|
||||
// Custom functions
|
||||
require_once __DIR__ . "/app_functions.php";
|
||||
|
||||
// Sentry
|
||||
Sentry\init([
|
||||
'dsn' => 'https://7c4607ed5e804d08926cc0bbc0d3fbe9@app.glitchtip.com/59',
|
||||
'release' => get_version(),
|
||||
]);
|
||||
|
||||
// Database auto-generation
|
||||
if (file_exists("/../includes/install.php")) {
|
||||
return;
|
||||
add_action('run_db_populate');
|
||||
return;
|
||||
add_action('run_db_populate');
|
||||
}
|
||||
|
||||
function run_db_populate() {
|
||||
function run_db_populate()
|
||||
{
|
||||
// all my glorious one-time-magic.
|
||||
include( "/../includes/install.php" );
|
||||
// after all execution rename your file;
|
||||
rename( "/../includes/install.php", "/../includes/install-backup.php");
|
||||
include("/../includes/install.php");
|
||||
// after all execution rename your file;
|
||||
rename("/../includes/install.php", "/../includes/install-backup.php");
|
||||
}
|
||||
|
||||
// Session
|
||||
@@ -29,30 +39,9 @@ $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
// OpenID Connect
|
||||
use Jumbojett\OpenIDConnectClient;
|
||||
|
||||
$oidc = new OpenIDConnectClient($_ENV['OIDC_HOST'], $_ENV['OIDC_CLIENT_ID'], $_ENV['OIDC_CLIENT_SECRET']);
|
||||
if ($_ENV['OIDC_DISABLE_SSL'] == "true") {
|
||||
$oidc->setVerifyHost(false);
|
||||
$oidc->setVerifyPeer(false);
|
||||
}
|
||||
|
||||
|
||||
// Custom functions
|
||||
|
||||
require_once __DIR__ . "/app_functions.php";
|
||||
|
||||
function oidc_set_vars($sub, $uid, $fname, $lname, $email) {
|
||||
$_SESSION['uuid'] = $sub;
|
||||
$_SESSION['username'] = $uid;
|
||||
$_SESSION['given_name'] = $fname;
|
||||
$_SESSION['family_name'] = $lname;
|
||||
$_SESSION['full_name'] = $fname . " " . $lname;
|
||||
$_SESSION['email'] = $email;
|
||||
}
|
||||
|
||||
function is_signed_in() {
|
||||
if (isset($_SESSION['is_signed_in'])) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
$oidc->setVerifyHost(false);
|
||||
$oidc->setVerifyPeer(false);
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
|
||||
// Perform the OIDC authentication
|
||||
try {
|
||||
$oidc->authenticate();
|
||||
$_SESSION['access_token'] = $oidc->requestClientCredentialsToken()->access_token;
|
||||
$oidc_user = array(
|
||||
$oidc->authenticate();
|
||||
$_SESSION['access_token'] = $oidc->requestClientCredentialsToken()->access_token;
|
||||
$oidc_user = array(
|
||||
'sub' => $oidc->requestUserInfo('sub'),
|
||||
'username' => $oidc->requestUserInfo('preferred_username'),
|
||||
'given_name' => $oidc->requestUserInfo('given_name'),
|
||||
@@ -14,46 +14,41 @@
|
||||
'email' => $oidc->requestUserInfo('email'),
|
||||
);
|
||||
} catch (Jumbojett\OpenIDConnectClientException $e) {
|
||||
$alert = array("danger", "Error during OpenID Connect authentication: " . $e->getMessage());
|
||||
$alert = array("danger", "Error during OpenID Connect authentication: " . $e->getMessage());
|
||||
}
|
||||
|
||||
// Check if the user already exists
|
||||
try {
|
||||
$user_exist_sql = $db->prepare("SELECT uuid FROM users WHERE uuid=:uuid");
|
||||
$user_exist_sql->bindParam(':uuid', $oidc_user['sub']);
|
||||
$user_exist_sql->execute();
|
||||
} catch (PDOException $e) {
|
||||
$alert = array("danger", "Error during check for user record: " . $e->getMessage());
|
||||
}
|
||||
|
||||
if (empty($user_exist_sql)) {
|
||||
// User doesn't already exist
|
||||
try {
|
||||
$stmt = "INSERT INTO users (uuid, uid, given_name, family_name, email) VALUES (:sub, :username, :given, :family, :email)";
|
||||
$sql = $db->prepare($stmt);
|
||||
$sql->bindParam(':sub', $oidc_user['sub']);
|
||||
$sql->bindParam(':username', $oidc_user['username']);
|
||||
$sql->bindParam(':given', $oidc_user['given_name']);
|
||||
$sql->bindParam(':family', $oidc_user['family_name']);
|
||||
$sql->bindParam(':email', $oidc_user['email']);
|
||||
$sql->execute();
|
||||
} catch (Jumbojett\PDOException $e) {
|
||||
$alert = array("danger", "Error during creation of new user record: " . $e->getMessage());
|
||||
}
|
||||
if (user_exists($db, $oidc_user['sub']) == false) {
|
||||
// User doesn't already exist
|
||||
try {
|
||||
$stmt = "INSERT INTO users (uuid, uid, given_name, family_name, email) VALUES (:sub, :username, :given, :family, :email)";
|
||||
$sql = $db->prepare($stmt);
|
||||
$sql->bindParam(':sub', $oidc_user['sub']);
|
||||
$sql->bindParam(':username', $oidc_user['username']);
|
||||
$sql->bindParam(':given', $oidc_user['given_name']);
|
||||
$sql->bindParam(':family', $oidc_user['family_name']);
|
||||
$sql->bindParam(':email', $oidc_user['email']);
|
||||
$sql->execute();
|
||||
} catch (PDOException $e) {
|
||||
echo("Error during creation of new user record: " . $e->getMessage());
|
||||
die();
|
||||
$alert = array("danger", "Error during creation of new user record: " . $e->getMessage());
|
||||
}
|
||||
} else {
|
||||
// User already exists
|
||||
try {
|
||||
$stmt = "UPDATE users SET uid=:username, given_name=:given, family_name=:family, email=:email WHERE uuid=:sub";
|
||||
$sql = $db->prepare($stmt);
|
||||
$sql->bindParam(':sub', $oidc_user['sub']);
|
||||
$sql->bindParam(':username', $oidc_user['username']);
|
||||
$sql->bindParam(':given', $oidc_user['given_name']);
|
||||
$sql->bindParam(':family', $oidc_user['family_name']);
|
||||
$sql->bindParam(':email', $oidc_user['email']);
|
||||
$sql->execute();
|
||||
} catch (Jumbojett\PDOException $e) {
|
||||
$alert = array("danger", "Error during existing user record update: " . $e->getMessage());
|
||||
}
|
||||
// User already exists
|
||||
try {
|
||||
$stmt = "UPDATE users SET uid=:username, given_name=:given, family_name=:family, email=:email WHERE uuid=:sub";
|
||||
$sql = $db->prepare($stmt);
|
||||
$sql->bindParam(':sub', $oidc_user['sub']);
|
||||
$sql->bindParam(':username', $oidc_user['username']);
|
||||
$sql->bindParam(':given', $oidc_user['given_name']);
|
||||
$sql->bindParam(':family', $oidc_user['family_name']);
|
||||
$sql->bindParam(':email', $oidc_user['email']);
|
||||
$sql->execute();
|
||||
} catch (PDOException $e) {
|
||||
echo("Error during existing user record update: " . $e->getMessage());
|
||||
die();
|
||||
$alert = array("danger", "Error during existing user record update: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
oidc_set_vars($oidc_user['sub'], $oidc_user['username'], $oidc_user['given_name'], $oidc_user['family_name'], $oidc_user['email']);
|
||||
@@ -62,4 +57,3 @@
|
||||
$_SESSION['is_signed_in'] = "true";
|
||||
|
||||
header('Location: /');
|
||||
?>
|
||||
|
||||
@@ -3,21 +3,17 @@
|
||||
require_once __DIR__ . "/../includes/header.php";
|
||||
|
||||
if (is_signed_in()) {
|
||||
$requests = get_my_open_requests($db);
|
||||
$subscriptions = get_open_subscribed_requests($db);
|
||||
$requests = get_my_open_requests($db);
|
||||
$subscriptions = get_open_subscribed_requests($db);
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
|
||||
|
||||
<!-- Begin page content -->
|
||||
<main role="main" class="flex-shrink-0">
|
||||
|
||||
<section>
|
||||
<?php
|
||||
if(isset($alert)) {
|
||||
echo("
|
||||
if (isset($alert)) {
|
||||
echo("
|
||||
<div class='container'>
|
||||
<div class='alert alert-" . $alert[0] . " alert-dismissible fade show' role='alert'>
|
||||
" . $alert[1] . "
|
||||
@@ -27,7 +23,7 @@
|
||||
</div>
|
||||
</div>
|
||||
");
|
||||
unset($alert);
|
||||
unset($alert);
|
||||
}
|
||||
?>
|
||||
</section>
|
||||
@@ -37,7 +33,11 @@
|
||||
<h1>Welcome to <?php echo($_ENV['APP_NAME']); ?></h1>
|
||||
<p class="lead text-muted">
|
||||
<?php
|
||||
if ($_ENV['APP_NAME'] == "FHeD") {echo("The Free HelpDesk");} else {echo($_ENV['APP_NAME']);};
|
||||
if ($_ENV['APP_NAME'] == "FHeD") {
|
||||
echo("The Free HelpDesk");
|
||||
} else {
|
||||
echo($_ENV['APP_NAME']);
|
||||
};
|
||||
?>
|
||||
is the one-stop shop for all of your IT-related needs. Let us know how we can help you by opening a request.
|
||||
</p>
|
||||
@@ -63,10 +63,10 @@
|
||||
<ul class="list-group list-group-flush">
|
||||
<?php
|
||||
if (count($requests) == 0) {
|
||||
echo("<center><b>No open tickets</b></center>");
|
||||
echo("<center><b>No open tickets</b></center>");
|
||||
} else {
|
||||
foreach($requests as $tkt) {
|
||||
?>
|
||||
foreach ($requests as $tkt) {
|
||||
?>
|
||||
<li class="list-group-item">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
@@ -80,7 +80,9 @@
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<?php } } ?>
|
||||
<?php
|
||||
}
|
||||
} ?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@@ -93,9 +95,9 @@
|
||||
<ul class="list-group list-group-flush">
|
||||
<?php
|
||||
if (count($subscriptions) == 0) {
|
||||
echo("<center><b>No subscribed tickets</b></center>");
|
||||
echo("<center><b>No subscribed tickets</b></center>");
|
||||
} else {
|
||||
foreach($subscriptions as $sub) { ?>
|
||||
foreach ($subscriptions as $sub) { ?>
|
||||
<li class="list-group-item">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
@@ -109,7 +111,8 @@
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<?php } } ?>
|
||||
<?php }
|
||||
} ?>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
@@ -118,8 +121,6 @@
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
</main>
|
||||
|
||||
<?php
|
||||
require_once __DIR__ . "/../includes/footer.php";
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user