2.0.1 • Published 5 months ago

@wisemen/vue-core-auth v2.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
5 months ago

Wisemen vue-core OAuth Client

This package provides a simple way to authenticate with an OAuth2 server.

Installation

pnpm add @wisemen/vue-core-oauth-client

Usage

OAuth2VueClient

Create a new file auth.lib.ts and add the following code:

import { OAuth2VueClient } from '@wisemen/vue-core-auth'
import axios from 'axios'

import {
  API_AUTH_URL,
  API_CLIENT_ID,
  API_CLIENT_SECRET,
} from '@/constants/environment.constant.ts'

export const oAuthClient = new OAuth2VueClient({
  clientId: API_CLIENT_ID,
  axios,
  clientSecret: API_CLIENT_SECRET,
  tokenEndpoint: `${API_AUTH_URL}/token`,
})

ZitadelClient

Create a new file auth.lib.ts and add the following code:

import { ZitadelClient, useAxiosFetchStrategy, localStorageTokensStrategy } from '@wisemen/vue-core-auth'
import axios from 'axios'

import {
  AUTH_BASE_URL,
  AUTH_CLIENT_ID,
  AUTH_ORGANIZATION_ID,
  CURRENT_ENVIRONMENT,
} from '@/constants/environment.constant.ts'

export const oAuthClient = new ZitadelClient({
  clientId: AUTH_CLIENT_ID,
  organizationId: AUTH_ORGANIZATION_ID,
  fetchStrategy: new AxiosFetchStrategy(axios),
  tokensStrategy: new LocalStorageTokensStrategy(), // Optional, defaults to localStorage 
  baseUrl: AUTH_BASE_URL,
  loginRedirectUri: `${window.location.origin}/auth/callback`,
  offline: CURRENT_ENVIRONMENT === 'e2e',
  postLogoutRedirectUri: `${window.location.origin}/auth/logout`,
})
2.0.1

5 months ago

2.0.0

5 months ago

1.2.0

5 months ago

1.2.2

5 months ago

1.2.1

5 months ago

1.1.0

7 months ago

0.0.6

7 months ago

0.0.5

7 months ago

0.0.4

7 months ago

0.0.3

7 months ago

0.0.2

7 months ago

0.0.1

7 months ago