PHP code example of locksyk / api-session-bundle

1. Go to this page and download the library: Download locksyk/api-session-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

locksyk / api-session-bundle example snippets


// config/bundles.php
LocksyK\ApiSessionBundle\ApiSessionBundle::class => ['all' => true],

$resumedUser = $impersonations->exit($request, ImpersonationExitedEvent::REASON_FORCED);

interface TokenStrategyInterface
{
    public function mint(string $sessionId, ?int $expiresAt = null): string;
    public function extract(string $bearerValue): ?SessionToken;
}

$client->jsonRequest('POST', '/api/test/login', ['email' => '[email protected]']);
$token = $client->getResponse()->headers->get('X-Session-Token');
$client->request('GET', '/api/me', server: ['HTTP_AUTHORIZATION' => 'Bearer '.$token]);
yaml
api_session:
    firewalls: []                  # firewall names to bridge (der
        prefix: sess_              # token prefix; non-empty, dot-free
        lifetime: null             # seconds; non-null enables refresh
    csrf_bypass: true              # CSRF check bypass on bridged firewalls
    stale_token:
        www_authenticate: true     # RFC 6750 invalid_token on 401s
    logout:
        json_response: false       # opt-in: 204 on logout
    switch_user:
        role: ROLE_ALLOWED_TO_SWITCH
        grant_previous_admin_role: auto    # auto | true | false