Modificiones para que funcione el Shield y updates

This commit is contained in:
imnavajas
2024-05-01 15:33:01 +02:00
parent f80d0dc52a
commit c78b3d8488
35 changed files with 1720 additions and 727 deletions

47
.idea/php.xml generated
View File

@ -10,6 +10,53 @@
<option name="highlightLevel" value="WARNING" />
<option name="transferred" value="true" />
</component>
<component name="PhpIncludePathManager">
<include_path>
<path value="$PROJECT_DIR$/ci4/vendor/psr/log" />
<path value="$PROJECT_DIR$/ci4/vendor/psr/container" />
<path value="$PROJECT_DIR$/ci4/vendor/nikic/php-parser" />
<path value="$PROJECT_DIR$/ci4/vendor/phenx/php-svg-lib" />
<path value="$PROJECT_DIR$/ci4/vendor/phenx/php-font-lib" />
<path value="$PROJECT_DIR$/ci4/vendor/dompdf/dompdf" />
<path value="$PROJECT_DIR$/ci4/vendor/laminas/laminas-escaper" />
<path value="$PROJECT_DIR$/ci4/vendor/myclabs/deep-copy" />
<path value="$PROJECT_DIR$/ci4/vendor/phar-io/version" />
<path value="$PROJECT_DIR$/ci4/vendor/phar-io/manifest" />
<path value="$PROJECT_DIR$/ci4/vendor/phpunit/phpunit" />
<path value="$PROJECT_DIR$/ci4/vendor/phpunit/php-timer" />
<path value="$PROJECT_DIR$/ci4/vendor/phpunit/php-invoker" />
<path value="$PROJECT_DIR$/ci4/vendor/phpunit/php-code-coverage" />
<path value="$PROJECT_DIR$/ci4/vendor/phpunit/php-file-iterator" />
<path value="$PROJECT_DIR$/ci4/vendor/phpunit/php-text-template" />
<path value="$PROJECT_DIR$/ci4/vendor/symfony/deprecation-contracts" />
<path value="$PROJECT_DIR$/ci4/vendor/theseer/tokenizer" />
<path value="$PROJECT_DIR$/ci4/vendor/composer" />
<path value="$PROJECT_DIR$/ci4/vendor/doctrine/instantiator" />
<path value="$PROJECT_DIR$/ci4/vendor/fakerphp/faker" />
<path value="$PROJECT_DIR$/ci4/vendor/mikey179/vfsstream" />
<path value="$PROJECT_DIR$/ci4/vendor/sebastian/diff" />
<path value="$PROJECT_DIR$/ci4/vendor/sebastian/type" />
<path value="$PROJECT_DIR$/ci4/vendor/sebastian/version" />
<path value="$PROJECT_DIR$/ci4/vendor/sebastian/exporter" />
<path value="$PROJECT_DIR$/ci4/vendor/sebastian/code-unit" />
<path value="$PROJECT_DIR$/ci4/vendor/sebastian/cli-parser" />
<path value="$PROJECT_DIR$/ci4/vendor/sebastian/comparator" />
<path value="$PROJECT_DIR$/ci4/vendor/sebastian/complexity" />
<path value="$PROJECT_DIR$/ci4/vendor/sebastian/environment" />
<path value="$PROJECT_DIR$/ci4/vendor/sebastian/global-state" />
<path value="$PROJECT_DIR$/ci4/vendor/sebastian/lines-of-code" />
<path value="$PROJECT_DIR$/ci4/vendor/sebastian/object-reflector" />
<path value="$PROJECT_DIR$/ci4/vendor/sebastian/object-enumerator" />
<path value="$PROJECT_DIR$/ci4/vendor/sebastian/recursion-context" />
<path value="$PROJECT_DIR$/ci4/vendor/sebastian/resource-operations" />
<path value="$PROJECT_DIR$/ci4/vendor/sebastian/code-unit-reverse-lookup" />
<path value="$PROJECT_DIR$/ci4/vendor/sabberworm/php-css-parser" />
<path value="$PROJECT_DIR$/ci4/vendor/masterminds/html5" />
<path value="$PROJECT_DIR$/ci4/vendor/codeigniter4/shield" />
<path value="$PROJECT_DIR$/ci4/vendor/codeigniter4/settings" />
<path value="$PROJECT_DIR$/ci4/vendor/codeigniter4/framework" />
</include_path>
</component>
<component name="PhpProjectSharedConfiguration" php_language_level="8.1">
<option name="suggestChangeDefaultLanguageLevel" value="false" />
</component>

View File

@ -11,19 +11,12 @@ class App extends BaseConfig
* Base Site URL
* --------------------------------------------------------------------------
*
* URL to your CodeIgniter root. Typically this will be your base URL,
* URL to your CodeIgniter root. Typically, this will be your base URL,
* WITH a trailing slash:
*
* http://example.com/
*
* If this is not set then CodeIgniter will try guess the protocol, domain
* and path to your installation. However, you should always configure this
* explicitly and never rely on auto-guessing, especially in production
* environments.
*
* @var string
* E.g., http://example.com/
*/
public $baseURL = '';
public string $baseURL = '';
/**
* Allowed Hostnames in the Site URL other than the hostname in the baseURL.
@ -43,33 +36,28 @@ class App extends BaseConfig
* Index File
* --------------------------------------------------------------------------
*
* Typically this will be your index.php file, unless you've renamed it to
* something else. If you are using mod_rewrite to remove the page set this
* variable so that it is blank.
*
* @var string
* Typically, this will be your `index.php` file, unless you've renamed it to
* something else. If you have configured your web server to remove this file
* from your site URIs, set this variable to an empty string.
*/
public $indexPage = '';
public string $indexPage = '';
/**
* --------------------------------------------------------------------------
* URI PROTOCOL
* --------------------------------------------------------------------------
*
* This item determines which getServer global should be used to retrieve the
* URI string. The default setting of 'REQUEST_URI' works for most servers.
* This item determines which server global should be used to retrieve the
* URI string. The default setting of 'REQUEST_URI' works for most servers.
* If your links do not seem to work, try one of the other delicious flavors:
*
* 'REQUEST_URI' Uses $_SERVER['REQUEST_URI']
* 'QUERY_STRING' Uses $_SERVER['QUERY_STRING']
* 'PATH_INFO' Uses $_SERVER['PATH_INFO']
* 'REQUEST_URI': Uses $_SERVER['REQUEST_URI']
* 'QUERY_STRING': Uses $_SERVER['QUERY_STRING']
* 'PATH_INFO': Uses $_SERVER['PATH_INFO']
*
* WARNING: If you set this to 'PATH_INFO', URIs will always be URL-decoded!
*
* @var string
*/
public $uriProtocol = 'REQUEST_URI';
public string $uriProtocol = 'REQUEST_URI';
/**
* --------------------------------------------------------------------------
@ -80,10 +68,8 @@ class App extends BaseConfig
* is viewing the site from. It affects the language strings and other
* strings (like currency markers, numbers, etc), that your program
* should run under for this request.
*
* @var string
*/
public $defaultLocale = 'es';
public string $defaultLocale = 'es';
/**
* --------------------------------------------------------------------------
@ -94,10 +80,8 @@ class App extends BaseConfig
* language to use based on the value of the Accept-Language header.
*
* If false, no automatic detection will be performed.
*
* @var bool
*/
public $negotiateLocale = true;
public bool $negotiateLocale = false;
/**
* --------------------------------------------------------------------------
@ -108,9 +92,11 @@ class App extends BaseConfig
* by the application in descending order of priority. If no match is
* found, the first locale will be used.
*
* @var string[]
* IncomingRequest::setLocale() also uses this list.
*
* @var list<string>
*/
public $supportedLocales = ['en','es'];
public array $supportedLocales = ['en', 'es'];
/**
* --------------------------------------------------------------------------
@ -120,9 +106,10 @@ class App extends BaseConfig
* The default timezone that will be used in your application to display
* dates with the date helper, and can be retrieved through app_timezone()
*
* @var string
* @see https://www.php.net/manual/en/timezones.php for list of timezones
* supported by PHP.
*/
public $appTimezone = 'Europe/Madrid';
public string $appTimezone = 'Europe/Madrid';
/**
* --------------------------------------------------------------------------
@ -133,211 +120,20 @@ class App extends BaseConfig
* that require a character set to be provided.
*
* @see http://php.net/htmlspecialchars for a list of supported charsets.
*
* @var string
*/
public $charset = 'UTF-8';
public string $charset = 'UTF-8';
/**
* --------------------------------------------------------------------------
* URI PROTOCOL
* Force Global Secure Requests
* --------------------------------------------------------------------------
*
* If true, this will force every request made to this application to be
* made via a secure connection (HTTPS). If the incoming request is not
* secure, the user will be redirected to a secure version of the page
* and the HTTP Strict Transport Security header will be set.
*
* @var bool
* and the HTTP Strict Transport Security (HSTS) header will be set.
*/
public $forceGlobalSecureRequests = false;
/**
* --------------------------------------------------------------------------
* Session Driver
* --------------------------------------------------------------------------
*
* The session storage driver to use:
* - `CodeIgniter\Session\Handlers\FileHandler`
* - `CodeIgniter\Session\Handlers\DatabaseHandler`
* - `CodeIgniter\Session\Handlers\MemcachedHandler`
* - `CodeIgniter\Session\Handlers\RedisHandler`
*
* @var string
*/
public $sessionDriver = 'CodeIgniter\Session\Handlers\FileHandler';
/**
* --------------------------------------------------------------------------
* Session Cookie Name
* --------------------------------------------------------------------------
*
* The session cookie name, must contain only [0-9a-z_-] characters
*
* @var string
*/
public $sessionCookieName = 'ci_session';
/**
* --------------------------------------------------------------------------
* Session Expiration
* --------------------------------------------------------------------------
*
* The number of SECONDS you want the session to last.
* Setting to 0 (zero) means expire when the browser is closed.
*
* @var int
*/
public $sessionExpiration = 7200;
/**
* --------------------------------------------------------------------------
* Session Save Path
* --------------------------------------------------------------------------
*
* The location to save sessions to and is driver dependent.
*
* For the 'files' driver, it's a path to a writable directory.
* WARNING: Only absolute paths are supported!
*
* For the 'database' driver, it's a table name.
* Please read up the manual for the format with other session drivers.
*
* IMPORTANT: You are REQUIRED to set a valid save path!
*
* @var string
*/
public $sessionSavePath = WRITEPATH . 'session';
/**
* --------------------------------------------------------------------------
* Session Match IP
* --------------------------------------------------------------------------
*
* Whether to match the user's IP address when reading the session data.
*
* WARNING: If you're using the database driver, don't forget to update
* your session table's PRIMARY KEY when changing this setting.
*
* @var bool
*/
public $sessionMatchIP = false;
/**
* --------------------------------------------------------------------------
* Session Time to Update
* --------------------------------------------------------------------------
*
* How many seconds between CI regenerating the session ID.
*
* @var int
*/
public $sessionTimeToUpdate = 300;
/**
* --------------------------------------------------------------------------
* Session Regenerate Destroy
* --------------------------------------------------------------------------
*
* Whether to destroy session data associated with the old session ID
* when auto-regenerating the session ID. When set to FALSE, the data
* will be later deleted by the garbage collector.
*
* @var bool
*/
public $sessionRegenerateDestroy = false;
/**
* --------------------------------------------------------------------------
* Cookie Prefix
* --------------------------------------------------------------------------
*
* Set a cookie name prefix if you need to avoid collisions.
*
* @var string
*
* @deprecated use Config\Cookie::$prefix property instead.
*/
public $cookiePrefix = '';
/**
* --------------------------------------------------------------------------
* Cookie Domain
* --------------------------------------------------------------------------
*
* Set to `.your-domain.com` for site-wide cookies.
*
* @var string
*
* @deprecated use Config\Cookie::$domain property instead.
*/
public $cookieDomain = '';
/**
* --------------------------------------------------------------------------
* Cookie Path
* --------------------------------------------------------------------------
*
* Typically will be a forward slash.
*
* @var string
*
* @deprecated use Config\Cookie::$path property instead.
*/
public $cookiePath = '/';
/**
* --------------------------------------------------------------------------
* Cookie Secure
* --------------------------------------------------------------------------
*
* Cookie will only be set if a secure HTTPS connection exists.
*
* @var bool
*
* @deprecated use Config\Cookie::$secure property instead.
*/
public $cookieSecure = false;
/**
* --------------------------------------------------------------------------
* Cookie HttpOnly
* --------------------------------------------------------------------------
*
* Cookie will only be accessible via HTTP(S) (no JavaScript).
*
* @var bool
*
* @deprecated use Config\Cookie::$httponly property instead.
*/
public $cookieHTTPOnly = true;
/**
* --------------------------------------------------------------------------
* Cookie SameSite
* --------------------------------------------------------------------------
*
* Configure cookie SameSite setting. Allowed values are:
* - None
* - Lax
* - Strict
* - ''
*
* Alternatively, you can use the constant names:
* - `Cookie::SAMESITE_NONE`
* - `Cookie::SAMESITE_LAX`
* - `Cookie::SAMESITE_STRICT`
*
* Defaults to `Lax` for compatibility with modern browsers. Setting `''`
* (empty string) means default SameSite attribute set by browsers (`Lax`)
* will be set on cookies. If set to `None`, `$cookieSecure` must also be set.
*
* @var string
*
* @deprecated use Config\Cookie::$samesite property instead.
*/
public $cookieSameSite = 'Lax';
public bool $forceGlobalSecureRequests = false;
/**
* --------------------------------------------------------------------------
@ -362,104 +158,6 @@ class App extends BaseConfig
*/
public array $proxyIPs = [];
/**
* --------------------------------------------------------------------------
* CSRF Token Name
* --------------------------------------------------------------------------
*
* The token name.
*
* @deprecated Use `Config\Security` $tokenName property instead of using this property.
*
* @var string
*/
public $CSRFTokenName = 'csrf_test_name';
/**
* --------------------------------------------------------------------------
* CSRF Header Name
* --------------------------------------------------------------------------
*
* The header name.
*
* @deprecated Use `Config\Security` $headerName property instead of using this property.
*
* @var string
*/
public $CSRFHeaderName = 'X-CSRF-TOKEN';
/**
* --------------------------------------------------------------------------
* CSRF Cookie Name
* --------------------------------------------------------------------------
*
* The cookie name.
*
* @deprecated Use `Config\Security` $cookieName property instead of using this property.
*
* @var string
*/
public $CSRFCookieName = 'csrf_cookie_name';
/**
* --------------------------------------------------------------------------
* CSRF Expire
* --------------------------------------------------------------------------
*
* The number in seconds the token should expire.
*
* @deprecated Use `Config\Security` $expire property instead of using this property.
*
* @var int
*/
public $CSRFExpire = 7200;
/**
* --------------------------------------------------------------------------
* CSRF Regenerate
* --------------------------------------------------------------------------
*
* Regenerate token on every submission?
*
* @deprecated Use `Config\Security` $regenerate property instead of using this property.
*
* @var bool
*/
public $CSRFRegenerate = true;
/**
* --------------------------------------------------------------------------
* CSRF Redirect
* --------------------------------------------------------------------------
*
* Redirect to previous page with error on failure?
*
* @deprecated Use `Config\Security` $redirect property instead of using this property.
*
* @var bool
*/
public $CSRFRedirect = true;
/**
* --------------------------------------------------------------------------
* CSRF SameSite
* --------------------------------------------------------------------------
*
* Setting for CSRF SameSite cookie token. Allowed values are:
* - None
* - Lax
* - Strict
* - ''
*
* Defaults to `Lax` as recommended in this link:
*
* @see https://portswigger.net/web-security/csrf/samesite-cookies
* @deprecated Use `Config\Security` $samesite property instead of using this property.
*
* @var string
*/
public $CSRFSameSite = 'Lax';
/**
* --------------------------------------------------------------------------
* Content Security Policy
@ -475,9 +173,6 @@ class App extends BaseConfig
*
* @see http://www.html5rocks.com/en/tutorials/security/content-security-policy/
* @see http://www.w3.org/TR/CSP/
*
* @var bool
*/
public $CSPEnabled = false;
public bool $CSPEnabled = false;
}

