Add internal authentication configuration and middleware support
- Enable internal authentication via environment variable in .env.example - Update nuxt.config.ts to include internalAuthEnabled check - Modify internal-auth middleware to conditionally enforce authentication based on the new configuration
This commit is contained in:
@@ -13,13 +13,20 @@ export default defineEventHandler((event) => {
|
||||
|
||||
const config = useRuntimeConfig()
|
||||
|
||||
// Skip auth if internal auth is not enabled
|
||||
if (!config.internalAuthEnabled) {
|
||||
return
|
||||
}
|
||||
|
||||
// Get credentials from environment variables
|
||||
const validUsername = config.internalAuthUsername
|
||||
const validPassword = config.internalAuthPassword
|
||||
|
||||
// Skip auth if credentials are not configured (development convenience)
|
||||
if (!validUsername || !validPassword) {
|
||||
console.warn('⚠️ INTERNAL_AUTH_USERNAME or INTERNAL_AUTH_PASSWORD not set. /internal routes are unprotected!')
|
||||
console.warn(
|
||||
'⚠️ INTERNAL_AUTH_USERNAME or INTERNAL_AUTH_PASSWORD not set. /internal routes are unprotected!'
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user