Update documentation

Fix typo
This commit is contained in:
René Preuß
2023-04-08 16:07:39 +02:00
parent 06feac925b
commit 4b7d11f44d
2 changed files with 38 additions and 15 deletions

View File

@@ -1,18 +1,28 @@
# 🔒 @bitinflow/nuxt-oauth
**@bitinflow/nuxt-oauth** is a Nuxt 3 Module that provides a simple OAuth 2 implementation for static site nuxt applications. It uses an Implicit Grant where no backend code is required, and plans to support PKCE as well. This package is intended to be used with laravel-passport, allowing users to interact with their first-party API using their own OAuth provider. Currently, it does not support multiple OAuth providers. With **@bitinflow/nuxt-oauth**, developers can quickly and easily implement secure OAuth authentication in their Nuxt applications.
**@bitinflow/nuxt-oauth** is a Nuxt 3 Module that provides a simple OAuth 2 implementation for static site nuxt
applications for which no backend code is required. It uses the recommended Authorization Code Grant with PKCE by
default and supports Implicit Grant Tokens as well.
This package is intended to be used with Laravel Passport, allowing users to interact with their first-party API using
their own OAuth provider. Currently, it does not support multiple OAuth providers. With **@bitinflow/nuxt-oauth**,
developers can quickly and easily implement secure OAuth authentication in their Nuxt applications.
- [✨  Release Notes](/CHANGELOG.md)
## Features
- 📦 Authorization Code Grant with PKCE (default)
- 📦 Simple OAuth 2 Implicit Grant authentication ([not recommended](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-security-topics))
- 📦 Simple OAuth 2 Implicit Grant Token
authentication ([not recommended](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-security-topics))
- 📦 Intended to be used with laravel-passport
- 📦 Single OAuth provider support (currently)
## Quick Setup
> **Note:** Starting with **@bitinflow/nuxt-oauth** v1.2.0, the default response type is `code`. If you want to use the
> `token` response type, you need to set it explicitly in the configuration.
1. Add `@bitinflow/nuxt-oauth` dependency to your project
```bash
@@ -27,8 +37,9 @@ npm install --save-dev @bitinflow/nuxt-oauth
```
2. Add `@bitinflow/nuxt-oauth` to the `modules` section of `nuxt.config.ts` and disable `ssr`.
Or alternatively disable `ssr` via `routeRules`, only for pages where `auth` or `guest` middlewares are needed. Typically account section and login page.
Or alternatively disable `ssr` via `routeRules`, only for pages where `auth` or `guest` middlewares are needed.
Typically account section and login page.
```js
export default defineNuxtConfig({
@@ -39,28 +50,40 @@ export default defineNuxtConfig({
ssr: false,
// or
routeRules: {
'/account/**': { ssr: false },
'/auth/**': { ssr: false }
'/account/**': {ssr: false},
'/auth/**': {ssr: false}
},
// using code response type (default)
oauth: {
redirect: {
login: '/login',
logout: '/',
callback: '/login',
home: '/home'
},
endpoints: {
authorization: 'https://example.com/v1/oauth/authorization',
userInfo: `https://example.com/api/users/me`,
authorization: 'https://example.com/oauth/authorize',
token: 'https://example.com/oauth/token',
userInfo: 'https://example.com/api/users/me',
logout: 'https://example.com/oauth/logout'
},
clientId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
scope: ['user:read']
},
// using token response type (not recommended)
oauth: {
endpoints: {
authorization: 'https://example.com/oauth/authorize',
userInfo: 'https://example.com/api/users/me',
logout: 'https://example.com/oauth/logout'
},
clientId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
responseType: 'token',
scope: ['user:read']
},
})
```
This will be your callback url (host is determined by `window.location.origin`):
- Callback: `http://localhost:3000/login`
That's it! You can now use @bitinflow/nuxt-oauth in your Nuxt app ✨
## Development