529
ci4/app/Config/Auth.php Normal file
View File

@ -0,0 +1,529 @@
<?php
declare(strict_types=1);
/**
* This file is part of CodeIgniter Shield.
*
* (c) CodeIgniter Foundation <admin@codeigniter.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Config;
use CodeIgniter\Shield\Config\Auth as ShieldAuth;
use CodeIgniter\Shield\Authentication\Actions\ActionInterface;
use CodeIgniter\Shield\Authentication\AuthenticatorInterface;
use CodeIgniter\Shield\Authentication\Authenticators\AccessTokens;
use CodeIgniter\Shield\Authentication\Authenticators\HmacSha256;
use CodeIgniter\Shield\Authentication\Authenticators\JWT;
use CodeIgniter\Shield\Authentication\Authenticators\Session;
use CodeIgniter\Shield\Authentication\Passwords\CompositionValidator;
use CodeIgniter\Shield\Authentication\Passwords\DictionaryValidator;
use CodeIgniter\Shield\Authentication\Passwords\NothingPersonalValidator;
use CodeIgniter\Shield\Authentication\Passwords\PwnedValidator;
use CodeIgniter\Shield\Authentication\Passwords\ValidatorInterface;
use CodeIgniter\Shield\Models\UserModel;
class Auth extends ShieldAuth
{
/**
* ////////////////////////////////////////////////////////////////////
* AUTHENTICATION
* ////////////////////////////////////////////////////////////////////
*/
// Constants for Record Login Attempts. Do not change.
public const RECORD_LOGIN_ATTEMPT_NONE = 0; // Do not record at all
public const RECORD_LOGIN_ATTEMPT_FAILURE = 1; // Record only failures
public const RECORD_LOGIN_ATTEMPT_ALL = 2; // Record all login attempts
/**
* --------------------------------------------------------------------
* View files
* --------------------------------------------------------------------
*/
public array $views = [
'login' => '\App\Views\Shield\login',
'register' => '\App\Views\Shield\register',
'layout' => '\App\Views\Shield\layout',
'action_email_2fa' => '\CodeIgniter\Shield\Views\email_2fa_show',
'action_email_2fa_verify' => '\CodeIgniter\Shield\Views\email_2fa_verify',
'action_email_2fa_email' => '\CodeIgniter\Shield\Views\Email\email_2fa_email',
'action_email_activate_show' => '\CodeIgniter\Shield\Views\email_activate_show',
'action_email_activate_email' => '\CodeIgniter\Shield\Views\Email\email_activate_email',
'magic-link-login' => '\App\Views\Shield\magic_link_form',
'magic-link-message' => '\CodeIgniter\Shield\Views\magic_link_message',
'magic-link-email' => '\CodeIgniter\Shield\Views\Email\magic_link_email',
];
/**
* --------------------------------------------------------------------
* Redirect URLs
* --------------------------------------------------------------------
* The default URL that a user will be redirected to after various auth
* actions. This can be either of the following:
*
* 1. An absolute URL. E.g. http://example.com OR https://example.com
* 2. A named route that can be accessed using `route_to()` or `url_to()`
* 3. A URI path within the application. e.g 'admin', 'login', 'expath'
*
* If you need more flexibility you can override the `getUrl()` method
* to apply any logic you may need.
*/
public array $redirects = [
'register' => '/',
'login' => '/',
'logout' => 'login',
'force_reset' => '/',
'permission_denied' => '/',
'group_denied' => '/',
];
/**
* --------------------------------------------------------------------
* Authentication Actions
* --------------------------------------------------------------------
* Specifies the class that represents an action to take after
* the user logs in or registers a new account at the site.
*
* You must register actions in the order of the actions to be performed.
*
* Available actions with Shield:
* - register: \CodeIgniter\Shield\Authentication\Actions\EmailActivator::class
* - login: \CodeIgniter\Shield\Authentication\Actions\Email2FA::class
*
* @var array<string, class-string<ActionInterface>|null>
*/
public array $actions = [
'register' => null,
'login' => null,
];
/**
* --------------------------------------------------------------------
* Authenticators
* --------------------------------------------------------------------
* The available authentication systems, listed
* with alias and class name. These can be referenced
* by alias in the auth helper:
* auth('tokens')->attempt($credentials);
*
* @var array<string, class-string<AuthenticatorInterface>>
*/
public array $authenticators = [
'tokens' => AccessTokens::class,
'session' => Session::class,
'hmac' => HmacSha256::class,
// 'jwt' => JWT::class,
];
/**
* --------------------------------------------------------------------
* Default Authenticator
* --------------------------------------------------------------------
* The Authenticator to use when none is specified.
* Uses the $key from the $authenticators array above.
*/
public string $defaultAuthenticator = 'session';
/**
* --------------------------------------------------------------------
* Authentication Chain
* --------------------------------------------------------------------
* The Authenticators to test logged in status against
* when using the 'chain' filter. Each Authenticator listed will be checked.
* If no match is found, then the next in the chain will be checked.
*
* @var string[]
* @phpstan-var list<string>
*/
public array $authenticationChain = [
'session',
'tokens',
'hmac',
// 'jwt',
];
/**
* --------------------------------------------------------------------
* Allow Registration
* --------------------------------------------------------------------
* Determines whether users can register for the site.
*/
public bool $allowRegistration = true;
/**
* --------------------------------------------------------------------
* Record Last Active Date
* --------------------------------------------------------------------
* If true, will always update the `last_active` datetime for the
* logged-in user on every page request.
* This feature only works when session/tokens filter is active.
*
* @see https://codeigniter4.github.io/shield/quick_start_guide/using_session_auth/#protecting-pages for set filters.
*/
public bool $recordActiveDate = true;
/**
* --------------------------------------------------------------------
* Allow Magic Link Logins
* --------------------------------------------------------------------
* If true, will allow the use of "magic links" sent via the email
* as a way to log a user in without the need for a password.
* By default, this is used in place of a password reset flow, but
* could be modified as the only method of login once an account
* has been set up.
*/
public bool $allowMagicLinkLogins = true;
/**
* --------------------------------------------------------------------
* Magic Link Lifetime
* --------------------------------------------------------------------
* Specifies the amount of time, in seconds, that a magic link is valid.
* You can use Time Constants or any desired number.
*/
public int $magicLinkLifetime = HOUR;
/**
* --------------------------------------------------------------------
* Session Authenticator Configuration
* --------------------------------------------------------------------
* These settings only apply if you are using the Session Authenticator
* for authentication.
*
* - field The name of the key the current user info is stored in session
* - allowRemembering Does the system allow use of "remember-me"
* - rememberCookieName The name of the cookie to use for "remember-me"
* - rememberLength The length of time, in seconds, to remember a user.
*
* @var array<string, bool|int|string>
*/
public array $sessionConfig = [
'field' => 'user',
'allowRemembering' => true,
'rememberCookieName' => 'remember',
'rememberLength' => 30 * DAY,
];
/**
* --------------------------------------------------------------------
* The validation rules for username
* --------------------------------------------------------------------
*
* Do not use string rules like `required|valid_email`.
*
* @var array<string, array<int, string>|string>
*/
public array $usernameValidationRules = [
'label' => 'Auth.username',
'rules' => [
'required',
'max_length[30]',
'min_length[3]',
'regex_match[/\A[a-zA-Z0-9\.]+\z/]',
],
];
/**
* --------------------------------------------------------------------
* The validation rules for email
* --------------------------------------------------------------------
*
* Do not use string rules like `required|valid_email`.
*
* @var array<string, array<int, string>|string>
*/
public array $emailValidationRules = [
'label' => 'Auth.email',
'rules' => [
'required',
'max_length[254]',
'valid_email',
],
];
/**
* --------------------------------------------------------------------
* Minimum Password Length
* --------------------------------------------------------------------
* The minimum length that a password must be to be accepted.
* Recommended minimum value by NIST = 8 characters.
*/
public int $minimumPasswordLength = 8;
/**
* --------------------------------------------------------------------
* Password Check Helpers
* --------------------------------------------------------------------
* The PasswordValidator class runs the password through all of these
* classes, each getting the opportunity to pass/fail the password.
* You can add custom classes as long as they adhere to the
* CodeIgniter\Shield\Authentication\Passwords\ValidatorInterface.
*
* @var class-string<ValidatorInterface>[]
*/
public array $passwordValidators = [
CompositionValidator::class,
NothingPersonalValidator::class,
DictionaryValidator::class,
// PwnedValidator::class,
];
/**
* --------------------------------------------------------------------
* Valid login fields
* --------------------------------------------------------------------
* Fields that are available to be used as credentials for login.
*/
public array $validFields = [
'email',
// 'username',
];
/**
* --------------------------------------------------------------------
* Additional Fields for "Nothing Personal"
* --------------------------------------------------------------------
* The NothingPersonalValidator prevents personal information from
* being used in passwords. The email and username fields are always
* considered by the validator. Do not enter those field names here.
*
* An extended User Entity might include other personal info such as
* first and/or last names. $personalFields is where you can add
* fields to be considered as "personal" by the NothingPersonalValidator.
* For example:
* $personalFields = ['firstname', 'lastname'];
*/
public array $personalFields = [];
/**
* --------------------------------------------------------------------
* Password / Username Similarity
* --------------------------------------------------------------------
* Among other things, the NothingPersonalValidator checks the
* amount of sameness between the password and username.
* Passwords that are too much like the username are invalid.
*
* The value set for $maxSimilarity represents the maximum percentage
* of similarity at which the password will be accepted. In other words, any
* calculated similarity equal to, or greater than $maxSimilarity
* is rejected.
*
* The accepted range is 0-100, with 0 (zero) meaning don't check similarity.
* Using values at either extreme of the *working range* (1-100) is
* not advised. The low end is too restrictive and the high end is too permissive.
* The suggested value for $maxSimilarity is 50.
*
* You may be thinking that a value of 100 should have the effect of accepting
* everything like a value of 0 does. That's logical and probably true,
* but is unproven and untested. Besides, 0 skips the work involved
* making the calculation unlike when using 100.
*
* The (admittedly limited) testing that's been done suggests a useful working range
* of 50 to 60. You can set it lower than 50, but site users will probably start
* to complain about the large number of proposed passwords getting rejected.
* At around 60 or more it starts to see pairs like 'captain joe' and 'joe*captain' as
* perfectly acceptable which clearly they are not.
*
* To disable similarity checking set the value to 0.
* public $maxSimilarity = 0;
*/
public int $maxSimilarity = 50;
/**
* --------------------------------------------------------------------
* Hashing Algorithm to use
* --------------------------------------------------------------------
* Valid values are
* - PASSWORD_DEFAULT (default)
* - PASSWORD_BCRYPT
* - PASSWORD_ARGON2I - As of PHP 7.2 only if compiled with support for it
* - PASSWORD_ARGON2ID - As of PHP 7.3 only if compiled with support for it
*/
public string $hashAlgorithm = PASSWORD_DEFAULT;
/**
* --------------------------------------------------------------------
* ARGON2I/ARGON2ID Algorithm options
* --------------------------------------------------------------------
* The ARGON2I method of hashing allows you to define the "memory_cost",
* the "time_cost" and the number of "threads", whenever a password hash is
* created.
*/
public int $hashMemoryCost = 65536; // PASSWORD_ARGON2_DEFAULT_MEMORY_COST;
public int $hashTimeCost = 4; // PASSWORD_ARGON2_DEFAULT_TIME_COST;
public int $hashThreads = 1; // PASSWORD_ARGON2_DEFAULT_THREADS;
/**
* --------------------------------------------------------------------
* BCRYPT Algorithm options
* --------------------------------------------------------------------
* The BCRYPT method of hashing allows you to define the "cost"
* or number of iterations made, whenever a password hash is created.
* This defaults to a value of 12 which is an acceptable number.
* However, depending on the security needs of your application
* and the power of your hardware, you might want to increase the
* cost. This makes the hashing process takes longer.
*
* Valid range is between 4 - 31.
*/
public int $hashCost = 12;
/**
* ////////////////////////////////////////////////////////////////////
* OTHER SETTINGS
* ////////////////////////////////////////////////////////////////////
*/
/**
* --------------------------------------------------------------------
* Customize the DB group used for each model
* --------------------------------------------------------------------
*/
public ?string $DBGroup = null;
/**
* --------------------------------------------------------------------
* Customize Name of Shield Tables
* --------------------------------------------------------------------
* Only change if you want to rename the default Shield table names
*
* It may be necessary to change the names of the tables for
* security reasons, to prevent the conflict of table names,
* the internal policy of the companies or any other reason.
*
* - users Auth Users Table, the users info is stored.
* - auth_identities Auth Identities Table, Used for storage of passwords, access tokens, social login identities, etc.
* - auth_logins Auth Login Attempts, Table records login attempts.
* - auth_token_logins Auth Token Login Attempts Table, Records Bearer Token type login attempts.
* - auth_remember_tokens Auth Remember Tokens (remember-me) Table.
* - auth_groups_users Groups Users Table.
* - auth_permissions_users Users Permissions Table.
*
* @var array<string, string>
*/
public array $tables = [
'users' => 'users',
'identities' => 'auth_identities',
'logins' => 'auth_logins',
'token_logins' => 'auth_token_logins',
'remember_tokens' => 'auth_remember_tokens',
'groups_users' => 'auth_groups_users',
'permissions_users' => 'auth_permissions_users',
];
/**
* --------------------------------------------------------------------
* User Provider
* --------------------------------------------------------------------
* The name of the class that handles user persistence.
* By default, this is the included UserModel, which
* works with any of the database engines supported by CodeIgniter.
* You can change it as long as they adhere to the
* CodeIgniter\Shield\Models\UserModel.
*
* @var class-string<UserModel>
*/
public string $userProvider = UserModel::class;
/**
* Returns the URL that a user should be redirected
* to after a successful login.
*/
public function loginRedirect(): string
{
$session = session();
$url = $session->getTempdata('beforeLoginUrl') ?? setting('Auth.redirects')['login'];
return $this->getUrl($url);
}
/**
* Returns the URL that a user should be redirected
* to after they are logged out.
*/
public function logoutRedirect(): string
{
$url = setting('Auth.redirects')['logout'];
return $this->getUrl($url);
}
/**
* Returns the URL the user should be redirected to
* after a successful registration.
*/
public function registerRedirect(): string
{
$url = setting('Auth.redirects')['register'];
return $this->getUrl($url);
}
/**
* Returns the URL the user should be redirected to
* if force_reset identity is set to true.
*/
public function forcePasswordResetRedirect(): string
{
$url = setting('Auth.redirects')['force_reset'];
return $this->getUrl($url);
}
/**
* Returns the URL the user should be redirected to
* if permission denied.
*/
public function permissionDeniedRedirect(): string
{
$url = setting('Auth.redirects')['permission_denied'];
return $this->getUrl($url);
}
/**
* Returns the URL the user should be redirected to
* if group denied.
*/
public function groupDeniedRedirect(): string
{
$url = setting('Auth.redirects')['group_denied'];
return $this->getUrl($url);
}
/**
* Accepts a string which can be an absolute URL or
* a named route or just a URI path, and returns the
* full path.
*
* @param string $url an absolute URL or a named route or just URI path
*/
protected function getUrl(string $url): string
{
// To accommodate all url patterns
$final_url = '';
switch (true) {
case strpos($url, 'http://') === 0 || strpos($url, 'https://') === 0: // URL begins with 'http' or 'https'. E.g. http://example.com
$final_url = $url;
break;
case route_to($url) !== false: // URL is a named-route
$final_url = rtrim(url_to($url), '/ ');
break;
default: // URL is a route (URI path)
$final_url = rtrim(site_url($url), '/ ');
break;
}
return $final_url;
}
}

