Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
PandorasActorMS authored Sep 27, 2023
2 parents 59da465 + 26f4877 commit 0e07076
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ OIDC_LOGOUT=""

; Path to composer auoload file (without /vendor/autoload.php)
; normally set to "."
;COMPOSER_PATH="/composer/lib" # is always in the same directory in Docker container
; is always in the same directory in Docker container
;COMPOSER_PATH="/composer/lib"

;Favicon
FAVICON_URI=""
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ To get started you need to add a configuration file to the project first. Copy t
| OIDC_IDP | string | "https://...." | URL of the Identity provider supporting OpenID Connect. |
| OIDC_CLIENT_ID | string | "..." | Client Id for this application in Identity provider. |
| OIDC_CLIENT_SECRET | string | "..." | Secret key for OpenID Connect.
| OIDC_LOGOUT_URI | string | "https://...." | URL to logout from Identity provider |
| OIDC_LOGOUT_URI | string | "https://...." | URL to logout from Identity provider |
| COMPOSER_PATH | string | "..." | Path to PHP Composer libariries (only needed for OpenID Connect). |
| OPENAI_API_KEY | string | sk-... | Open AI Api key |
| IMPRINT_LOCATION | string | https://your-university/imprint | A link to your imprint. Alternatively you can replace the file index.php under /impressum with your own html/ php of your imprint. |
Expand Down
2 changes: 0 additions & 2 deletions interface.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@
?>
</head>
<meta name="viewport" content="width=device-width, initial-scale=1">

<link rel="stylesheet" href="app.css">


<div class="wrapper">
<div class="sidebar">
<div class="logo" onclick="load(this, 'chat.htm')">
Expand Down
42 changes: 42 additions & 0 deletions oic_login.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

// use library for dealing with OpenID connect
$env = parse_ini_file('.env');
$composerpath = $env["COMPOSER_PATH"];

require($composerpath . '/vendor/autoload.php');

use Jumbojett\OpenIDConnectClient;

// Create OpenID connect client
$env = parse_ini_file('.env');

$oidc = new OpenIDConnectClient(
$env["OIC_IDP"],
$env["OIC_CLIENT_ID"],
$env["OIC_CLIENT_SECRET"]
);

# Demo is dealing with HTTP rather than HTTPS
$testuser = $env["TESTUSER"];
if ($testuser) {
$oidc->setHttpUpgradeInsecureRequests(false);
}

$oidc->authenticate();

$_SESSION['oidcClient'] = $oidc;

// Set session variable username
$firstname = $oidc->requestUserInfo('given_name');
$surname = $oidc->requestUserInfo('family_name');
$initials = substr($firstname, 0, 1) . substr($surname, 0, 1);

$_SESSION['username'] = $initials;


header("Location: interface.php");
exit();

?>

0 comments on commit 0e07076

Please sign in to comment.