Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always use Config\Services to allow users to override with their own service. #122

Merged
merged 1 commit into from
Oct 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,19 @@ The following Services are provided by the package:
Provides access to any of the authenticacation packages that Myth:Auth knows about. By default
it will return the "Local Authentication" library, which is the basic password-based system.

$authenticate = Myth\Auth\Config\Services::authentication();
$authenticate = Config\Services::authentication();

You can specify the library to use as the first argument:

$authenticate = Myth\Auth\Config\Services::authentication('jwt');
$authenticate = Config\Services::authentication('jwt');

**authorization**

Provides access to any of the authorization libraries that Myth:Auth knows about. By default
it will return the "Flat" authorization library, which is a Flat RBAC (role-based access control)
as defined by NIST. It provides user-specific permissions as well as group (role) based permissions.

$authorize = $auth = Myth\Auth\Config\Services::authorization();
$authorize = $auth = Config\Services::authorization();

**passwords**

Expand All @@ -104,7 +104,7 @@ supports many of [NIST's latest Digital Identity guidelines](https://pages.nist.
validator comes with a dictionary of over 620,000 common/leaked passwords that can be checked against.
A handful of variations on the user's email/username are automatically checked against.

$authenticate = Myth\Auth\Config\Services::passwords();
$authenticate = Config\Services::passwords();

Most of the time you should not need to access this library directly, though, as a new Validation rule
is provided that can be used with the Validation library, `strong_password`. In order to enable this,
Expand Down
2 changes: 1 addition & 1 deletion docs/authorization.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ with users for low-level security. While the class can easily be used on it's ow
You can get an instance of the authorization library using the provided Services class, which will automatically be
detected by CodeIgniter.

$authorize = $auth = Myth\Auth\Config\Services::authorization();
$authorize = $auth = Config\Services::authorization();

Once you have this service, you have full access to all of the methods described below.

Expand Down
2 changes: 1 addition & 1 deletion src/Authentication/AuthenticationBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use Config\App;
use CodeIgniter\Events\Events;
use CodeIgniter\Model;
use Myth\Auth\Config\Services;
use Config\Services;
use Myth\Auth\Entities\User;
use Myth\Auth\Exceptions\AuthException;
use Myth\Auth\Exceptions\UserNotFoundException;
Expand Down
2 changes: 1 addition & 1 deletion src/Authentication/Passwords/ValidationRules.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php namespace Myth\Auth\Authentication\Passwords;

use Myth\Auth\Config\Services;
use Config\Services;

/**
* Class ValidationRules
Expand Down
12 changes: 6 additions & 6 deletions src/Commands/CreateGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

use CodeIgniter\CLI\BaseCommand;
use CodeIgniter\CLI\CLI;
use CodeIgniter\Config\Services;
use Config\Services;

class CreateGroup extends BaseCommand
{
protected $group = 'Auth';
protected $name = 'auth:create_group';
protected $description = "Adds a new group to the database.";

protected $usage = "auth:create_group [name] [description]";
protected $arguments = [
'name' => "The name of the new group to create",
Expand All @@ -20,21 +20,21 @@ public function run(array $params = [])
{
$db = db_connect();
$auth = Services::authorization();

// consume or prompt for group name
$name = array_shift($params);
if (empty($name))
{
$name = CLI::prompt('Group name', null, 'required');
}

// consume or prompt for description
$description = array_shift($params);
if (empty($description))
{
$description = CLI::prompt('Description', '');
}

try
{
$auth->createGroup($name, $description);
Expand All @@ -43,7 +43,7 @@ public function run(array $params = [])
{
$this->showError($e);
}

$this->call('auth:list_groups');
}
}
2 changes: 1 addition & 1 deletion src/Controllers/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use CodeIgniter\Controller;
use Config\Email;
use Myth\Auth\Config\Services;
use Config\Services;
use Myth\Auth\Entities\User;
use Myth\Auth\Models\UserModel;

Expand Down
2 changes: 1 addition & 1 deletion src/Helpers/auth_helper.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

use Myth\Auth\Config\Services;
use Config\Services;

if (! function_exists('logged_in'))
{
Expand Down