View File

@ -0,0 +1,120 @@
<?php
declare(strict_types=1);
/**
* This file is part of CodeIgniter Shield.
*
* (c) CodeIgniter Foundation <admin@codeigniter.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Config;
use CodeIgniter\Shield\Config\AuthGroups as ShieldAuthGroups;
class AuthGroups extends ShieldAuthGroups
{
/**
* --------------------------------------------------------------------
* Default Group
* --------------------------------------------------------------------
* The group that a newly registered user is added to.
*/
public string $defaultGroup = 'user';
/**
* --------------------------------------------------------------------
* Groups
* --------------------------------------------------------------------
* An associative array of the available groups in the system, where the keys
* are the group names and the values are arrays of the group info.
*
* Whatever value you assign as the key will be used to refer to the group
* when using functions such as:
* $user->addGroup('superadmin');
*
* @var array<string, array<string, string>>
*
* @see https://codeigniter4.github.io/shield/quick_start_guide/using_authorization/#change-available-groups for more info
*/
public array $groups = [
'superadmin' => [
'title' => 'Super Admin',
'description' => 'Complete control of the site.',
],
'admin' => [
'title' => 'Admin',
'description' => 'Day to day administrators of the site.',
],
'developer' => [
'title' => 'Developer',
'description' => 'Site programmers.',
],
'user' => [
'title' => 'User',
'description' => 'General users of the site. Often customers.',
],
'beta' => [
'title' => 'Beta User',
'description' => 'Has access to beta-level features.',
],
];
/**
* --------------------------------------------------------------------
* Permissions
* --------------------------------------------------------------------
* The available permissions in the system.
*
* If a permission is not listed here it cannot be used.
*/
public array $permissions = [
'admin.access' => 'Can access the sites admin area',
'admin.settings' => 'Can access the main site settings',
'users.manage-admins' => 'Can manage other admins',
'users.list' => 'Can list user stuff',
'users.create' => 'Can create new non-admin users',
'users.edit' => 'Can edit existing non-admin users',
'users.delete' => 'Can delete existing non-admin users',
'beta.access' => 'Can access beta-level features',
];
/**
* --------------------------------------------------------------------
* Permissions Matrix
* --------------------------------------------------------------------
* Maps permissions to groups.
*
* This defines group-level permissions.
*/
public array $matrix = [
"superadmin"=> [
"admin.*",
"users.*",
"beta.*"
],
"admin"=> [
"admin.access",
"users.create",
"users.edit",
"users.delete",
"beta.access"
],
"developer"=> [
"admin.access",
"admin.settings",
"users.create",
"users.edit",
"beta.access"
],
"user"=> [
"users.list"
],
"beta"=> [
"beta.access"
]
];
}

