Download the PHP package codemonauts/craft-basicauth without Composer
On this page you can find all versions of the php package codemonauts/craft-basicauth. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download codemonauts/craft-basicauth
More information about codemonauts/craft-basicauth
Files in codemonauts/craft-basicauth
Package craft-basicauth
Short Description Craft CMS plugin for HTTP Basic Authentication within templates.
License MIT
Informations about the package craft-basicauth
HTTP Basic Authentication for Craft CMS
A plugin for Craft CMS that provides HTTP Basic Authentication (BasicAuth) within templates.
Requirements
- Craft CMS >= 4.0.0
Installation
Open your terminal and go to your Craft project:
Apache
I you are using Apache to host your CraftCMS, you have to tell Apache to pass the Authorization
header (which contains the basic auth data) to PHP (See the Dokumenation). Otherwise Craft will never see any credentials and will continue to show you the dialog to enter your username and password. This can either be set directly in the Apache config file or in your .htaccess
:
Settings
On the settings page in the control panel you can add credentials to use for authentication.
You can add a list of IP addresses and subnets (v4 and v6) that have access without any credentials. Use the CIDR notation for subnets.
These settings supports the project config if enabled.
{% basicauth %} Tag
In your templates you can require BasicAuth:
Parameters
The {% basicauth %}
tag supports the following parameters:`
require
This specifies the type of check to be made. You can check against a single user
, a group
of user, any valid
user and also accept any
provided credentials.
This parameter is required.
site
This specifies the site handle for which the authentication should be made. The Authentication is only enforced when the current site handle is the same as specified.
env
This specifies the environment for which the authentication should be made. The Authentication is only enforced when the current environment is the same as specified.
if
Only activates the BasicAuth if a certain condition is met.
Globals
This plugin provides two global variables with the credentials of the user:
Why should I use this plugin and not the webserver module?
May you ask yourself why you should use this plugin and not the Basic Authentication provided by the webserver? Here are some aspects:
- You have full control of the Basic Authentication without your DevOps friends.
- You can add the
{% basicauth %}
wherever you need it: In your central layout for all pages or only in one special template with some fancy conditions. - You can use conditions from Craft. For example:
{% basicauth require valid if not currentUser %}
With ❤ by codemonauts
All versions of craft-basicauth with dependencies
symfony/http-foundation Version ^5.3.1
ext-json Version *