Add modular group verification system with frontend and backend checks
All checks were successful
build-and-deploy / build (push) Successful in 54s
build-and-deploy / deploy (push) Successful in 4s

This commit implements a comprehensive, reusable group verification system:

Components:
- GroupCheckButton: Base component for group verification
- 7 specialized buttons: 3 real groups (authentik Admins, grupo-prueba, lvl0), 1 public access test, 2 system verification buttons
- All buttons support both frontend and backend verification modes

Backend:
- New API endpoint /api/auth/check-group for server-side group validation
- Reads Authentik headers and validates group membership

Frontend:
- Enhanced useAuthentik composable with hasGroup() and checkGroupBackend() methods
- Toast notifications for all verification results
- Smooth animations and color-coded visual feedback

UI Improvements:
- Organized layout with cards for different verification types
- Grid layout for group buttons
- Professional styling with hover effects and shadows
- Clear visual distinction between frontend/backend checks
This commit is contained in:
2025-10-13 04:09:42 -06:00
parent f52f9f393f
commit 43bcf4a647
10 changed files with 451 additions and 1 deletions

View File

@@ -182,11 +182,39 @@ export const useAuthentik = () => {
}
}
/**
* Verifica si el usuario pertenece a un grupo específico (frontend)
* Lee los grupos desde el estado local (headers de Authentik)
*/
const hasGroup = (groupName: string): boolean => {
if (!user.value) return false
return user.value.groups.includes(groupName)
}
/**
* Verifica si el usuario pertenece a un grupo específico (backend)
* Consulta al servidor para validar contra Authentik
*/
const checkGroupBackend = async (groupName: string): Promise<boolean> => {
try {
const response = await $fetch<{ hasGroup: boolean }>(`/api/auth/check-group`, {
method: 'POST',
body: { groupName }
})
return response.hasGroup
} catch (error) {
console.error('Error checking group membership:', error)
return false
}
}
return {
user,
isAuthenticated,
logout,
goToProfile,
checkSessionStatus
checkSessionStatus,
hasGroup,
checkGroupBackend
}
}