View File

@ -0,0 +1,138 @@
<?php
declare(strict_types=1);
/**
* This file is part of CodeIgniter Shield.
*
* (c) CodeIgniter Foundation <admin@codeigniter.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Config;
use CodeIgniter\Shield\Config\AuthToken as ShieldAuthToken;
/**
* Configuration for Token Auth and HMAC Auth
*/
class AuthToken extends ShieldAuthToken
{
/**
* --------------------------------------------------------------------
* Record Login Attempts for Token Auth and HMAC Auth
* --------------------------------------------------------------------
* Specify which login attempts are recorded in the database.
*
* Valid values are:
* - Auth::RECORD_LOGIN_ATTEMPT_NONE
* - Auth::RECORD_LOGIN_ATTEMPT_FAILURE
* - Auth::RECORD_LOGIN_ATTEMPT_ALL
*/
public int $recordLoginAttempt = Auth::RECORD_LOGIN_ATTEMPT_FAILURE;
/**
* --------------------------------------------------------------------
* Name of Authenticator Header
* --------------------------------------------------------------------
* The name of Header that the Authorization token should be found.
* According to the specs, this should be `Authorization`, but rare
* circumstances might need a different header.
*/
public array $authenticatorHeader = [
'tokens' => 'Authorization',
'hmac' => 'Authorization',
];
/**
* --------------------------------------------------------------------
* Unused Token Lifetime for Token Auth and HMAC Auth
* --------------------------------------------------------------------
* Determines the amount of time, in seconds, that an unused token can
* be used.
*/
public int $unusedTokenLifetime = YEAR;
/**
* --------------------------------------------------------------------
* Secret2 storage character limit
* --------------------------------------------------------------------
* Database size limit for the identities 'secret2' field.
*/
public int $secret2StorageLimit = 255;
/**
* --------------------------------------------------------------------
* HMAC secret key byte size
* --------------------------------------------------------------------
* Specify in integer the desired byte size of the
* HMAC SHA256 byte size
*/
public int $hmacSecretKeyByteSize = 32;
/**
* --------------------------------------------------------------------
* HMAC encryption Keys
* --------------------------------------------------------------------
* This sets the key to be used when encrypting a user's HMAC Secret Key.
*
* 'keys' is an array of keys which will facilitate key rotation. Valid
* keyTitles must include only [a-zA-Z0-9_] and should be kept to a
* max of 8 characters.
*
* Each keyTitle is an associative array containing the required 'key'
* value, and the optional 'driver' and 'digest' values. If the
* 'driver' and 'digest' values are not specified, the default 'driver'
* and 'digest' values will be used.
*
* Old keys will are used to decrypt existing Secret Keys. It is encouraged
* to run 'php spark shield:hmac reencrypt' to update existing Secret
* Key encryptions.
*
* @see https://codeigniter.com/user_guide/libraries/encryption.html
*
* @var array<string, array{key: string, driver?: string, digest?: string}>|string
*
* NOTE: The value becomes temporarily a string when setting value as JSON
* from environment variable.
*
* [key_name => ['key' => key_value]]
* or [key_name => ['key' => key_value, 'driver' => driver, 'digest' => digest]]
*/
public $hmacEncryptionKeys = [
'k1' => [
'key' => '',
],
];
/**
* --------------------------------------------------------------------
* HMAC Current Encryption Key Selector
* --------------------------------------------------------------------
* This specifies which of the encryption keys should be used.
*/
public string $hmacEncryptionCurrentKey = 'k1';
/**
* --------------------------------------------------------------------
* HMAC Encryption Key Driver
* --------------------------------------------------------------------
* This specifies which of the encryption drivers should be used.
*
* Available drivers:
* - OpenSSL
* - Sodium
*/
public string $hmacEncryptionDefaultDriver = 'OpenSSL';
/**
* --------------------------------------------------------------------
* HMAC Encryption Key Driver
* --------------------------------------------------------------------
* THis specifies the type of encryption to be used.
* e.g. 'SHA512' or 'SHA256'.
*/
public string $hmacEncryptionDefaultDigest = 'SHA512';
}

View File

@ -85,4 +85,17 @@ class Autoload extends AutoloadConfig
* @var array<int, string>
*/
public $files = [];
/**
* -------------------------------------------------------------------
* Helpers
* -------------------------------------------------------------------
* Prototype:
* $helpers = [
* 'form',
* ];
*
* @var list<string>
*/
public $helpers = ['auth', 'setting'];
}

View File

