remove remaining password migration code
parent
747d3fb9c1
commit
3ea2b879dc
|
@ -564,7 +564,6 @@ user {
|
|||
}
|
||||
password.bpass {
|
||||
secret = "9qEYN0ThHer1KWLNekA76Q=="
|
||||
autoupgrade = true
|
||||
}
|
||||
}
|
||||
history {
|
||||
|
|
|
@ -245,9 +245,6 @@ object mon {
|
|||
def confirmEmailResult(v: Boolean) = inc(s"user.register.confirm_email.$v")
|
||||
}
|
||||
object auth {
|
||||
val shaBcUpgrade = inc("user.auth.sha_bc_upgrade")
|
||||
val bcFullMigrate = inc("user.auth.bc_full_migrate")
|
||||
val shaLogin = inc("user.auth.sha_login")
|
||||
val hashTime = rec("user.auth.hash_time")
|
||||
val hashTimeInc = incX("user.auth.hash_time_inc")
|
||||
def result(v: Boolean) = inc(s"user.auth.result.$v")
|
||||
|
|
|
@ -9,9 +9,7 @@ import lila.user.User.{ ClearPassword, BSONFields => F }
|
|||
|
||||
final class Authenticator(
|
||||
passHasher: PasswordHasher,
|
||||
userRepo: UserRepo.type,
|
||||
upgradeShaPasswords: Boolean,
|
||||
onShaLogin: () => Unit
|
||||
userRepo: UserRepo.type
|
||||
) {
|
||||
import Authenticator._
|
||||
|
||||
|
@ -46,17 +44,10 @@ final class Authenticator(
|
|||
$set(F.bpass -> passEnc(p).bytes) ++ $unset(F.salt, F.sha512)
|
||||
).void
|
||||
|
||||
private def authWithBenefits(auth: AuthData)(p: ClearPassword): Boolean = {
|
||||
val res = compare(auth, p)
|
||||
if (res && auth.salt.isDefined && upgradeShaPasswords)
|
||||
setPassword(id = auth._id, p) >>- lila.mon.user.auth.bcFullMigrate()
|
||||
res
|
||||
}
|
||||
|
||||
private def loginCandidate(select: Bdoc): Fu[Option[User.LoginCandidate]] =
|
||||
userRepo.coll.uno[AuthData](select, authProjection)(AuthDataBSONHandler) zip userRepo.coll.uno[User](select) map {
|
||||
case (Some(authData), Some(user)) if user.enabled =>
|
||||
User.LoginCandidate(user, authWithBenefits(authData)).some
|
||||
User.LoginCandidate(user, compare(authData, _)).some
|
||||
case _ => none
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ final class Env(
|
|||
val CollectionTrophy = config getString "collection.trophy"
|
||||
val CollectionRanking = config getString "collection.ranking"
|
||||
val PasswordBPassSecret = config getString "password.bpass.secret"
|
||||
val PasswordUpgradeSha = config getBoolean "password.bpass.autoupgrade"
|
||||
}
|
||||
import settings._
|
||||
|
||||
|
@ -89,9 +88,7 @@ final class Env(
|
|||
}
|
||||
}
|
||||
),
|
||||
userRepo = UserRepo,
|
||||
upgradeShaPasswords = PasswordUpgradeSha,
|
||||
onShaLogin = lila.mon.user.auth.shaLogin
|
||||
userRepo = UserRepo
|
||||
)
|
||||
|
||||
lazy val forms = new DataForm(authenticator)
|
||||
|
|
|
@ -10,9 +10,7 @@ class AuthTest extends Specification {
|
|||
val secret = Array.fill(32)(1.toByte).toBase64
|
||||
def getAuth(passHasher: PasswordHasher) = new Authenticator(
|
||||
passHasher = passHasher,
|
||||
userRepo = null,
|
||||
upgradeShaPasswords = false,
|
||||
onShaLogin = () => ()
|
||||
userRepo = null
|
||||
)
|
||||
|
||||
val auth = getAuth(new PasswordHasher(secret, 2))
|
||||
|
|
Loading…
Reference in New Issue