Clean up codebase and prepare as template
Remove unused files and code: - Delete test/debug endpoints (test.get.ts, public.get.ts, user.get.ts, debug-config backup) - Remove unused OAuth wrapper (oauth-authentik.ts) - Clean up debug console.log statements - Simplify code comments Fix TypeScript errors: - Add @types/node dependency - Create index.d.ts with User interface extension - Fix UButton color props (red→error, gray→neutral) - Add type assertions in protected.get.ts Update documentation: - Enhance README.md as template documentation - Update SETUP.md with correct API routes (/api/auth/* instead of /auth/*) - Add NUXT_OAUTH_AUTHENTIK_SERVER_URL_INTERNAL documentation - Update endpoint documentation This commit prepares the repository to be used as a template for future Nuxt 4 + Authentik OAuth projects.
This commit is contained in:
@@ -3,15 +3,12 @@ import { withQuery } from 'ufo'
|
||||
|
||||
/**
|
||||
* OAuth Authentik Login Handler
|
||||
* Ruta: /api/auth/authentik
|
||||
*
|
||||
* Este endpoint inicia el flujo OAuth con Authentik
|
||||
* Handles OAuth flow: initial redirect and callback
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const runtimeConfig = useRuntimeConfig(event)
|
||||
const query = getQuery(event)
|
||||
|
||||
// Configuración de Authentik
|
||||
const config = {
|
||||
clientId: runtimeConfig.oauth.authentik.clientId,
|
||||
clientSecret: runtimeConfig.oauth.authentik.clientSecret,
|
||||
@@ -21,13 +18,6 @@ export default defineEventHandler(async (event) => {
|
||||
scope: ['openid', 'profile', 'email'],
|
||||
}
|
||||
|
||||
console.log('OAuth Authentik - Iniciando flujo:', {
|
||||
serverUrl: config.serverUrl,
|
||||
serverUrlInternal: config.serverUrlInternal,
|
||||
redirectURL: config.redirectURL,
|
||||
hasCode: !!query.code
|
||||
})
|
||||
|
||||
// Handle OAuth callback
|
||||
if (query.code) {
|
||||
try {
|
||||
@@ -70,7 +60,6 @@ export default defineEventHandler(async (event) => {
|
||||
loggedInAt: Date.now()
|
||||
})
|
||||
|
||||
// Redirigir al dashboard después del login
|
||||
return sendRedirect(event, '/')
|
||||
} catch (error: any) {
|
||||
console.error('Authentik OAuth error:', error)
|
||||
@@ -89,6 +78,5 @@ export default defineEventHandler(async (event) => {
|
||||
}
|
||||
)
|
||||
|
||||
console.log('Redirecting to:', authorizationUrl)
|
||||
return sendRedirect(event, authorizationUrl)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user