Configuration
Create a autologin.php file under your /config directory with the following options available to you. You can also use multi-environment options to change these per environment.
The below shows the defaults already used by Autologin, so you don't need to add these options unless you want to modify the values.
<?php
return [
'*' => [
'enabled' => true,
'ipWhitelist' => [],
'basicAuth' => [],
'urlKeys' => [],
'redirectUrl' => '',
],
];Configuration options
enabled- Whether to enable the Autologin plugin.ipWhitelist- A list of Craft usernames/emails mapped to IPs.basicAuth- A list of Craft usernames/emails mapped to basic auth usernames.urlKeys- A list of Craft usernames/emails mapped to url keys.redirectUrl- Redirect to this url after logging in automatically.
IP Whitelist
Return an array with the key as the username you wish to autologin, and the value an array of IPs.
<?php
return [
'ipWhitelist' => [
'craftUsername' => [
'162.247.141.58',
'162.247.141.59',
],
],
];IP addresses are matched against the direct connection address. Autologin never reads Client-IP, and reads X-Forwarded-For only when the direct connection comes from an address listed in Craft's trustedHosts setting, so a browser can't supply its own address.
If Craft runs behind a reverse proxy, load balancer or CDN, the direct connection address is the proxy. List your proxy's addresses or ranges in trustedHosts, or have your web server restore the visitor address (such as nginx real_ip or Apache mod_remoteip). Craft's default trustedHosts value of any doesn't count, because it would trust any visitor. Don't whitelist the proxy's own address, because every visitor passing through it would match.
Basic Auth
Return an array with the key as the username you wish to autologin, and the value a Basic HTTP Auth username.
<?php
return [
'basicAuth' => [
'craftUserName1' => 'basicAuthUsername',
'craftUserName2' => 'basicAuthUsername2',
],
];URL Keys
Return an array with the key as the username you wish to autologin, and the value for the unique key.
<?php
return [
'urlKeys' => [
'craftUserName' => 'BepmD8GQBZpaFpXQ',
],
];Control Panel
You can also manage configuration settings through the Control Panel by visiting Settings → Autologin.