mirror of
https://github.com/bitinflow/nuxt-oauth.git
synced 2026-03-13 13:45:59 +00:00
Update documentation
Fix typo
This commit is contained in:
51
README.md
51
README.md
@@ -1,18 +1,28 @@
|
|||||||
# 🔒 @bitinflow/nuxt-oauth
|
# 🔒 @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)
|
- [✨ Release Notes](/CHANGELOG.md)
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- 📦 Authorization Code Grant with PKCE (default)
|
- 📦 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
|
- 📦 Intended to be used with laravel-passport
|
||||||
- 📦 Single OAuth provider support (currently)
|
- 📦 Single OAuth provider support (currently)
|
||||||
|
|
||||||
## Quick Setup
|
## 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
|
1. Add `@bitinflow/nuxt-oauth` dependency to your project
|
||||||
|
|
||||||
```bash
|
```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`.
|
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
|
```js
|
||||||
export default defineNuxtConfig({
|
export default defineNuxtConfig({
|
||||||
@@ -39,28 +50,40 @@ export default defineNuxtConfig({
|
|||||||
ssr: false,
|
ssr: false,
|
||||||
// or
|
// or
|
||||||
routeRules: {
|
routeRules: {
|
||||||
'/account/**': { ssr: false },
|
'/account/**': {ssr: false},
|
||||||
'/auth/**': { ssr: false }
|
'/auth/**': {ssr: false}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// using code response type (default)
|
||||||
oauth: {
|
oauth: {
|
||||||
redirect: {
|
|
||||||
login: '/login',
|
|
||||||
logout: '/',
|
|
||||||
callback: '/login',
|
|
||||||
home: '/home'
|
|
||||||
},
|
|
||||||
endpoints: {
|
endpoints: {
|
||||||
authorization: 'https://example.com/v1/oauth/authorization',
|
authorization: 'https://example.com/oauth/authorize',
|
||||||
userInfo: `https://example.com/api/users/me`,
|
token: 'https://example.com/oauth/token',
|
||||||
|
userInfo: 'https://example.com/api/users/me',
|
||||||
logout: 'https://example.com/oauth/logout'
|
logout: 'https://example.com/oauth/logout'
|
||||||
},
|
},
|
||||||
clientId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
|
clientId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
|
||||||
scope: ['user:read']
|
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 ✨
|
That's it! You can now use @bitinflow/nuxt-oauth in your Nuxt app ✨
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ const defaults: ModuleOptions = {
|
|||||||
endpoints: {
|
endpoints: {
|
||||||
authorization: 'https://accounts.bitinflow.com/oauth/authorize',
|
authorization: 'https://accounts.bitinflow.com/oauth/authorize',
|
||||||
token: 'https://accounts.bitinflow.com/oauth/token',
|
token: 'https://accounts.bitinflow.com/oauth/token',
|
||||||
userInfo: `https://accounts.bitinflow.com/api/v3/user`,
|
userInfo: 'https://accounts.bitinflow.com/api/v3/user',
|
||||||
logout: null,
|
logout: null,
|
||||||
},
|
},
|
||||||
refreshToken: {
|
refreshToken: {
|
||||||
|
|||||||
Reference in New Issue
Block a user