Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: changes to make the sessions work with https #15

Merged
merged 3 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions build_artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ for lang in 'nl' 'en'; do
cp "$DIR/start_session.js" "$DIR/build/$lang/start_session.js"
done

cp -r "$DIR/data" "$DIR/build/data"
rm "$DIR/build/data/README.md"
rm "$DIR/build/data/.gitignore"

# Delete potential empty directories
find "$DIR/build" -type d -empty -delete
# Delete shell files
Expand Down
4 changes: 0 additions & 4 deletions config.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,3 @@
define('IRMATUBE_NEXT_SESSION_URL', BASE_URL . '/demo/get_session_request.php');
define('IRMATUBE_CREDENTIAL', 'pbdf.pbdf.irmatube');
}

if (JWT_ENABLED) {
define('IRMA_SERVER_PUBLICKEY', __DIR__ . '/../data/pk.pem');
}
1 change: 0 additions & 1 deletion data/.gitignore

This file was deleted.

6 changes: 0 additions & 6 deletions data/README.md

This file was deleted.

2 changes: 1 addition & 1 deletion get_session_request.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
function get_session_request($contents)
{
if (JWT_ENABLED) {
$jwt_pk = file_get_contents(IRMA_SERVER_PUBLICKEY);
$jwt_pk = file_get_contents(IRMA_SERVER_URL . './publickey');
try {
$decoded = JWT::decode($contents, new Key($jwt_pk, 'RS256'));
} catch (Exception $e) {
Expand Down
20 changes: 10 additions & 10 deletions start_session.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
require_once 'config.php';

date_default_timezone_set('UTC');
$protocol = explode(':', IRMA_SERVER_URL, 2)[0];

$sigrequests = [
'email-signature' => [
Expand Down Expand Up @@ -177,7 +176,7 @@
];

function start_session($type, $lang) {
global $sprequests, $sigrequests, $protocol;
global $sprequests, $sigrequests;

if (array_key_exists($type, $sprequests))
$sessionrequest = $sprequests[$type];
Expand All @@ -189,14 +188,15 @@ function start_session($type, $lang) {
$jsonsr = json_encode($sessionrequest);

$api_call = array(
$protocol => array(
'method' => 'POST',
'header' => "Content-type: application/json\r\n"
. "Content-Length: " . strlen($jsonsr) . "\r\n"
. "Authorization: " . API_TOKEN . "\r\n",
'content' => $jsonsr
)
);
'http' => array(
'method' => 'POST',
'header' => "Content-type: application/json\r\n"
. "Content-Length: " . strlen($jsonsr) . "\r\n"
. "Authorization: " . API_TOKEN . "\r\n",
'content' => $jsonsr,
)
);


$resp = file_get_contents(IRMA_SERVER_URL . '/session', false, stream_context_create($api_call));
if (! $resp) {
Expand Down