Skip to content

Commit

Permalink
doc(readme): update readme to follow other AdonisJs repo (#29)
Browse files Browse the repository at this point in the history
* doc(readme): update readme to follow other AdonisJs repo

* doc(readme): correct case of the text in the image
  • Loading branch information
RomainLanz authored and thetutlage committed Jan 2, 2017
1 parent 2628d32 commit c58c8ed
Showing 1 changed file with 42 additions and 26 deletions.
68 changes: 42 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,41 @@
# Adonis Auth
<p align="center">
<a href="http://adonisjs.com"><img src="https://cloud.githubusercontent.com/assets/2793951/21462223/c147cefe-c959-11e6-80db-36709c766f17.png" alt="AdonisJs Auth"></a>
</p>

[![Gitter](https://img.shields.io/badge/+%20GITTER-JOIN%20CHAT%20%E2%86%92-1DCE73.svg?style=flat-square)](https://gitter.im/adonisjs/adonis-framework)
[![Trello](https://img.shields.io/badge/TRELLO-%E2%86%92-89609E.svg?style=flat-square)](https://trello.com/b/yzpqCgdl/adonis-for-humans)
[![Version](https://img.shields.io/npm/v/adonis-auth.svg?style=flat-square)](https://www.npmjs.com/package/adonis-auth)
[![Build Status](https://img.shields.io/travis/adonisjs/adonis-auth/master.svg?style=flat-square)](https://travis-ci.org/adonisjs/adonis-auth)
[![Coverage Status](https://img.shields.io/coveralls/adonisjs/adonis-auth/master.svg?style=flat-square)](https://coveralls.io/github/adonisjs/adonis-auth?branch=master)
[![Downloads](https://img.shields.io/npm/dt/adonis-auth.svg?style=flat-square)](https://www.npmjs.com/package/adonis-auth)
[![License](https://img.shields.io/npm/l/adonis-auth.svg?style=flat-square)](https://opensource.org/licenses/MIT)
<p align="center">
<a href="https://www.npmjs.com/package/adonis-auth"><img src="https://img.shields.io/npm/v/adonis-auth.svg?style=flat-square" alt="Version"></a>
<a href="https://travis-ci.org/adonisjs/adonis-auth"><img src="https://img.shields.io/travis/adonisjs/adonis-auth/master.svg?style=flat-square" alt="Build Status"></a>
<a href="https://coveralls.io/github/adonisjs/adonis-auth?branch=master"><img src="https://img.shields.io/coveralls/adonisjs/adonis-auth/master.svg?style=flat-square" alt="Coverage Status"></a>
<a href="https://www.npmjs.com/package/adonis-auth"><img src="https://img.shields.io/npm/dt/adonis-auth.svg?style=flat-square" alt="Downloads"></a>
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/npm/l/adonis-auth.svg?style=flat-square" alt="License"></a>
</p>

> :pray: This repository contains the authentication provider for Adonis Framework.
<p align="center">
<a href="https://gitter.im/adonisjs/adonis-framework"><img src="https://img.shields.io/badge/gitter-join%20us-1DCE73.svg?style=flat-square" alt="Gitter"></a>
<a href="https://trello.com/b/yzpqCgdl/adonis-for-humans"><img src="https://img.shields.io/badge/trello-roadmap-89609E.svg?style=flat-square" alt="Trello"></a>
<a href="https://www.patreon.com/adonisframework"><img src="https://img.shields.io/badge/patreon-support%20AdonisJs-brightgreen.svg?style=flat-square" alt="Support AdonisJs"></a>
</p>

Auth provider is a fully featured authentication system for Adonis framework. It supports multiple authentication schemes to authenticate HTTP requests.
<br>

## Supported Schemes
AdonisJs Auth is a fully featured authentication system for AdonisJs framework.<br>
It supports by default multiple authentication schemes to authenticate HTTP requests.

1. Sessions
2. Basic-Auth
3. JWT Tokens
3. JSON Web Token
4. API Token

In order to verify users credentials, it makes use of Serializers and below serializers are shipped with this library.

1. Lucid
2. Database Provider

You are free to add your own schemes and serializers and documentation for same is written on the official website
You are free to add your own schemes and serializers and documentation for same is written [on the official website](http://adonisjs.com/docs/3.2/authentication#_serializer).

<br>
<hr>
<br>

## Table of Contents

Expand All @@ -33,26 +44,28 @@ You are free to add your own schemes and serializers and documentation for same
* [Team Members](#team-members)
* [Contribution Guidelines](#contribution-guidelines)

<br>
## <a name="config"></a>Config

Configuration settings are slightly different for each scheme. When you define settings, we call them authenticators.

In short, an authenticator is a combination of `scheme`, `serializer` and common settings around them.

### Example
**config/auth.js**

```javascript
// config/auth.js
{
authenticator: 'session',

session: {
...
// ...
}
}
```


### Session
#### Session

```javascript
session: {
Expand All @@ -64,7 +77,7 @@ session: {
}
```

### Basic Auth
#### Basic Auth

```javascript
basicAuth: {
Expand All @@ -76,7 +89,7 @@ basicAuth: {
}
```

### JWT
#### JSON Web Token

```javascript
jwt: {
Expand All @@ -87,7 +100,7 @@ jwt: {
}
```

### API Tokens
#### API Token

Personal api tokens are like passwords for a given account. Majority of API's needs API based authentication because:

Expand All @@ -106,8 +119,8 @@ and give it to the developer for testing.

Also you need to create the relationship between the user and the token, so that the Lucid serializer can make use of it.

**app/Model/User.js**
```javascript
// app/Model/User.js
class User extends Lucid {

apiTokens () {
Expand All @@ -117,8 +130,8 @@ class User extends Lucid {
}
```

**app/Model/Token.js**
```javascript
// app/Model/Token.js
class Token extends Lucid {

user () {
Expand All @@ -128,6 +141,7 @@ class Token extends Lucid {
}
```

<br>
## <a name="setup"></a>Setup

In order to make use of the Auth provider, you need to register it inside your `bootstrap/app.js` file.
Expand All @@ -143,8 +157,8 @@ const providers = [

Next you need to register the `AuthInit` middleware. This middleware will create a new instance of Auth Manager and will assign it to the request object.

**app/Http/kernel.js**
```javascript
// app/Http/kernel.js
const globalMiddleware = [
...,
'Adonis/Middleware/AuthInit'
Expand All @@ -171,8 +185,8 @@ yield request.auth.logout()

Auth provider also ships with an extra middleware, which can be assigned to your routes to authenticate them.

**app/Http/kernel.js**
```javascript
// app/Http/kernel.js
const namedMiddleware = {
auth: 'Adonis/Middleware/Auth'
}
Expand All @@ -183,21 +197,23 @@ and then inside your routes file you can do.
#### Using default authenticator
```javascript
Route
.get('account', 'AccountController.index')
.get('account', 'AccountsController.index')
.middleware('auth')
```

#### Defining authenticator
```javascript
Route
.get('account', 'AccountController.index')
.get('account', 'AccountsController.index')
.middleware('auth:basic')
```

<br>
## <a name="team-members"></a>Team Members

* Harminder Virk ([Caffiene Blogging](http://amanvirk.me/)) <virk.officials@gmail.com>

<br>
## <a name="contribution-guidelines"></a>Contribution Guidelines

In favor of active development we accept contributions for everyone. You can contribute by submitting a bug, creating pull requests or even improving documentation.
Expand Down

0 comments on commit c58c8ed

Please sign in to comment.