Skip to content

Commit

Permalink
Merge branch 'master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
pooya parsa committed May 24, 2019
2 parents aacb191 + 0729bd4 commit bf53d55
Show file tree
Hide file tree
Showing 23 changed files with 7,421 additions and 112 deletions.
1 change: 0 additions & 1 deletion .gitbook.yaml

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<h1 align="center" >🔑 Auth Module</h1>
<p align="center">Authentication module for Nuxt.js</p>
<p align="center">Zero-boilerplate authentication support for Nuxt.js!</p>

<p align="center">
<a href="https://david-dm.org/nuxt-community/auth-module">
Expand Down Expand Up @@ -28,7 +28,7 @@
</p>


## Development
## Development

Running demo for development:

Expand Down
59 changes: 59 additions & 0 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
module.exports = {
title: 'Auth Module',
description: 'Authentication module for Nuxt',
themeConfig: {
repo: 'nuxt-community/auth-module',
docsDir: 'docs',
editLinks: true,
editLinkText: 'Edit this page on GitHub',
sidebarDepth: 2,
sidebar: {
'/api/': [
'/api/auth',
'/api/options',
'/api/storage'
],
'/': [
{
title: 'Guide',
collapsable: false,
children: [
'/',
'/guide/setup',
'/guide/scheme',
'/guide/provider',
]
},
{
title: 'Schemes',
collapsable: false,
children: [
'/schemes/local',
'/schemes/oauth2'
]
},
{
title: 'Providers',
collapsable: false,
children: [
'/providers/auth0',
'/providers/facebook',
'/providers/github',
'/providers/google',
'/providers/laravel-passport'
]
}
],
},
nav: [
{
text: 'Guide',
link: '/'
},
{
text: 'API',
link: '/api/'
}
]
}
}
13 changes: 0 additions & 13 deletions docs/README.md

This file was deleted.

25 changes: 0 additions & 25 deletions docs/SUMMARY.md

This file was deleted.

2 changes: 1 addition & 1 deletion docs/api/auth.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# $auth
# auth

