59 $object->regenerateScratchTokens();
74 'algorithm' =>
'SHA1',
83 return $this->secret[
'secret'];
105 if ( $this->secret[
'mode'] !==
'hotp' ) {
110 $memc = ObjectCache::newAnything( [] );
111 $uid = CentralIdLookup::factory()->centralIdFromLocalUser( $user->getUser() );
112 $memcKey =
wfMemcKey(
'oathauth',
'usedtokens', $uid );
113 $lastWindow = (
int)$memc->get( $memcKey );
118 $this->secret[
'period'], -$wgOATHAuthWindowRadius, $wgOATHAuthWindowRadius
125 $clientIP = $user->getUser()->getRequest()->getIP();
131 foreach ( $results as $window => $result ) {
132 if ( $window > $lastWindow && $result->toHOTP( 6 ) === $token ) {
136 $logger->info(
'OATHAuth user {user} entered a valid OTP from {clientip}', [
137 'user' => $user->getAccount(),
138 'clientip' => $clientIP,
146 $length = count( $this->scratchTokens );
148 if ( $length === 1 && $this->scratchTokens[0] ===
"" ) {
151 for ( $i = 0; $i < $length; $i++ ) {
152 if ( $token === $this->scratchTokens[$i] ) {
154 unset( $this->scratchTokens[$i] );
156 $logger->info(
'OATHAuth user {user} used a scratch token from {clientip}', [
157 'user' => $user->getAccount(),
158 'clientip' => $clientIP,
162 $user->setKey( $this );
163 $oathrepo->persist( $user, $clientIP );
176 $this->secret[
'period'] * ( 1 + 2 * $wgOATHAuthWindowRadius )
180 $logger->info(
'OATHAuth user {user} failed OTP/scratch token from {clientip}', [
181 'user' => $user->getAccount(),
182 'clientip' => $clientIP,
186 $user->getUser()->pingLimiter(
'badoath' );
194 for ( $i = 0; $i < 10; $i++ ) {
209 return in_array( $token, $this->scratchTokens,
true );
216 return LoggerFactory::getInstance(
'authentication' );
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
wfMemcKey(... $args)
Make a cache key for the local wiki.
static decode($b32)
Decodes a base32 string into a binary string according to RFC 4648.
static encode($string)
Encodes a binary string into a base32 string according to RFC 4648 (no padding).
static generateByTimeWindow( $key, $window, $min=-1, $max=1, $timestamp=false)
Generate a HOTP key collection based on a timestamp and window size all keys that could exist between...
static getOATHUserRepository()
Get the singleton OATH user repository.
Class representing a two-factor key.
static newFromRandom()
Make a new key from random values.
regenerateScratchTokens()
isScratchToken( $token)
Check if a token is one of the scratch tokens for this two factor key.
const SCRATCH_TOKEN
Represents that a token corresponds to a scratch token.
__construct( $secret, array $scratchTokens)
array $secret
Two factor binary secret.
const MAIN_TOKEN
Represents that a token corresponds to the main secret.
string[] $scratchTokens
List of scratch tokens.
verifyToken( $token, OATHUser $user)
Verify a token against the secret or scratch tokens.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Ge...
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))