refactor: extract authentication system to auth package

- Create auth/jwt.go with JWT token management
- Create auth/permissions.go with permission checking logic
- Create auth/storage.go with storage key utilities
- Create auth/auth.go with main authentication service
- Create auth/middleware.go with auth and rate limit middleware
- Update main.go to import auth package and use auth.* functions
- Add authService to Server struct

Major auth functionality now separated into dedicated package.
Build tested and verified working.

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-09-18 18:49:27 +03:00
parent 83777fe5a2
commit c273b836be
6 changed files with 535 additions and 34 deletions

19
auth/storage.go Normal file
View File

@@ -0,0 +1,19 @@
package auth
// Storage key generation utilities for authentication data
func UserStorageKey(userUUID string) string {
return "user:" + userUUID
}
func GroupStorageKey(groupUUID string) string {
return "group:" + groupUUID
}
func TokenStorageKey(tokenHash string) string {
return "token:" + tokenHash
}
func ResourceMetadataKey(resourceKey string) string {
return resourceKey + ":metadata"
}