API / Minn\Auth / Cookie

Cookie final readonly class

Minn\Auth\Cookie · public/minn/src/Minn/Auth/Cookie.php · 92 lines

The sign-in cookies: username|expiration|token|hmac, with key = HMAC-md5(username|fragment|expiration|token, the scheme's salt) hmac = HMAC-sha256(username|expiration|token, key) and the session live in the user's session_tokens store. The engine's own sign-in reads the logged_in one; check() judges any scheme's the way wp_validate_auth_cookie reports it (probe auth-cookies).

Constants and properties

privatereadonly Minn\Db $db

Promoted from the constructor.

privatereadonly Minn\Content\Users $users

Promoted from the constructor.

privatereadonly Minn\Auth\Sessions $sessions

Promoted from the constructor.

Public

new__construct(Minn\Db $db, Minn\Content\Users $users, Minn\Auth\Sessions $sessions)#
methodname(): string#

The cookie name this site uses: a hash of the siteurl option.

methodmint(Minn\Content\UserRecord $user, int $expiration, string $token): string#

A sign-in cookie value for a user, expiry, and session token.

methodvalidate(string $value): ?Minn\Auth\Authenticated#

The session a logged_in cookie value proves, or null when any part fails.

methodcheck(string $username, string $expiration, string $token, string $hmac, string $scheme, int $grace = 0): array#

A cookie's parts judged under a scheme, in the reference's order: expired (past its expiration plus $grace), bad_username, bad_hash (an unknown scheme never matches), bad_session_token, else valid with its user.

@return array{string, ?UserRecord}
methodfromJar(array $cookies): ?string#

The logged_in cookie from a request's cookie jar: the canonical name first, then any logged_in cookie, since tooling may send a name derived from a different host.

$cookiesarray<string, string>
staticsignature(string $username, string $fragment, int $expiration, string $token, string $scheme = 'logged_in'): ?string#

A cookie's hmac under a scheme's salt, or null for a scheme with none.