friendship ended with social-app. php is my new best friend
1<?php
2/**
3 * Interface CSRFToken
4 *
5 * @created 29.01.2018
6 * @author smiley <smiley@chillerlan.net>
7 * @copyright 2018 smiley
8 * @license MIT
9 */
10declare(strict_types=1);
11
12namespace chillerlan\OAuth\Core;
13
14/**
15 * Specifies the methods required for the OAuth2 CSRF token validation ("state parameter")
16 *
17 * @link https://datatracker.ietf.org/doc/html/rfc6749#section-4.1.1
18 * @link https://datatracker.ietf.org/doc/html/rfc6749#section-10.12
19 */
20interface CSRFToken{
21
22 /**
23 * Checks whether the CSRF state was set and verifies against the last known state.
24 * Throws a ProviderException if the given state is empty, unknown or doesn't match the known state.
25 *
26 * @throws \chillerlan\OAuth\Providers\ProviderException
27 */
28 public function checkState(string|null $state = null):void;
29
30 /**
31 * Sets the CSRF state parameter in a given array of query parameters and stores that value
32 * in the local storage for later verification. Returns the updated array of parameters.
33 *
34 * @param array<string, string> $params
35 * @return array<string, string>
36 * @throws \chillerlan\OAuth\Providers\ProviderException
37 */
38 public function setState(array $params):array;
39
40}