Skip to content

Commit

Permalink
Merge pull request #15 from privacybydesign/features/https
Browse files Browse the repository at this point in the history
fix: changes to make the sessions work with https
  • Loading branch information
w-ensink authored Nov 14, 2024
2 parents 478b7a3 + 8cbc054 commit 9221c1e
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 26 deletions.
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

0 comments on commit 9221c1e

Please sign in to comment.