mirror of
https://github.com/openvk/chandler.git
synced 2025-01-22 15:24:15 +03:00
UA and IP checks can now be disabled via extendedValidation option
This commit is contained in:
parent
60bbd5b8b5
commit
586aa99cd6
2 changed files with 10 additions and 1 deletions
|
@ -20,4 +20,5 @@ chandler:
|
||||||
security:
|
security:
|
||||||
secret: ""
|
secret: ""
|
||||||
csrfProtection: "permissive"
|
csrfProtection: "permissive"
|
||||||
|
extendedValidation: false
|
||||||
sessionDuration: 14
|
sessionDuration: 14
|
||||||
|
|
|
@ -27,6 +27,7 @@ class Authenticator
|
||||||
->table("ChandlerTokens")
|
->table("ChandlerTokens")
|
||||||
->where($data)
|
->where($data)
|
||||||
->fetch();
|
->fetch();
|
||||||
|
|
||||||
if(!$token) {
|
if(!$token) {
|
||||||
$this->db->table("ChandlerTokens")->insert($data);
|
$this->db->table("ChandlerTokens")->insert($data);
|
||||||
$token = $this->db->table("ChandlerTokens")->where($data)->fetch();
|
$token = $this->db->table("ChandlerTokens")->where($data)->fetch();
|
||||||
|
@ -68,9 +69,16 @@ class Authenticator
|
||||||
"token" => $token,
|
"token" => $token,
|
||||||
])
|
])
|
||||||
->fetch();
|
->fetch();
|
||||||
|
|
||||||
if(!$token) return null;
|
if(!$token) return null;
|
||||||
|
|
||||||
if($token->ip === CONNECTING_IP && $token->ua === $_SERVER["HTTP_USER_AGENT"]) {
|
$checksPassed = false;
|
||||||
|
if(CHANDLER_ROOT_CONF["security"]["extendedValidation"])
|
||||||
|
$checksPassed = $token->ip === CONNECTING_IP && $token->ua === $_SERVER["HTTP_USER_AGENT"];
|
||||||
|
else
|
||||||
|
$checksPassed = true;
|
||||||
|
|
||||||
|
if($checksPassed) {
|
||||||
$su = $this->session->get("_su");
|
$su = $this->session->get("_su");
|
||||||
$user = $this->db->table("ChandlerUsers")->get($su ?? $token->user);
|
$user = $this->db->table("ChandlerUsers")->get($su ?? $token->user);
|
||||||
if(!$user) return null;
|
if(!$user) return null;
|
||||||
|
|
Loading…
Reference in a new issue