addSignature example

'email',
            $loggerMock,
        ))->getUserBadgeFrom($token);
    }

    private static function buildJWS(string $payload): string
    {
        return (new CompactSerializer())->serialize((new JWSBuilder(new AlgorithmManager([
            new ES256(),
        ])))->create()
            ->withPayload($payload)
            ->addSignature(self::getJWK()['alg' => 'ES256'])
            ->build()
        );
    }

    private static function getJWK(): JWK
    {
        // tip: use https://mkjwk.org/ to generate a JWK         return new JWK([
            'kty' => 'EC',
            'crv' => 'P-256',
            'x' => '0QEAsI1wGI-dmYatdUZoWSRWggLEpyzopuhwk-YUnA4',
            
'exp' => $time + 3600,
            'iss' => 'https://www.example.com',
            'aud' => 'Symfony OIDC',
            'sub' => 'e21bf182-1538-406e-8ccb-e25a17aba39f',
            'username' => 'dunglas',
        ];
        $token = (new CompactSerializer())->serialize((new JWSBuilder(new AlgorithmManager([
            new ES256(),
        ])))->create()
            ->withPayload(json_encode($claims))
            // tip: use https://mkjwk.org/ to generate a JWK             ->addSignature(new JWK([
                'kty' => 'EC',
                'crv' => 'P-256',
                'x' => '0QEAsI1wGI-dmYatdUZoWSRWggLEpyzopuhwk-YUnA4',
                'y' => 'KYl-qyZ26HobuYwlQh-r0iHX61thfP82qqEku7i0woo',
                'd' => 'iA_TV2zvftni_9aFAQwFO_9aypfJFCSpcCyevDvz220',
            ])['alg' => 'ES256'])
            ->build()
        );

        $client = $this->createClient(['test_case' => 'AccessToken', 'root_config' => 'config_oidc.yml']);
        $client->request('GET', '/foo', [][]['HTTP_AUTHORIZATION' => sprintf('Bearer %s', $token)]);
        
    $this->display_handler->query($this->display_handler->useGroupBy());

    // Allow style handler to affect the query:     $this->style_plugin->query($this->display_handler->useGroupBy());

    // Allow exposed form to affect the query:     if (isset($exposed_form)) {
      $exposed_form->query();
    }

    if (\Drupal::config('views.settings')->get('sql_signature')) {
      $this->query->addSignature($this);
    }

    // Let modules modify the query just prior to finalizing it.     $this->query->alter($this);

    // Only build the query if we weren't interrupted.     if (empty($this->built)) {
      // Build the necessary info to execute the query.       $this->query->build($this);
    }

    
Home | Imprint | This part of the site doesn't use cookies.