additional_plugins/serendipity_event_browserid
Garvin Hicking cf7ea74b0a Added legal notice for remaining plugins
@th-h Please check serendipity_event_dejure if possible

@onli please check serendipity_event_commentspice and serendipity_event_browserid if possible
2018-04-05 14:17:19 +02:00
..
src browserid: Move to successor project portier (#52) 2017-02-22 18:33:36 +01:00
tests browserid: Move to successor project portier (#52) 2017-02-22 18:33:36 +01:00
UTF-8
vendor browserid: Move to successor project portier (#52) 2017-02-22 18:33:36 +01:00
ChangeLog Added legal notice for remaining plugins 2018-04-05 14:17:19 +02:00
composer.json browserid: Move to successor project portier (#52) 2017-02-22 18:33:36 +01:00
composer.lock browserid: Move to successor project portier (#52) 2017-02-22 18:33:36 +01:00
documentation_cs.html
documentation_cz.html
lang_cs.inc.php
lang_cz.inc.php
lang_de.inc.php
lang_en.inc.php
LICENSE browserid: Move to successor project portier (#52) 2017-02-22 18:33:36 +01:00
phpunit.xml browserid: Move to successor project portier (#52) 2017-02-22 18:33:36 +01:00
README.md browserid: Move to successor project portier (#52) 2017-02-22 18:33:36 +01:00
S9yStore.php browserid: Move to successor project portier (#52) 2017-02-22 18:33:36 +01:00
serendipity_event_browserid.js
serendipity_event_browserid.php Added legal notice for remaining plugins 2018-04-05 14:17:19 +02:00

portier-php

A Portier client library for PHP

Example

<?php

require 'vendor/autoload.php';

$app = new \Slim\App();

$redis = new Redis();
$redis->pconnect('127.0.0.1', 6379);

$portier = new \Portier\Client\Client(
    new \Portier\Client\RedisStore($redis),
    'http://localhost:8000/verify'
);

$app->get('/', function($req, $res) {
    $res = $res
        ->withStatus(200)
        ->withHeader('Content-Type', 'text/html; charset=utf-8');

    $res->getBody()->write(
<<<EOF
        <p>Enter your email address:</p>
        <form method="post" action="/auth">
            <input name="email" type="email">
            <button type="submit">Login</button>
        </form>
EOF
    );

    return $res;
});

$app->post('/auth', function($req, $res) use ($portier) {
    $authUrl = $portier->authenticate($req->getParsedBodyParam('email'));

    return $res
        ->withStatus(303)
        ->withHeader('Location', $authUrl);
});

$app->post('/verify', function($req, $res) use ($portier) {
    $email = $portier->verify($req->getParsedBodyParam('id_token'));

    $res = $res
        ->withStatus(200)
        ->withHeader('Content-Type', 'text/html; charset=utf-8');

    $res->getBody()->write(
<<<EOF
        <p>Verified email address ${email}!</p>
EOF
    );

    return $res;
});

$app->run();