@ -2,13 +2,13 @@
namespace Config;
use App\Filters\JWTAuthFilter;
use App\Filters\LoginAuthFilter;
use App\Filters\ThrottlerFilter;
use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Filters\CSRF;
use CodeIgniter\Filters\DebugToolbar;
use CodeIgniter\Filters\Honeypot;
use CodeIgniter\Filters\InvalidChars;
use CodeIgniter\Filters\SecureHeaders;
class Filters extends BaseConfig
{
@ -16,54 +16,40 @@ class Filters extends BaseConfig
* Configures aliases for Filter classes to
* make reading things nicer and simpler.
*
* @var array
* @var array<string, class-string|list<class-string>> [filter_name => classname]
* or [filter_name => [classname1, classname2, ...]]
*/
public $aliases = [
'csrf' => CSRF::class,
'toolbar' => DebugToolbar::class,
public array $aliases = [
'csrf' => CSRF::class,
'toolbar' => DebugToolbar::class,
'honeypot' => Honeypot::class,
'auth' => JWTAuthFilter::class,
'throttler' => ThrottlerFilter::class,
'login' => LoginAuthFilter::class,
'invalidchars' => InvalidChars::class,
'secureheaders' => SecureHeaders::class,
];
/**
* List of filter aliases that are always
* applied before and after every request.
*
* @var array
* @var array<string, array<string, array<string, string>>>|array<string, list<string>>
*/
public $globals = [
public array $globals = [
'before' => [
'login' => [
'except' => [
'login',
'login/*',
'oauth',
'oauth/*',
'api',
'api/*',
'cron',
'cron/*',
'lang',
'lang/*',
'language',
'language/*',
'integration',
'integration/*'
]
],
// 'honeypot',
'csrf' => [
// 'csrf',
// 'invalidchars',
'session' => [
'except' => [
'api',
'api/*'
]
'login*',
'register',
'auth/a/*',
'logout']
],
],
'after' => [
'toolbar',
// 'honeypot',
// 'secureheaders',
],
];
@ -72,14 +58,13 @@ class Filters extends BaseConfig
* particular HTTP method (GET, POST, etc.).
*
* Example:
* 'post' => ['csrf', 'throttle']
* 'post' => ['foo', 'bar']
*
* @var array
* If you use this, you should disable auto-routing because auto-routing
* permits any HTTP method to access a controller. Accessing the controller
* with a method you don't expect could bypass the filter.
*/
public $methods = [
// 'get' => ['throttler'],
// 'post' => ['throttler']
];
public array $methods = [];
/**
* List of filter aliases that should run on any
@ -87,21 +72,6 @@ class Filters extends BaseConfig
*
* Example:
* 'isLoggedIn' => ['before' => ['account/*', 'profiles/*']]
*
* @var array
*/
public $filters = [
'auth' => [
'before' => [
'api/user/*',
'api/user/'
],
],
'throttler' => [
'before' => [
'api/*',
'api/'
]
]
];
public array $filters = [];
}

39
ci4/app/Config/Kint.php Executable file → Normal file
View File

@ -3,7 +3,10 @@
namespace Config;
use CodeIgniter\Config\BaseConfig;
use Kint\Parser\ConstructablePluginInterface;
use Kint\Renderer\AbstractRenderer;
use Kint\Renderer\Rich\TabPluginInterface;
use Kint\Renderer\Rich\ValuePluginInterface;
/**
* --------------------------------------------------------------------------
@ -23,27 +26,32 @@ class Kint extends BaseConfig
|--------------------------------------------------------------------------
*/
/**
* @var list<class-string<ConstructablePluginInterface>|ConstructablePluginInterface>|null
*/
public $plugins;
public $maxDepth = 6;
public $displayCalledFrom = true;
public $expanded = false;
public int $maxDepth = 6;
public bool $displayCalledFrom = true;
public bool $expanded = false;
/*
|--------------------------------------------------------------------------
| RichRenderer Settings
|--------------------------------------------------------------------------
*/
public $richTheme = 'aante-light.css';
public $richFolder = false;
public $richSort = AbstractRenderer::SORT_FULL;
public string $richTheme = 'aante-light.css';
public bool $richFolder = false;
public int $richSort = AbstractRenderer::SORT_FULL;
/**
* @var array<string, class-string<ValuePluginInterface>>|null
*/
public $richObjectPlugins;
/**
* @var array<string, class-string<TabPluginInterface>>|null
*/
public $richTabPlugins;
/*
@ -51,11 +59,8 @@ class Kint extends BaseConfig
| CLI Settings
|--------------------------------------------------------------------------
*/
public $cliColors = true;
public $cliForceUTF8 = false;
public $cliDetectWidth = true;
public $cliMinWidth = 40;
public bool $cliColors = true;
public bool $cliForceUTF8 = false;
public bool $cliDetectWidth = true;
public int $cliMinWidth = 40;
}

View File

@ -0,0 +1,28 @@
<?php
namespace Config;
use CodeIgniter\Config\Publisher as BasePublisher;
/**
* Publisher Configuration
*
* Defines basic security restrictions for the Publisher class
* to prevent abuse by injecting malicious files into a project.
*/
class Publisher extends BasePublisher
{
/**
* A list of allowed destinations with a (pseudo-)regex
* of allowed files for each destination.
* Attempts to publish to directories not in this list will
* result in a PublisherException. Files that do no fit the
* pattern will cause copy/merge to fail.
*
* @var array<string, string>
*/
public $restrictions = [
ROOTPATH => '*',
FCPATH => '#\.(s?css|js|map|html?|xml|json|webmanifest|ttf|eot|woff2?|gif|jpe?g|tiff?|png|webp|bmp|ico|svg)$#i',
];
}

View File

@ -1,36 +1,13 @@
<?php
namespace Config;
use CodeIgniter\Router\RouteCollection;
/*
// Create a new instance of our RouteCollection class.
$routes = Services::routes();
// Load the system's routing file first, so that the app and ENVIRONMENT
// can override as needed.
if (file_exists(SYSTEMPATH . 'Config/Routes.php')) {
require SYSTEMPATH . 'Config/Routes.php';
}
*/
/*
* --------------------------------------------------------------------
* Router Setup
* --------------------------------------------------------------------
/**
* @var RouteCollection $routes
*/
/*
$routes->setDefaultNamespace('App\Controllers');
$routes->setDefaultController('Home');
$routes->setDefaultMethod('index');
$routes->setTranslateURIDashes(false);
$routes->set404Override();
$routes->setAutoRoute(true);
*/
// Create a new instance of our RouteCollection class.
$routes = Services::routes();
//service('auth')->routes($routes, ['except' => ['login', 'register']]);
service('auth')->routes($routes);
//WEB ROUTER ------------------------------------------------------
//------------------------------------------------------------------

View File

@ -87,7 +87,7 @@ class Routing extends BaseRouting
*
* If FALSE, will stop searching and do NO automatic routing.
*/
public bool $autoRoute = true;
public bool $autoRoute = false;
/**
* If TRUE, will enable the use of the 'prioritize' option

0
ci4/app/Config/Toolbar.php Executable file → Normal file
View File

View File

@ -1,45 +0,0 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class ChangeTablesNames extends Migration
{
public function up()
{
$this->forge->renameTable('wg_activity', 'auth_activity');
$this->forge->renameTable('wg_backup', 'auth_backup');
$this->forge->renameTable('wg_confirmation_token', 'auth_confirmation_token');
$this->forge->renameTable('wg_crontab_history', 'auth_crontab_history');
$this->forge->renameTable('wg_notification', 'auth_notification');
$this->forge->renameTable('wg_password_recovery', 'auth_password_recovery');
$this->forge->renameTable('wg_settings', 'auth_settings');
$this->forge->renameTable('wg_template', 'auth_template');
$this->forge->renameTable('wg_theme', 'auth_theme');
$this->forge->renameTable('wg_timezone', 'auth_timezone');
$this->forge->renameTable('wg_user', 'auth_user');
$this->forge->renameTable('wg_user_group', 'auth_user_group');
$this->forge->renameTable('wg_user_group', 'auth_user_group');
$this->forge->renameTable('wg_countries', 'auth_countries');
$this->forge->renameTable('wg_currency', 'auth_currency');
}
public function down()
{
$this->forge->renameTable('auth_activity', 'wg_activity');
$this->forge->renameTable('auth_backup', 'wg_backup');
$this->forge->renameTable('auth_confirmation_token', 'wg_confirmation_token');
$this->forge->renameTable('auth_crontab_history', 'wg_crontab_history');
$this->forge->renameTable('wg_notification', 'auth_notification');
$this->forge->renameTable('auth_password_recovery', 'wg_password_recovery');
$this->forge->renameTable('auth_settings', 'wg_settings');
$this->forge->renameTable('auth_template', 'wg_template');
$this->forge->renameTable('auth_theme', 'wg_theme');
$this->forge->renameTable('auth_timezone', 'wg_timezone');
$this->forge->renameTable('auth_user', 'wg_user');
$this->forge->renameTable('auth_user_group', 'wg_user_group');
$this->forge->renameTable('auth_countries', 'wg_countries');
$this->forge->renameTable('auth_currency', 'wg_currency');
}
}

View File

@ -1,33 +0,0 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateGroupUserTable extends Migration
{
public function up()
{
// define table fields
$fields = array(
'token_user' => array(
'type' => 'VARCHAR',
'constraint' => 35
),
'token_group' => array(
'type' => 'VARCHAR',
'constraint' => 35
)
);
$this->forge->addField($fields);
// create table
$this->forge->createTable('group_user');
}
public function down()
{
$this->forge->dropTable('group_user',TRUE);
}
}

View File

@ -1,19 +0,0 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class RemoveGroupFromUser extends Migration
{
public function up()
{
$this->forge->dropColumn('auth_user', ['group']);
}
public function down()
{
$sql = "ALTER TABLE `auth_user` ADD `group` varchar(216) COLLATE latin1_general_ci;";
$this->db->query($sql);
}
}

View File

@ -1,43 +0,0 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class DropOauthTables extends Migration
{
public function up()
{
$this->forge->dropTable('wg_user_oauth');
$this->forge->dropTable('wg_settings_oauth');
}
public function down()
{
$sql = "CREATE TABLE IF NOT EXISTS `wg_settings_oauth` (
`id_oauth` int(11) NOT NULL AUTO_INCREMENT,
`provider` enum('facebook','google','twitter','linkedin','github','instagram','slack','spotify','reddit','discord','dribbble','dropbox','gitlab','strava','tumblr','twitch','vkontakte','wordpress','yahoo','bitbucket','wechat') COLLATE latin1_general_ci NOT NULL,
`key` varchar(200) COLLATE latin1_general_ci DEFAULT NULL,
`secret` varchar(200) COLLATE latin1_general_ci DEFAULT NULL,
`btn_class` varchar(50) COLLATE latin1_general_ci NOT NULL,
`btn_text` varchar(50) COLLATE latin1_general_ci DEFAULT NULL,
`show_text` tinyint(1) NOT NULL DEFAULT '0',
`icon_class` varchar(50) COLLATE latin1_general_ci NOT NULL,
`status` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id_oauth`)
) ENGINE=MyISAM AUTO_INCREMENT=22 DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;";
$this->db->query($sql);
$sql = "CREATE TABLE IF NOT EXISTS `wg_user_oauth` (
`id_user_oauth` int(11) NOT NULL AUTO_INCREMENT,
`user` varchar(35) COLLATE latin1_general_ci NOT NULL,
`provider` enum('facebook','google','twitter','linkedin','github','instagram','slack','spotify','reddit','discord','dribbble','dropbox','gitlab','strava','tumblr','twitch','vkontakte','wordpress','yahoo','bitbucket') COLLATE latin1_general_ci NOT NULL,
`identifier` varchar(50) COLLATE latin1_general_ci NOT NULL,
`picture` varchar(150) COLLATE latin1_general_ci NOT NULL,
`created_at` timestamp NOT NULL,
`updated_at` timestamp NOT NULL ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id_user_oauth`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;";
$this->db->query($sql);
}
}

View File

@ -1,42 +0,0 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class DeleteSMSColumns extends Migration
{
public function up()
{
$this->forge->dropColumn('notification', ['is_send_sms', 'send_sms_notification']);
$this->forge->dropColumn('settings', ['sms_gateway','sms_account_id', 'sms_auth_token', 'sms_info_add',
'sms_confirmation', 'send_sms_register', 'send_sms_welcome']);
$this->forge->dropColumn('user', ['sms_confirmed']);
}
public function down()
{
$sql = "ALTER TABLE `wg_notification` ADD `is_send_sms` tinyint(1) NOT NULL DEFAULT '0';";
$this->db->query($sql);
$sql = "ALTER TABLE `wg_notification` ADD `send_sms_notification` tinyint(1) NOT NULL DEFAULT '0';";
$this->db->query($sql);
$sql = "ALTER TABLE `wg_settings` ADD `sms_gateway` enum('twilio') COLLATE latin1_general_ci NOT NULL DEFAULT 'twilio';";
$this->db->query($sql);
$sql = "ALTER TABLE `wg_settings` ADD `sms_account_id` varchar(255) COLLATE latin1_general_ci DEFAULT NULL;";
$this->db->query($sql);
$sql = "ALTER TABLE `wg_settings` ADD `sms_auth_token` varchar(255) COLLATE latin1_general_ci DEFAULT NULL;";
$this->db->query($sql);
$sql = "ALTER TABLE `wg_settings` ADD `sms_info_add` varchar(255) COLLATE latin1_general_ci DEFAULT NULL;";
$this->db->query($sql);
$sql = "ALTER TABLE `wg_settings` ADD `sms_confirmation` tinyint(1) NOT NULL DEFAULT '0';";
$this->db->query($sql);
$sql = "ALTER TABLE `wg_settings` ADD `send_sms_register` tinyint(1) NOT NULL DEFAULT '0';";
$this->db->query($sql);
$sql = "ALTER TABLE `wg_settings` ADD `send_sms_welcome` tinyint(1) NOT NULL DEFAULT '0';";
$this->db->query($sql);
$sql = "ALTER TABLE `wg_user` ADD `sms_confirmed` tinyint(4) NOT NULL DEFAULT '0';";
$this->db->query($sql);
}
}

View File

@ -1,28 +0,0 @@
<?php
namespace App\Filters;
use CodeIgniter\API\ResponseTrait;
use CodeIgniter\Filters\FilterInterface;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Config\Services;
use Exception;
class JWTAuthFilter implements FilterInterface
{
public function before(RequestInterface $request, $arguments = null)
{
try {
helper('jwt');
jwtValidateRequest(jwtRequest($request->getServer('HTTP_AUTHORIZATION')));
return $request;
} catch (Exception $e) {
return Services::response()->setJSON(['error' => $e->getMessage()])->setStatusCode(ResponseInterface::HTTP_UNAUTHORIZED);
}
}
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
{
}
}

View File

@ -12,7 +12,7 @@ class LoginAuthFilter implements FilterInterface
public function before(RequestInterface $request, $arguments = null)
{
try {
if(!$this->validateIgnoreControllerAccess()){
/*if(!$this->validateIgnoreControllerAccess()){
$session = session();
$token = $session->get('token')??'';
$tfa = $session->get('tfa')??false;
@ -24,7 +24,7 @@ class LoginAuthFilter implements FilterInterface
}else{
$this->validateControllerAccess();
}
}
}*/
} catch (Exception $e) {
}

