superbig/craft3-autologin

Automatically login based on whitelisted IP, basic auth username or URL keys

Fund package maintenance!
verbb

Installs: 3 077

Dependents: 1

Suggesters: 0

Security: 0

Stars: 16

Watchers: 3

Forks: 3

Open Issues: 2

Type:craft-plugin

3.0.0 2022-07-19 00:10 UTC

This package is auto-updated.

Last update: 2022-12-03 02:54:54 UTC


README

Automatically login based on whitelisted IP, basic auth username or URL keys.

Installation

You can install Autologin via the plugin store, or through Composer.

Craft Plugin Store

To install Autologin, navigate to the Plugin Store section of your Craft control panel, search for Autologin, and click the Try button.

Composer

You can also add the package to your project using Composer and the command line.

  1. Open your terminal and go to your Craft project:
cd /path/to/project
  1. Then tell Composer to require the plugin, and Craft to install it:
composer require verbb/autologin && php craft plugin/install autologin

Configuring Autologin

The plugin is configured in the config/ directory in a file you create called autologin.php. What follows is an example of what it might contain.

<?php
return [
    // Enable the Autologin plugin
    'enabled' => true,

    // A list of Craft usernames/emails mapped to IPs
    'ipWhitelist' => [
        'craftUsername' => [
            '162.247.141.58',
            '162.247.141.59',
        ],
    ],

    // A list of Craft usernames/emails mapped to basic auth usernames
    'basicAuth' => [
        'craftUserName1' => 'basicAuthUsername',
        'craftUserName2' => 'basicAuthUsername2',    
    ],
    
    // A list of Craft usernames/emails mapped to url keys
    'urlKeys' => [
        'craftUserName' => 'BepmD8GQBZpaFpXQ',
    ],

    // Redirect to this url after logging in automatically
    'redirectUrl' => '',
];

Login by URL

You can provide your users with a url that automatically logs them in. To set this up, you need a pair of username => password in the urlKeys setting.

After setting that up, you can login by going to siteurl.tld/autologin?key=BepmD8GQBZpaFpXQ.

If you want to redirect to the control panel dashboard, add cp=true to the url: siteurl.tld/autologin?key=BepmD8GQBZpaFpXQ&cp=true

Credits

Originally created by the team at Superbig.

Show your Support

Autologin is licensed under the MIT license, meaning it will always be free and open source – we love free stuff! If you'd like to show your support to the plugin regardless, Sponsor development.

68747470733a2f2f76657262622e696f2f6173736574732f696d672f76657262622d70696c6c2e737667