4 Commits

Author SHA1 Message Date
René Preuß
f2e4b5c1c9 chore(release): v1.0.2 2023-02-18 14:46:38 +01:00
René Preuß
e0c8c411a1 Fix route 2023-02-18 14:46:10 +01:00
René Preuß
15c3d43831 Add important documentation 2023-02-18 14:45:14 +01:00
René Preuß
c954054621 Change readme 2023-02-18 14:34:42 +01:00
5 changed files with 50 additions and 30 deletions

8
CHANGELOG.md Normal file
View File

@@ -0,0 +1,8 @@
# Changelog
## v1.0.2
## v1.0.0
Initial Release

View File

@@ -1,47 +1,66 @@
# @bitinflow/nuxt-oauth
[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![License][license-src]][license-href]
> My new Nuxt module
> Nuxt module for OAuth2 authentication
- [✨  Release Notes](/CHANGELOG.md)
<!-- - [📖 &nbsp;Documentation](https://example.com) -->
## Features
<!-- Highlight some of the features your module provide here -->
- ⛰ &nbsp;Foo
- 🚠 &nbsp;Bar
- 🌲 &nbsp;Baz
- 📦 OAuth2 authentication
- 📦 Supports only one OAuth2 provider
- 📦 Supports only implicit flow
## Quick Setup
1. Add `my-module` dependency to your project
1. Add `@bitinflow/nuxt-oauth` dependency to your project
```bash
# Using pnpm
pnpm add -D my-module
pnpm add -D @bitinflow/nuxt-oauth
# Using yarn
yarn add --dev my-module
yarn add --dev @bitinflow/nuxt-oauth
# Using npm
npm install --save-dev my-module
npm install --save-dev @bitinflow/nuxt-oauth
```
2. Add `my-module` to the `modules` section of `nuxt.config.ts`
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.
```js
export default defineNuxtConfig({
modules: [
'my-module'
]
'@bitinflow/nuxt-oauth'
],
ssr: false,
// or
routeRules: {
'/account/**': { ssr: false },
'/auth/**': { ssr: false }
},
oauth: {
redirect: {
login: '/login',
logout: '/',
callback: '/login',
home: '/home'
},
endpoints: {
authorization: 'https://example.com/v1/oauth/authorization',
userInfo: `https://example.com/api/users/me`,
logout: 'https://example.com/oauth/logout'
},
clientId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
scope: ['user:read']
},
})
```
That's it! You can now use My Module in your Nuxt app ✨
That's it! You can now use @bitinflow/nuxt-oauth in your Nuxt app ✨
## Development
@@ -68,13 +87,3 @@ npm run test:watch
# Release new version
npm run release
```
<!-- Badges -->
[npm-version-src]: https://img.shields.io/npm/v/my-module/latest.svg?style=flat&colorA=18181B&colorB=28CF8D
[npm-version-href]: https://npmjs.com/package/my-module
[npm-downloads-src]: https://img.shields.io/npm/dm/my-module.svg?style=flat&colorA=18181B&colorB=28CF8D
[npm-downloads-href]: https://npmjs.com/package/my-module
[license-src]: https://img.shields.io/npm/l/my-module.svg?style=flat&colorA=18181B&colorB=28CF8D
[license-href]: https://npmjs.com/package/my-module

View File

@@ -1,6 +1,6 @@
{
"name": "@bitinflow/nuxt-oauth",
"version": "1.0.1",
"version": "1.0.2",
"description": "Nuxt 3 OAuth Module",
"license": "MIT",
"type": "module",

View File

@@ -1,5 +1,8 @@
export default defineNuxtConfig({
modules: ['../src/module'],
ssr: false,
oauth: {
redirect: {
login: '/login/', // sandbox appends / at the end of url

View File

@@ -45,7 +45,7 @@ export default async (options: ComposableOptions = {
accessToken.value = null;
user.value = null;
return navigateTo('/')
return navigateTo(authConfig.endpoints.logout || authConfig.redirect.logout)
}
const setBearer = async (token: string, tokenType: string, expires: number) => {