View File

@ -1,43 +0,0 @@
<?php
namespace App\Filters;
use App\Models\SettingsModel;
use CodeIgniter\API\ResponseTrait;
use CodeIgniter\Filters\FilterInterface;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Config\Services;
use Exception;
class ThrottlerFilter implements FilterInterface
{
use ResponseTrait;
public function before(RequestInterface $request, $arguments = null)
{
try {
$throttler = Services::throttler();
$ip = $request->getIPAddress();
$settingsBase = new SettingsModel();
$settings = $settingsBase->first()??[];
if(!$settings['enable_api']){
return Services::response()->setJSON(['error' => 'ApiRest is currently disabled.'])->setStatusCode(ResponseInterface::HTTP_UNAUTHORIZED);
}
if($settings['block_external_api']){
if($ip != $settings['ip_allowed_api']??''){
return Services::response()->setJSON(['error' => 'Endpoint access from external domains is not allowed.'])->setStatusCode(ResponseInterface::HTTP_UNAUTHORIZED);
}
if ($throttler->check($ip, 60, MINUTE) === false)
{
return Services::response()->setStatusCode(429);
}
}
} catch (Exception $e) {
return Services::response()->setJSON(['error' => $e->getMessage()])->setStatusCode(ResponseInterface::HTTP_UNAUTHORIZED);
}
}
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
{
}
}

21
ci4/app/UserModel.php Normal file
View File

@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
namespace App\Models;
use CodeIgniter\Shield\Models\UserModel as ShieldUserModel;
class UserModel extends ShieldUserModel
{
protected function initialize(): void
{
parent::initialize();
$this->allowedFields = [
...$this->allowedFields,
// 'first_name',
];
}
}

View File

@ -0,0 +1,31 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<head>
<meta name="x-apple-disable-message-reformatting">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="format-detection" content="telephone=no, date=no, address=no, email=no">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title><?= lang('Auth.email2FASubject') ?></title>
</head>
<body>
<p><?= lang('Auth.email2FAMailBody') ?></p>
<div style="text-align: center">
<h1><?= $code ?></h1>
</div>
<table role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
<tbody>
<tr>
<td style="line-height: 20px; font-size: 20px; width: 100%; height: 20px; margin: 0;" align="left" width="100%" height="20">
&#160;
</td>
</tr>
</tbody>
</table>
<b><?= lang('Auth.emailInfo') ?></b>
<p><?= lang('Auth.emailIpAddress') ?> <?= esc($ipAddress) ?></p>
<p><?= lang('Auth.emailDevice') ?> <?= esc($userAgent) ?></p>
<p><?= lang('Auth.emailDate') ?> <?= esc($date) ?></p>
</body>
</html>

View File

@ -0,0 +1,31 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<head>
<meta name="x-apple-disable-message-reformatting">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="format-detection" content="telephone=no, date=no, address=no, email=no">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title><?= lang('Auth.emailActivateSubject') ?></title>
</head>
<body>
<p><?= lang('Auth.emailActivateMailBody') ?></p>
<div style="text-align: center">
<h1><?= $code ?></h1>
</div>
<table role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
<tbody>
<tr>
<td style="line-height: 20px; font-size: 20px; width: 100%; height: 20px; margin: 0;" align="left" width="100%" height="20">
&#160;
</td>
</tr>
</tbody>
</table>
<b><?= lang('Auth.emailInfo') ?></b>
<p><?= lang('Auth.emailIpAddress') ?> <?= esc($ipAddress) ?></p>
<p><?= lang('Auth.emailDevice') ?> <?= esc($userAgent) ?></p>
<p><?= lang('Auth.emailDate') ?> <?= esc($date) ?></p>
</body>
</html>

View File

@ -0,0 +1,36 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<head>
<meta name="x-apple-disable-message-reformatting">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="format-detection" content="telephone=no, date=no, address=no, email=no">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title><?= lang('Auth.magicLinkSubject') ?></title>
</head>
<body>
<table role="presentation" border="0" cellpadding="0" cellspacing="0" style="border-radius: 6px; border-collapse: separate !important;">
<tbody>
<tr>
<td style="line-height: 24px; font-size: 16px; border-radius: 6px; margin: 0;" align="center" bgcolor="#0d6efd">
<a href="<?= url_to('verify-magic-link') ?>?token=<?= $token ?>" style="color: #ffffff; font-size: 16px; font-family: Helvetica, Arial, sans-serif; text-decoration: none; border-radius: 6px; line-height: 20px; display: inline-block; font-weight: normal; white-space: nowrap; background-color: #0d6efd; padding: 8px 12px; border: 1px solid #0d6efd;"><?= lang('Auth.login') ?></a>
</td>
</tr>
</tbody>
</table>
<table role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
<tbody>
<tr>
<td style="line-height: 20px; font-size: 20px; width: 100%; height: 20px; margin: 0;" align="left" width="100%" height="20">
&#160;
</td>
</tr>
</tbody>
</table>
<b><?= lang('Auth.emailInfo') ?></b>
<p><?= lang('Auth.emailIpAddress') ?> <?= esc($ipAddress) ?></p>
<p><?= lang('Auth.emailDevice') ?> <?= esc($userAgent) ?></p>
<p><?= lang('Auth.emailDate') ?> <?= esc($date) ?></p>
</body>
</html>

View File

@ -0,0 +1,38 @@
<?= $this->extend(config('Auth')->views['layout']) ?>
<?= $this->section('title') ?><?= lang('Auth.email2FATitle') ?> <?= $this->endSection() ?>
<?= $this->section('main') ?>
<div class="container d-flex justify-content-center p-5">
<div class="card col-12 col-md-5 shadow-sm">
<div class="card-body">
<h5 class="card-title mb-5"><?= lang('Auth.email2FATitle') ?></h5>
<p><?= lang('Auth.confirmEmailAddress') ?></p>
<?php if (session('error')) : ?>
<div class="alert alert-danger"><?= session('error') ?></div>
<?php endif ?>
<form action="<?= url_to('auth-action-handle') ?>" method="post">
<?= csrf_field() ?>
<!-- Email -->
<div class="mb-2">
<input type="email" class="form-control" name="email"
inputmode="email" autocomplete="email" placeholder="<?= lang('Auth.email') ?>"
<?php /** @var CodeIgniter\Shield\Entities\User $user */ ?>
value="<?= old('email', $user->email) ?>" required>
</div>
<div class="d-grid col-8 mx-auto m-3">
<button type="submit" class="btn btn-primary btn-block"><?= lang('Auth.send') ?></button>
</div>
</form>
</div>
</div>
</div>
<?= $this->endSection() ?>

View File

@ -0,0 +1,36 @@
<?= $this->extend(config('Auth')->views['layout']) ?>
<?= $this->section('title') ?><?= lang('Auth.email2FATitle') ?> <?= $this->endSection() ?>
<?= $this->section('main') ?>
<div class="container d-flex justify-content-center p-5">
<div class="card col-12 col-md-5 shadow-sm">
<div class="card-body">
<h5 class="card-title mb-5"><?= lang('Auth.emailEnterCode') ?></h5>
<p><?= lang('Auth.emailConfirmCode') ?></p>
<?php if (session('error') !== null) : ?>
<div class="alert alert-danger"><?= session('error') ?></div>
<?php endif ?>
<form action="<?= url_to('auth-action-verify') ?>" method="post">
<?= csrf_field() ?>
<!-- Code -->
<div class="mb-2">
<input type="number" class="form-control" name="token" placeholder="000000"
inputmode="numeric" pattern="[0-9]*" autocomplete="one-time-code" required>
</div>
<div class="d-grid col-8 mx-auto m-3">
<button type="submit" class="btn btn-primary btn-block"><?= lang('Auth.confirm') ?></button>
</div>
</form>
</div>
</div>
</div>
<?= $this->endSection() ?>

View File

@ -0,0 +1,37 @@
<?= $this->extend(config('Auth')->views['layout']) ?>
<?= $this->section('title') ?><?= lang('Auth.emailActivateTitle') ?> <?= $this->endSection() ?>
<?= $this->section('main') ?>
<div class="container d-flex justify-content-center p-5">
<div class="card col-12 col-md-5 shadow-sm">
<div class="card-body">
<h5 class="card-title mb-5"><?= lang('Auth.emailActivateTitle') ?></h5>
<?php if (session('error')) : ?>
<div class="alert alert-danger"><?= session('error') ?></div>
<?php endif ?>
<p><?= lang('Auth.emailActivateBody') ?></p>
<form action="<?= url_to('auth-action-verify') ?>" method="post">
<?= csrf_field() ?>
<!-- Code -->
<div class="form-floating mb-2">
<input type="text" class="form-control" id="floatingTokenInput" name="token" placeholder="000000" inputmode="numeric"
pattern="[0-9]*" autocomplete="one-time-code" value="<?= old('token') ?>" required>
<label for="floatingTokenInput"><?= lang('Auth.token') ?></label>
</div>
<div class="d-grid col-8 mx-auto m-3">
<button type="submit" class="btn btn-primary btn-block"><?= lang('Auth.send') ?></button>
</div>
</form>
</div>
</div>
</div>
<?= $this->endSection() ?>

View File

