From 6d78ef9c9c7388b4ff428f9af44a2724db1c88cc Mon Sep 17 00:00:00 2001 From: Harminder Virk Date: Wed, 19 Jun 2024 08:48:42 +0530 Subject: [PATCH] feat: export auth guards collection --- src/auth/main.ts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/auth/main.ts b/src/auth/main.ts index caa37ff..002556e 100644 --- a/src/auth/main.ts +++ b/src/auth/main.ts @@ -13,6 +13,24 @@ import type { Codemods } from '@adonisjs/core/ace/codemods' const STUBS_ROOT = joinToURL(import.meta.url, './stubs') +/** + * Collection of configurable guards + */ +export const GUARDS = { + session: { + name: 'Session', + description: 'Authenticate users using cookies and session', + }, + access_tokens: { + name: 'Access Token', + description: 'Authenticate clients using API tokens', + }, + basic_auth: { + name: 'Basic Auth', + description: 'Authenticate users using HTTP Basic Auth', + }, +} + /** * Configures the "@adonisjs/auth" package with one of the * bundled guards and user providers @@ -21,7 +39,7 @@ export async function presetAuth( codemods: Codemods, app: Application, options: { - guard: 'session' | 'access_tokens' | 'basic_auth' + guard: keyof typeof GUARDS userProvider: 'lucid' } ) {