[Source Code](https://github.com/nuxt-community/auth-module/blob/dev/lib/core/auth.js)

Expand Down
24 changes: 12 additions & 12 deletions docs/options.md → docs/api/options.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Options
# options

General options shared with all strategies. See [defaults.js](https://github.com/nuxt-community/auth-module/blob/master/lib/module/defaults.js) for defaults.

### `redirect`
## `redirect`

Default:

Expand All @@ -25,13 +25,13 @@ auth: {
Each redirect path can be disabled by setting to `false`.
Also you can disable all redirects by setting `redirect` to `false`

### `watchLoggedIn`
## `watchLoggedIn`

- Default: `true`

When enabled (default) user will be redirected on login/logouts.

### `token`
## `token`

Auth tokens are stored in various storage providers (cookie, localStorage, vuex) on user login to provide a seamless auth experience across server-side rendering (SSR) and client-side rendering. Tokens are stored under with storage keys of the format: `{storageProvider.prefix}{token.prefix}{strategy}`. See [auth.js - Token helpers](https://github.com/nuxt-community/auth-module/blob/master/lib/core/auth.js#L160) and [storage.js](https://github.com/nuxt-community/auth-module/blob/master/lib/core/storage.js) for more details.

Expand All @@ -47,7 +47,7 @@ auth: {

* **prefix** - Default prefix used in building a key for token storage across all storage providers.

### `localStorage`
## `localStorage`

Default:

Expand All @@ -71,7 +71,7 @@ auth {

Otherwise the auth token will be stored in localStorage at a default key of: `auth._token.{provider}`.

### `cookie`
## `cookie`

Default:

Expand Down Expand Up @@ -105,39 +105,39 @@ auth: {

Otherwise the auth token will be stored in a cookie named by default as: `auth._token.{provider}`.

### `plugins`
## `plugins`

If you have any nuxt plugin that depends on `$auth` you have to specify it here instead of top-level `plugins` option in `nuxt.config.js`.

See [Extending Auth Plugin](recipes/extend.md)

### `resetOnError`
## `resetOnError`

* Default: `false`

Either a boolean or a function is accepted. If a function is passed, it will take the same arguments as `onError` handlers and return `Boolean` to inform whether a reset should be performed.

If enabled, user will be automatically logged out if an error happens. (For example when token expired)

### `rewriteRedirects`
## `rewriteRedirects`

* Default: `true`

If enabled, user will redirect back to the original guarded route instead of `redirect.home`.

### `fullPathRedirect`
## `fullPathRedirect`

Default: `false`

If true, use the full route path with query parameters for redirect

### `vuex.namespace`
## `vuex.namespace`

* Default: `auth`

Vuex store namespace for keeping state.

### `scopeKey`
## `scopeKey`

* Default: `scope`

Expand Down
5 changes: 5 additions & 0 deletions docs/api/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# API

- [options](./options.md)
- [auth](./auth.md)
- [storage](./storage.md)
10 changes: 5 additions & 5 deletions docs/api/storage.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# $auth.$storage
# storage

[Source Code](https://github.com/nuxt-community/auth-module/blob/dev/lib/core/storage.js)

Auth module has a built-in powerful and universal storage to keep tokens and profile data.

### Universal Storage
## Universal Storage

Universally keep state in vuex, localStorage and Cookies:

Expand All @@ -14,7 +14,7 @@ this.$auth.$storage.getUniversal(key, isJson)
this.$auth.$storage.syncUniversal(key, defaultValue, isJson)
```

### Local State
## Local State

Access to local state:

Expand All @@ -32,14 +32,14 @@ this.$auth.$storage.getState(key)
this.$auth.$storage.watchState('loggedIn', newValue => { })
```

### Cookies
## Cookies

```js
this.$auth.$storage.setCookie(key, val, isJson)
this.$auth.$storage.getCookie(key)
```

### Local Storage
## Local Storage

```js
this.$auth.$storage.setLocalStorage(key, val, isJson)
Expand Down
File renamed without changes.
7 changes: 7 additions & 0 deletions docs/providers/README.md → docs/guide/provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@
Providers are an abstraction on top of Schemes.
They make it super easy to integrate with popular authentication services. They can do even more by provider required server-side changes such as token signing and you can also write your own provider.

## Supported Providers

- [Auth0](../providers/auth0.md)
- [Facebook](../providers/facebook.md)
- [Github](../providers/github.md)
- [Google](../providers/google.md)
- [Laravel Passport](../providers/laravel-passport.md)
4 changes: 1 addition & 3 deletions docs/schemes/README.md → docs/guide/scheme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Schemes and Strategies
# Schemes

Schemes define authentication logic. Strategy is a configurated instance of Scheme. You can have multiple schemes and strategies in your project.

Expand All @@ -24,5 +24,3 @@ auth: {
}
}
```

👉 Now that you have an idea what schemes and strategies are, you can configure the default [Local Scheme](local.md) or use a [Provider](../providers/README.md).
4 changes: 3 additions & 1 deletion docs/setup.md → docs/guide/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ auth: {
}
```

ℹ️ When adding `auth-module` to a new Nuxt project ensure you have activated the Vuex store. More information on how to do that can be found on the [Nuxt Getting Started Guide](https://nuxtjs.org/guide/vuex-store).
::: warning IMPORTANT
When adding `auth-module` to a new Nuxt project ensure you have activated the Vuex store. More information on how to do that can be found on the [Nuxt Getting Started Guide](https://nuxtjs.org/guide/vuex-store).
:::
10 changes: 10 additions & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"private": true,
"scripts": {
"dev": "vuepress dev",
"build": "vuepress build"
},
"devDependencies": {
"vuepress": "^1.0.0-alpha.47"
}
}
4 changes: 2 additions & 2 deletions docs/providers/auth0.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Auth0 Provider
# Auth0

[Source Code](https://github.com/nuxt-community/auth-module/blob/dev/lib/providers/auth0.js)

Expand Down Expand Up @@ -31,7 +31,7 @@ User will be redirected to a page like this:

💁 This provider is based on [oauth2 scheme](../schemes/oauth2.md) and supports all scheme options.

### Obtaining `client_id`, `domain`, and `audience`
## Obtaining `client_id`, `domain`, and `audience`

`client_id` and `domain` are **REQUIRED**. Your application needs some details about this client to communicate with Auth0.

Expand Down
4 changes: 2 additions & 2 deletions docs/providers/facebook.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Facebook Provider
# Facebook

[Source Code](https://github.com/nuxt-community/auth-module/blob/dev/lib/providers/facebook.js)

Expand All @@ -24,7 +24,7 @@ this.$auth.loginWith('facebook')

💁 This provider is based on [oauth2 scheme](../schemes/oauth2.md) and supports all scheme options.

### Obtaining `client_id`
## Obtaining `client_id`

This option is **REQUIRED**. To obtain one, create your app in [Facebook Developers](https://developers.facebook.com) and add "Facebook Login" product. Then set valid callback URLs. Client ID is same as your "App ID".

2 changes: 1 addition & 1 deletion docs/providers/github.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ this.$auth.loginWith('github')

💁 This provider is based on [oauth2 scheme](../schemes/oauth2.md) and supports all scheme options.

### Obtaining `client_id` and `client_secret`
## Obtaining `client_id` and `client_secret`

This option is **REQUIRED**. To obtain one, create your app in [Create a new Oauth APP](https://github.com/settings/applications/new) and use provided "Client ID" and "Client Secret".

8 changes: 6 additions & 2 deletions docs/providers/google.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Google Provider
---
sidebarDepth: 0
---

# Google

[Source Code](https://github.com/nuxt-community/auth-module/blob/dev/lib/providers/google.js)

Expand All @@ -22,7 +26,7 @@ this.$auth.loginWith('google')

💁 This provider is based on [oauth2 scheme](../schemes/oauth2.md) and supports all scheme options.

### Obtaining `client_id`
## Obtaining `client_id`

This option is **REQUIRED**. To obtain one, create your app in [Google API Console](https://console.developers.google.com), Create a new project and from Credentials tab, create a new "Oauth Client ID".

Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ auth: {
}
```

## Usage

Anywhere in your application logic:

```js
Expand Down
22 changes: 22 additions & 0 deletions docs/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Auth Module

Zero-boilerplate authentication support for Nuxt.js!

## Getting Started

If it is first time using this module, reading resources below in order is recommended:

1. [Add auth and axios modules](./guide/setup.md)
2. [Configure local scheme](./schemes/local.md)
3. [Customize options](./api/options.md)
4. [Use `$auth` service](./api/auth.md)

## More Resources

* [Glassory](./glassory.md)
* [GitHub](https://github.com/nuxt-community/auth-module)
* [Releases](https://github.com/nuxt-community/auth-module/releases)
* [Migration Guide](./migration.md)
* [Examples](https://github.com/nuxt-community/auth-module/tree/dev/examples)
* [Demo](https://nuxt-auth.herokuapp.com)

Loading

0 comments on commit bf53d55

Please sign in to comment.