@ -0,0 +1,116 @@
<?php
$session = session();
$settings = $session->get('settings');
?>
<!DOCTYPE html>
<html
lang="<?= $settings['default_language'] ?? 'es' ?>"
class="h-100"
class="dark-style customizer-hide"
dir="ltr"
data-theme="theme-default"
data-assets-path="<?= site_url('themes/vuexy/') ?>"
data-template="vertical-menu-template-no-customizer"
>
<head>
<meta charset="utf-8">
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"
/>
<title><?= $this->renderSection('title') ?></title>
<?php
$baseImgUrl = site_url('themes/vuexy/img/favicon');
$baseThemeUrl = site_url('themes/vuexy');
?>
<!-- Favicon -->
<link rel="icon" type="image/x-icon" href="<?= $baseImgUrl . '/favicon.ico' ?>"/>
<link rel="apple-touch-icon" sizes="57x57" href="<?= $baseImgUrl . '/apple-icon-57x57.png' ?>">
<link rel="apple-touch-icon" sizes="60x60" href="<?= $baseImgUrl . '/apple-icon-60x60.png' ?>">
<link rel="apple-touch-icon" sizes="72x72" href="<?= $baseImgUrl . '/apple-icon-72x72.png' ?>">
<link rel="apple-touch-icon" sizes="76x76" href="<?= $baseImgUrl . '/apple-icon-76x76.png' ?>">
<link rel="apple-touch-icon" sizes="114x114" href="<?= $baseImgUrl . '/apple-icon-114x114.png' ?>">
<link rel="apple-touch-icon" sizes="120x120" href="<?= $baseImgUrl . '/apple-icon-120x120.png' ?>">
<link rel="apple-touch-icon" sizes="144x144" href="<?= $baseImgUrl . '/apple-icon-144x144.png' ?>">
<link rel="apple-touch-icon" sizes="152x152" href="<?= $baseImgUrl . '/apple-icon-152x152.png' ?>">
<link rel="apple-touch-icon" sizes="180x180" href="<?= $baseImgUrl . '/apple-icon-180x180.png' ?>">
<link rel="icon" type="image/png" sizes="192x192" href="<?= $baseImgUrl . '/android-icon-192x192.png' ?>">
<link rel="icon" type="image/png" sizes="32x32" href="<?= $baseImgUrl . '/favicon-32x32.png' ?>">
<link rel="icon" type="image/png" sizes="96x96" href="<?= $baseImgUrl . '/favicon-96x96.png' ?>">
<link rel="icon" type="image/png" sizes="16x16" href="<?= $baseImgUrl . '/favicon-16x16.png' ?>">
<link rel="manifest" href="<?= $baseImgUrl . '/manifest.json' ?>">
<!-- Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com"/>
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin/>
<link
href="https://fonts.googleapis.com/css2?family=Public+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400;1,500;1,600;1,700&display=swap"
rel="stylesheet"
/>
<!-- Icons -->
<link rel="stylesheet" href="<?= $baseThemeUrl . '/vendors/fonts/fontawesome.css' ?>"/>
<link rel="stylesheet" href="<?= $baseThemeUrl . '/vendors/fonts/tabler-icons.css' ?>"/>
<link rel="stylesheet" href="<?= $baseThemeUrl . '/vendors/fonts/flag-icons.css' ?>"/>
<!-- Core CSS -->
<link rel="stylesheet" href="<?= $baseThemeUrl . '/vendors/css/rtl/core-dark.css' ?>"/>
<link rel="stylesheet" href="<?= $baseThemeUrl . '/vendors/css/rtl/theme-default-dark.css' ?>"/>
<link rel="stylesheet" href="<?= $baseThemeUrl . '/css/safekat.css' ?>"/>
<!-- Vendors CSS -->
<link rel="stylesheet" href="<?= $baseThemeUrl . '/vendors/libs/perfect-scrollbar/perfect-scrollbar.css' ?>"/>
<link rel="stylesheet" href="<?= $baseThemeUrl . '/vendors/libs/node-waves/node-waves.css' ?>"/>
<link rel="stylesheet" href="<?= $baseThemeUrl . '/vendors/libs/typeahead-js/typeahead.css' ?>"/>
<link rel="stylesheet" href="<?= $baseThemeUrl . '/vendors/libs/toastr/toastr.css' ?>"/>
<!-- Vendor -->
<link rel="stylesheet" href="<?= $baseThemeUrl . '/vendors/libs/formvalidation/dist/css/formValidation.min.css' ?>"/>
<!-- Page CSS -->
<link rel="stylesheet" href="<?= $baseThemeUrl . '/vendors/css/pages/page-auth.css' ?>"/>
<!-- Helpers -->
<script src="<?= $baseThemeUrl . '/vendors/js/helpers.js' ?>"></script>
<script src="<?= $baseThemeUrl . '/js/config.js' ?>"></script>
</head>
<body>
<?= $this->renderSection('main') ?>
<?= $this->renderSection('pageScripts') ?>
<!-- Required vendors -->
<!-- Core JS -->
<script src="<?= $baseThemeUrl . '/vendors/libs/jquery/jquery.js' ?>"></script>
<script src="<?= $baseThemeUrl . '/vendors/libs/popper/popper.js' ?>"></script>
<script src="<?= $baseThemeUrl . '/vendors/js/bootstrap.js' ?>"></script>
<script src="<?= $baseThemeUrl . '/vendors/libs/perfect-scrollbar/perfect-scrollbar.js' ?>"></script>
<script src="<?= $baseThemeUrl . '/vendors/libs/node-waves/node-waves.js' ?>"></script>
<script src="<?= $baseThemeUrl . '/vendors/libs/hammer/hammer.js' ?>"></script>
<script src="<?= $baseThemeUrl . '/vendors/libs/i18n/i18n.js' ?>"></script>
<script src="<?= $baseThemeUrl . '/vendors/libs/typeahead-js/typeahead.js' ?>"></script>
<script src="<?= $baseThemeUrl . '/vendors/js/menu.js' ?>"></script>
<!-- Main JS -->
<script src="<?= $baseThemeUrl . '/js/main.js' ?>"></script>
<!-- Custom JS -->
<script>
function pass() {
"use strict";
var passwordField = document.getElementById('password');
var showPassIcon = document.getElementById('show_pass');
var isTextField = passwordField.type === 'text';
passwordField.type = isTextField ? 'password' : 'text';
showPassIcon.innerHTML = isTextField ? '<i class="ti ti-eye"></i>' : '<i class="ti ti-eye-off"></i>';
}
</script>
</body>
</html>

View File

@ -0,0 +1,136 @@
<?= $this->extend(config('Auth')->views['layout']) ?>
<?= $this->section('title') ?><?= lang('Auth.login') ?><?= $this->endSection() ?>
<?= $this->section('main') ?>
<!-- Content -->
<div class="authentication-wrapper authentication-cover authentication-bg">
<div class="authentication-inner row">
<!-- /Left Text -->
<div class="d-none d-lg-flex col-lg-7 p-0">
<div class="auth-cover-bg auth-cover-bg-color d-flex justify-content-center align-items-center">
<img
src="<?= site_url('themes/vuexy/img/safekat/login/auth-login-illustration-light.png') ?>"
alt="auth-login-cover"
class="img-fluid my-5 auth-illustration"
/>
<img
src="<?= site_url('themes/vuexy/img/illustrations/bg-shape-image-light.png'); ?>"
alt="auth-login-cover"
class="platform-bg"
/>
</div>
</div>
<!-- /Left Text -->
<!-- Login -->
<div class="d-flex col-12 col-lg-5 align-items-center p-sm-5 p-4">
<div class="w-px-400 mx-auto">
<!-- Logo -->
<div class="app-brand mb-4">
<a href="<?= site_url('login'); ?>" class="app-brand-link gap-2">
<span class="app-brand-logo">
<img src="<?= site_url('themes/vuexy/img/safekat/logos/sk-logo.png') ?>">
</span>
</a>
</div>
<!-- /Logo -->
<h3 class="mb-1 fw-bold"><?= lang('Auth.login') ?></h3>
<?php if (session('error') !== null) : ?>
<div class="alert alert-danger" role="alert"><?= session('error') ?></div>
<?php elseif (session('errors') !== null) : ?>
<div class="alert alert-danger" role="alert">
<?php if (is_array(session('errors'))) : ?>
<?php foreach (session('errors') as $error) : ?>
<?= $error ?>
<br>
<?php endforeach ?>
<?php else : ?>
<?= session('errors') ?>
<?php endif ?>
</div>
<?php endif ?>
<?php if (session('message') !== null) : ?>
<div class="alert alert-success" role="alert"><?= session('message') ?></div>
<?php endif ?>
<form id="formAuthentication" class="mb-3" action="<?= url_to('login') ?>" method="POST">
<?= csrf_field() ?>
<!-- Email -->
<div class="mb-3">
<label for="floatingEmailInput" class="form-label"><?= lang('Auth.email') ?></label>
<input
type="email"
class="form-control"
id="floatingEmailInput"
name="email"
inputmode="email"
placeholder="<?= lang('Auth.email') ?>"
value="<?= old('email') ?>"
required
autofocus
/>
</div>
<!-- Password -->
<div class="mb-3 form-password-toggle">
<div class="d-flex justify-content-between">
<label class="form-label" for="password"><?= lang('Auth.password') ?></label>
<?php if (setting('Auth.allowMagicLinkLogins')): ?>
<a href="<?= url_to('magic-link') ?>">
<small><?= lang('Auth.forgotPassword') ?></small>
</a>
<?php endif; ?>
</div>
<div class="input-group input-group-merge">
<input
type="password"
class="form-control"
id="floatingPasswordInput"
name="password"
inputmode="text"
autocomplete="current-password"
placeholder="<?= lang('Auth.password') ?>"
required
onclick="pass()"
/>
<span id="show_pass" class="input-group-text cursor-pointer"><i
class="ti ti-eye-off"></i></span>
</div>
</div>
<!-- Remember me -->
<?php if (setting('Auth.sessionConfig')['allowRemembering']): ?>
<div class="mb-3">
<div class="form-check">
<input type="checkbox" name="remember"
class="form-check-input" <?php if (old('remember')): ?> checked<?php endif ?>>
<label class="form-check-label"
for="remember"> <?= lang('Auth.rememberMe') ?> </label>
</div>
</div>
<?php endif; ?>
<button class="btn btn-primary d-grid w-100"><?= lang('Auth.login') ?></button>
</form>
<?php if (setting('Auth.allowRegistration')) : ?>
<p class="text-center">
<span><?= lang('Auth.needAccount') ?></span>
<a href="<?= url_to('register') ?>">
<span><?= lang('Auth.register') ?></span>
</a>
</p>
<?php endif; ?>
</div>
</div>
<!-- /Login -->
</div>
</div>
<!-- / Content -->
<?= $this->endSection() ?>

View File

