fix: secure admin endpoints with authentication middleware (issue #4)

- Add config parameter to AuthService constructor
- Implement proper config-based auth checks in middleware
- Wrap all admin endpoints (users, groups, tokens) with authentication
- Apply granular scopes: admin:users:*, admin:groups:*, admin:tokens:*
- Maintain backward compatibility when config is nil

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-09-21 12:15:38 +03:00
parent 3aff0ab5ef
commit e6d87d025f
4 changed files with 45 additions and 18 deletions

View File

@@ -118,7 +118,7 @@ func NewServer(config *types.Config) (*Server, error) {
server.revisionService = storage.NewRevisionService(storageService)
// Initialize authentication service
server.authService = auth.NewAuthService(db, logger)
server.authService = auth.NewAuthService(db, logger, config)
// Setup initial root account if needed (Issue #3)
if config.AuthEnabled {