A Library for basic HTTP Authentication in Code Igniter.
A Code Igniter Library for HTTP Authentication.
To install, download and install Splint from https://splint.cynobit.com/downloads/splint and then run the below from your Code Igniter project root.
splint install francis94c/http-auth
From anywhere you can access the CI
instance
$params = array(
"auth" => array (
"username" => "hashed_password"
),
"bearer" => "Bearer Name",
"denied_message" => "Access Denied!"
);
$this->load->splint("francis94c/http-auth", "+HTTPAuth", $params, "http_auth");
OR Alternatively load with the below steps.
http_auth_config.php
in your application/config
folder.<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$config["http_auth_config"] = array(
"auth" => array (
"username" => "hashed_password"
),
"bearer" => "Bearer Name",
"denied_message" => "Access Denied!"
)
?>
$this->load->package("francis94c/http-auth");
After loading, simply place the below line of code where you want authentication.
$this->http_auth->authenticate();
The above is most preferable at a Controller's Constructor.
This will output your $denied_message
if authentication fails or allow the rest of the Controller to run if successful.
with from CynoBit