@ -0,0 +1,91 @@
<?= $this->extend(config('Auth')->views['layout']) ?>
<?= $this->section('title') ?><?= lang('Auth.useMagicLink') ?> <?= $this->endSection() ?>
<?= $this->section('main') ?>
<!-- Content -->
<div class="authentication-wrapper authentication-cover authentication-bg">
<div class="authentication-inner row">
<!-- /Left Text -->
<div class="d-none d-lg-flex col-lg-6 p-0">
<div class="auth-cover-bg auth-cover-bg-color d-flex justify-content-center align-items-center">
<img
src="<?= site_url('themes/vuexy/img/safekat/login/auth-login-illustration-light.png') ?>"
alt="auth-forgot-password-cover"
class="img-fluid my-5 auth-illustration"
/>
<img
src="<?= site_url('themes/vuexy/img/illustrations/bg-shape-image-light.png'); ?>"
alt="auth-forgot-password-cover"
class="platform-bg"
/>
</div>
</div>
<!-- /Left Text -->
<!-- Forgot Password -->
<div class="d-flex col-12 col-lg-6 align-items-center p-sm-5 p-4">
<div class="w-px-500 mx-auto">
<!-- Logo -->
<div class="app-brand mb-4">
<a href="index.html" class="app-brand-link gap-2">
<span class="app-brand-logo">
<img src="<?= site_url('themes/vuexy/img/safekat/logos/sk-logo.png') ?>"
</span>
</a>
</div>
<!-- /Logo -->
<h3 class="mb-1 fw-bold"><?= lang('Auth.useMagicLink') ?></h3>
<?php if (session('error') !== null) : ?>
<div class="alert alert-danger" role="alert"><?= session('error') ?></div>
<?php elseif (session('errors') !== null) : ?>
<div class="alert alert-danger" role="alert">
<?php if (is_array(session('errors'))) : ?>
<?php foreach (session('errors') as $error) : ?>
<?= $error ?>
<br>
<?php endforeach ?>
<?php else : ?>
<?= session('errors') ?>
<?php endif ?>
</div>
<?php endif ?>
<form id="sendForm" class="mb-3" action="<?= url_to('magic-link') ?>" method="post">
<?= csrf_field() ?>
<div class="mb-3">
<label for="floatingEmailInput" class="form-label"><?= lang('Auth.email') ?></label>
<input
type="email"
class="form-control"
id="floatingEmailInput"
name="email"
inputmode="email"
placeholder="<?= lang('Auth.email') ?>"
value="<?= old('email', auth()->user()->email ?? null) ?>"
required
autofocus
/>
</div>
<button class="btn btn-primary d-grid w-100"><?= lang('Auth.send') ?></button>
</form>
<div class="text-center">
<a href="<?= url_to('login') ?>" class="d-flex align-items-center justify-content-center">
<i class="ti ti-chevron-left scaleX-n1-rtl"></i>
<?= lang('Auth.backToLogin') ?>
</a>
</div>
</div>
</div>
<!-- /Forgot Password -->
</div>
</div>
<!-- / Content -->
<?= $this->endSection() ?>

View File

@ -0,0 +1,19 @@
<?= $this->extend(config('Auth')->views['layout']) ?>
<?= $this->section('title') ?><?= lang('Auth.useMagicLink') ?> <?= $this->endSection() ?>
<?= $this->section('main') ?>
<div class="container d-flex justify-content-center p-5">
<div class="card col-12 col-md-5 shadow-sm">
<div class="card-body">
<h5 class="card-title mb-5"><?= lang('Auth.useMagicLink') ?></h5>
<p><b><?= lang('Auth.checkYourEmail') ?></b></p>
<p><?= lang('Auth.magicLinkDetails', [setting('Auth.magicLinkLifetime') / 60]) ?></p>
</div>
</div>
</div>
<?= $this->endSection() ?>

View File

@ -0,0 +1,147 @@
<?= $this->extend(config('Auth')->views['layout']) ?>
<?= $this->section('title') ?><?= lang('Auth.register') ?> <?= $this->endSection() ?>
<?= $this->section('main') ?>
<!-- Content -->
<div class="authentication-wrapper authentication-cover authentication-bg">
<div class="authentication-inner row">
<!-- /Left Text -->
<div class="d-none d-lg-flex col-lg-7 p-0">
<div class="auth-cover-bg auth-cover-bg-color d-flex justify-content-center align-items-center">
<img
src="<?= site_url('themes/vuexy/img/safekat/login/auth-login-illustration-light.png') ?>"
alt="auth-register-cover"
class="img-fluid my-5 auth-illustration"
/>
<img
src="<?= site_url('themes/vuexy/img/illustrations/bg-shape-image-light.png'); ?>"
alt="auth-register-cover"
class="platform-bg"
/>
</div>
</div>
<!-- /Left Text -->
<!-- Register -->
<div class="d-flex col-12 col-lg-5 align-items-center p-sm-5 p-4">
<div class="w-px-400 mx-auto">
<!-- Logo -->
<div class="app-brand mb-4">
<a href="index.html" class="app-brand-link gap-2">
<span class="app-brand-logo">
<img src="<?= site_url('themes/vuexy/img/safekat/logos/sk-logo.png') ?>"
</span>
</a>
</div>
<!-- /Logo -->
<h3 class="mb-1 fw-bold"><?= lang('Auth.register') ?></h3>
<?php if (session('error') !== null) : ?>
<div class="alert alert-danger" role="alert"><?= session('error') ?></div>
<?php elseif (session('errors') !== null) : ?>
<div class="alert alert-danger" role="alert">
<?php if (is_array(session('errors'))) : ?>
<?php foreach (session('errors') as $error) : ?>
<?= $error ?>
<br>
<?php endforeach ?>
<?php else : ?>
<?= session('errors') ?>
<?php endif ?>
</div>
<?php endif ?>
<form id="sendForm" class="mb-3" action="<?= url_to('register') ?>" method="POST">
<?= csrf_field() ?>
<!-- Email -->
<div class="mb-3">
<label for="floatingEmailInput" class="form-label"><?= lang('Auth.email') ?></label>
<input
type="email"
class="form-control"
id="floatingEmailInput"
name="email"
inputmode="email"
autocomplete="email"
placeholder="<?= lang('Auth.email') ?>"
value="<?= old('email') ?>"
required
/>
</div>
<!-- Username -->
<div class="mb-3">
<label for="floatingUsernameInput" class="form-label"><?= lang('Auth.username') ?></label>
<input
type="text"
class="form-control"
id="floatingUsernameInput"
name="username"
inputmode="text"
autocomplete="username"
placeholder=<?= lang('Auth.username') ?>
value="<?= old('username') ?>"
required
/>
</div>
<!-- Password -->
<div class="mb-3 form-password-toggle">
<label class="form-label" for="floatingPasswordInput"><?= lang('Auth.password') ?></label>
<div class="input-group input-group-merge">
<input
type="password"
class="form-control"
id="floatingPasswordInput"
name="password"
inputmode="text"
autocomplete="new-password"
placeholder="<?= lang('Auth.password') ?>"
onclick="pass()"
required
/>
<span class="input-group-text cursor-pointer"><i class="ti ti-eye-off"></i></span>
</div>
</div>
<!-- Password (Again) -->
<div class="mb-3 form-password-toggle">
<label class="form-label" for="floatingPasswordConfirmInput"><?= lang('Auth.passwordConfirm') ?></label>
<div class="input-group input-group-merge">
<input
type="password"
class="form-control"
id="floatingPasswordConfirmInput"
name="password_confirm"
inputmode="text"
autocomplete="new-password"
placeholder="<?= lang('Auth.passwordConfirm') ?>"
onclick="pass()"
required
/>
<span class="input-group-text cursor-pointer"><i class="ti ti-eye-off"></i></span>
</div>
</div>
<button class="btn btn-primary d-grid w-100"><?= lang('Auth.register') ?></button>
</form>
<p class="text-center"><?= lang('Auth.haveAccount') ?>
<a href="<?= url_to('login') ?>">
<span><?= lang('Auth.login') ?></span>
</a>
</p>
</div>
</div>
<!-- /Register -->
</div>
</div>
<!-- / Content -->
<?= $this->endSection() ?>

View File

@ -12,13 +12,16 @@
/*
* --------------------------------------------------------------------
* CodeIgniter command-line tools
* CODEIGNITER COMMAND-LINE TOOLS
* --------------------------------------------------------------------
* The main entry point into the CLI system and allows you to run
* commands and perform maintenance on your application.
*
* Because CodeIgniter can handle CLI requests as just another web request
* this class mainly acts as a passthru to the framework itself.
*/
/*
*---------------------------------------------------------------
* CHECK SERVER API
*---------------------------------------------------------------
*/
// Refuse to run when called from php-cgi
@ -26,8 +29,13 @@ if (strpos(PHP_SAPI, 'cgi') === 0) {
exit("The cli tool is not supported when running php-cgi. It needs php-cli to function!\n\n");
}
// Check PHP version.
$minPhpVersion = '7.4'; // If you update this, don't forget to update `public/index.php`.
/*
*---------------------------------------------------------------
* CHECK PHP VERSION
*---------------------------------------------------------------
*/
$minPhpVersion = '8.1'; // If you update this, don't forget to update `public/index.php`.
if (version_compare(PHP_VERSION, $minPhpVersion, '<')) {
$message = sprintf(
'Your PHP version must be %s or higher to run CodeIgniter. Current version: %s',
@ -39,15 +47,14 @@ if (version_compare(PHP_VERSION, $minPhpVersion, '<')) {
}
// We want errors to be shown when using it from the CLI.
error_reporting(-1);
error_reporting(E_ALL);
ini_set('display_errors', '1');
/**
* @var bool
*
* @deprecated No longer in use. `CodeIgniter` has `$context` property.
/*
*---------------------------------------------------------------
* SET THE CURRENT DIRECTORY
*---------------------------------------------------------------
*/
define('SPARKED', true);
// Path to the front controller
define('FCPATH', __DIR__ . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR);
@ -64,36 +71,14 @@ chdir(FCPATH);
* and fires up an environment-specific bootstrapping.
*/
// Load our paths config file
// LOAD OUR PATHS CONFIG FILE
// This is the line that might need to be changed, depending on your folder structure.
require FCPATH . '../app/Config/Paths.php';
// ^^^ Change this line if you move your application folder
$paths = new Config\Paths();
// Location of the framework bootstrap file.
require rtrim($paths->systemDirectory, '\\/ ') . DIRECTORY_SEPARATOR . 'bootstrap.php';
// LOAD THE FRAMEWORK BOOTSTRAP FILE
require $paths->systemDirectory . '/Boot.php';
// Load environment settings from .env files into $_SERVER and $_ENV
require_once SYSTEMPATH . 'Config/DotEnv.php';
(new CodeIgniter\Config\DotEnv(ROOTPATH))->load();
// Grab our CodeIgniter
$app = Config\Services::codeigniter();
$app->initialize();
// Grab our Console
$console = new CodeIgniter\CLI\Console();
// Show basic information before we do anything else.
if (is_int($suppress = array_search('--no-header', $_SERVER['argv'], true))) {
unset($_SERVER['argv'][$suppress]); // @codeCoverageIgnore
$suppress = true;
}
$console->showHeader($suppress);
// fire off the command in the main framework.
$exit = $console->run();
exit(is_int($exit) ? $exit : EXIT_SUCCESS);
exit(CodeIgniter\Boot::bootSpark($paths));

View File

@ -45,7 +45,7 @@ if (getcwd() . DIRECTORY_SEPARATOR !== FCPATH) {
// LOAD OUR PATHS CONFIG FILE
// This is the line that might need to be changed, depending on your folder structure.
require FCPATH . '../ci4/app/Config/Paths.php';
require FCPATH . '../app/Config/Paths.php';
// ^^^ Change this line if you move your application folder
$paths = new Config\Paths();

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB