mirror of
https://github.com/delight-im/PHP-Auth.git
synced 2025-08-09 17:46:33 +02:00
Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
e7e174b05d | ||
|
8f35cc9965 |
@@ -25,9 +25,7 @@ CREATE TABLE IF NOT EXISTS "users_confirmations" (
|
|||||||
"token" VARCHAR(255) NOT NULL,
|
"token" VARCHAR(255) NOT NULL,
|
||||||
"expires" INTEGER NOT NULL CHECK ("expires" >= 0)
|
"expires" INTEGER NOT NULL CHECK ("expires" >= 0)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS "email_expires" ON "users_confirmations" ("email", "expires");
|
CREATE INDEX IF NOT EXISTS "email_expires" ON "users_confirmations" ("email", "expires");
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS "user_id" ON "users_confirmations" ("user_id");
|
CREATE INDEX IF NOT EXISTS "user_id" ON "users_confirmations" ("user_id");
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS "users_remembered" (
|
CREATE TABLE IF NOT EXISTS "users_remembered" (
|
||||||
@@ -37,7 +35,6 @@ CREATE TABLE IF NOT EXISTS "users_remembered" (
|
|||||||
"token" VARCHAR(255) NOT NULL,
|
"token" VARCHAR(255) NOT NULL,
|
||||||
"expires" INTEGER NOT NULL CHECK ("expires" >= 0)
|
"expires" INTEGER NOT NULL CHECK ("expires" >= 0)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS "user" ON "users_remembered" ("user");
|
CREATE INDEX IF NOT EXISTS "user" ON "users_remembered" ("user");
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS "users_resets" (
|
CREATE TABLE IF NOT EXISTS "users_resets" (
|
||||||
@@ -47,7 +44,6 @@ CREATE TABLE IF NOT EXISTS "users_resets" (
|
|||||||
"token" VARCHAR(255) NOT NULL,
|
"token" VARCHAR(255) NOT NULL,
|
||||||
"expires" INTEGER NOT NULL CHECK ("expires" >= 0)
|
"expires" INTEGER NOT NULL CHECK ("expires" >= 0)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS "user_expires" ON "users_resets" ("user", "expires");
|
CREATE INDEX IF NOT EXISTS "user_expires" ON "users_resets" ("user", "expires");
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS "users_throttling" (
|
CREATE TABLE IF NOT EXISTS "users_throttling" (
|
||||||
@@ -56,7 +52,6 @@ CREATE TABLE IF NOT EXISTS "users_throttling" (
|
|||||||
"replenished_at" INTEGER NOT NULL CHECK ("replenished_at" >= 0),
|
"replenished_at" INTEGER NOT NULL CHECK ("replenished_at" >= 0),
|
||||||
"expires_at" INTEGER NOT NULL CHECK ("expires_at" >= 0)
|
"expires_at" INTEGER NOT NULL CHECK ("expires_at" >= 0)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS "expires_at" ON "users_throttling" ("expires_at");
|
CREATE INDEX IF NOT EXISTS "expires_at" ON "users_throttling" ("expires_at");
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
22
src/Auth.php
22
src/Auth.php
@@ -48,7 +48,7 @@ final class Auth extends UserManager {
|
|||||||
$this->sessionResyncInterval = isset($sessionResyncInterval) ? ((int) $sessionResyncInterval) : (60 * 5);
|
$this->sessionResyncInterval = isset($sessionResyncInterval) ? ((int) $sessionResyncInterval) : (60 * 5);
|
||||||
$this->rememberCookieName = self::createRememberCookieName();
|
$this->rememberCookieName = self::createRememberCookieName();
|
||||||
|
|
||||||
$this->initSession();
|
$this->initSessionIfNecessary();
|
||||||
$this->enhanceHttpSecurity();
|
$this->enhanceHttpSecurity();
|
||||||
|
|
||||||
$this->processRememberDirective();
|
$this->processRememberDirective();
|
||||||
@@ -56,16 +56,18 @@ final class Auth extends UserManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Initializes the session and sets the correct configuration */
|
/** Initializes the session and sets the correct configuration */
|
||||||
private function initSession() {
|
private function initSessionIfNecessary() {
|
||||||
// use cookies to store session IDs
|
if (\session_status() === \PHP_SESSION_NONE) {
|
||||||
\ini_set('session.use_cookies', 1);
|
// use cookies to store session IDs
|
||||||
// use cookies only (do not send session IDs in URLs)
|
\ini_set('session.use_cookies', 1);
|
||||||
\ini_set('session.use_only_cookies', 1);
|
// use cookies only (do not send session IDs in URLs)
|
||||||
// do not send session IDs in URLs
|
\ini_set('session.use_only_cookies', 1);
|
||||||
\ini_set('session.use_trans_sid', 0);
|
// do not send session IDs in URLs
|
||||||
|
\ini_set('session.use_trans_sid', 0);
|
||||||
|
|
||||||
// start the session (requests a cookie to be written on the client)
|
// start the session (requests a cookie to be written on the client)
|
||||||
@Session::start();
|
@Session::start();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Improves the application's security over HTTP(S) by setting specific headers */
|
/** Improves the application's security over HTTP(S) by setting specific headers */
|
||||||
|
Reference in New Issue
Block a user