Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Daynnnnn committed Aug 13, 2021
1 parent 3952a53 commit 8dfdcf1
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 22 deletions.
53 changes: 32 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,43 +11,56 @@ Use forward authentication to login to statamic.
From a standard Statamic V3 site, you can run:
`composer require daynnnnn/statamic-forward-auth`

# Setup
Then publish the config:
``

First you'll need to adjust your config/auth.php to use the forward driver on the user provider, then you'll need to add some extra attributes:
# Setup

`type` - A string/class containing authentication type to use in forward driver. Supported types are listed below.
First you'll need to adjust your config/auth.php to use the forward driver on the user provider:

`data` - An array containing attributes to be added to users created via forward authentication.
```
'users' => [
'driver' => 'forward',
],
```

`config` - An array containing type specific values.
Then you can edit `config/statamic/forward-authentication.php` to setup authentication

# Types

By default, there's 2 supported services: `http` and `ldap`

These can be selected via the `default` value in `config/statamic/forward-authentication.php`

## LDAP

### Config
### Description

`host`: `(string)` LDAP Host
An ldap search will be made of the `base_dn` to find the user. If the user is found, try to bind to the found user using provided password.

`ssl`: `(bool)` Whether host should be accessed with SSL
### Config

`base_dn`: `(string)` Root search DN to find user in.
`host: (string)` LDAP Host

`username`: `(string)` Bind users username.
`ssl: (bool)` Whether host should be accessed with SSL

`password`: `(string)` Bind users password.
`base_dn: (string)` Root search DN to find user in.

### Description
`username: (string)` Bind users username.

An ldap search will be made of the `base_dn` to find the user. If the user is found, try to bind to the found user using provided password.
`password: (string)` Bind users password.

## HTTP Authentication

### Description

A POST request will be sent to the endpoint with the attributes of `email` and `password`. The expected response is JSON, and should contain the success status of the credentials, and if the success status is true, the full name of a user.

### Config

`endpoint`: `(string)` Address on which login will be attempted
`endpoint: (string)` Address on which login will be attempted

`result`: `(array)` Where the success status and full name of the user can be found in the JSON response, example:
`result: (array)` Where the success status and full name of the user can be found in the JSON response, example:

If your JSON response looks like this:

Expand All @@ -69,12 +82,10 @@ result => [
],
```

### Description

A POST request will be sent to the endpoint with the attributes of `email` and `password`. The expected response is JSON, and should contain the success status of the credentials, and if the success status is true, the full name of a user.

# Extending

You can also extend this to add your own form of forward authentication, you'll need to create a new class which implements the `AuthServiceContract` interface, and then specify your class as the `type` like this:
You can also extend this to add your own form of forward authentication, you'll need to create a new class which implements the `AuthServiceContract` interface, and then set a service in `config/statamic/forward-authentication.php`. With the service, the only requirment is that the driver is defined as your class, like this:

`'driver' => App\AuthServices\MyCustomAuthService::class,`

`'type' => App\AuthServices\MyCustomAuthService::class,`
The rest of the config can be setup based on what your custom authentication service needs.
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
"description": "Allows you to use login using forward authentication.",
"autoload": {
"psr-4": {
"Daynnnnn\\Statamic\\Auth\\ForwardAuth\\": "src",
"Daynnnnn\\Statamic\\Auth\\ForwardAuth\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Daynnnnn\\Statamic\\Auth\\ForwardAuth\\Tests\\": "tests"
}
},
Expand Down

0 comments on commit 8dfdcf1

Please sign in to comment.