31 $this->site_secret = $secret;
46 $key = $this->site_secret->get(
true);
49 return new Hmac(
$key, [$this->crypto,
'areEqual'],
$data, $algo);
65 return "{$time}.{$token}";
81 if (!
preg_match(
'~^(\d+)\.([a-zA-Z0-9\-_]+)$~', $code, $matches)) {
85 $time = (int) $matches[1];
Manages a site-specific secret key, encoded as a 32 byte string "secret".
generateInviteCode(string $username)
Generates a unique invite code for a user.
if(!$annotation instanceof ElggAnnotation) $time
trait TimeUsing
Adds methods for setting the current time (for testing)
validateInviteCode(string $username, string $code)
Validate a user's invite code.
getCurrentTime($modifier= '')
Get the (cloned) time.
if(!$entity instanceof\ElggUser) $data
getHmac($data, $algo= 'sha256', $key= '')
Get an HMAC token builder/validator object.
Component for creating HMAC tokens.
if($container instanceof ElggGroup &&$container->guid!=elgg_get_page_owner_guid()) $key
__construct(SiteSecret $secret, Crypto $crypto)
Constructor.
Provides a factory for HMAC objects.