Skip to content

Commit

Permalink
feat: export auth guards collection
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Jun 19, 2024
1 parent 0c76ad7 commit 6d78ef9
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/auth/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -21,7 +39,7 @@ export async function presetAuth(
codemods: Codemods,
app: Application<any>,
options: {
guard: 'session' | 'access_tokens' | 'basic_auth'
guard: keyof typeof GUARDS
userProvider: 'lucid'
}
) {
Expand Down

0 comments on commit 6d78ef9

Please sign in to comment.