refactor(arch): decouple private imports, enforce contracts and comply with cordis architecture

This commit is contained in:
ryan
2026-09-03 10:40:02 +08:00
parent dbcf485d8a
commit 953a224245
107 changed files with 2028 additions and 1263 deletions
@@ -23,31 +23,51 @@ func passThrough() gin.HandlerFunc {
return func(c *gin.Context) { c.Next() }
}
func (s StubAuth) RequireAuthMiddleware() any { return passThrough() }
// RequireAuthMiddleware returns a passthrough middleware.
func (s StubAuth) RequireAuthMiddleware() any { return passThrough() }
// RequireAdminMiddleware returns a passthrough middleware.
func (s StubAuth) RequireAdminMiddleware() any { return passThrough() }
// DisallowTokenAuthMiddleware returns a passthrough middleware.
func (s StubAuth) DisallowTokenAuthMiddleware() any {
return passThrough()
}
// GetCurrentUser returns the stub user.
func (s StubAuth) GetCurrentUser(context.Context) (*contracts.UserDTO, error) {
return s.User, nil
}
// GetCurrentUserID returns the stub user ID.
func (s StubAuth) GetCurrentUserID(context.Context) (uint64, error) {
if s.User == nil {
return 0, nil
}
return s.User.ID, nil
}
// VerifyToken returns the stub user.
func (s StubAuth) VerifyToken(context.Context, string) (*contracts.UserDTO, error) {
return s.User, nil
}
// CreateSession creates a stub session.
func (s StubAuth) CreateSession(context.Context, uint64, map[string]any) (string, error) {
return "", nil
}
func (s StubAuth) RevokeToken(context.Context, string) error { return nil }
// RevokeToken revokes a stub token.
func (s StubAuth) RevokeToken(context.Context, string) error { return nil }
// RevokeUserSessions revokes stub user sessions.
func (s StubAuth) RevokeUserSessions(context.Context, uint64) error { return nil }
func (s StubAuth) InvalidateCachedUser(context.Context, uint64) {}
func (s StubAuth) InvalidateCachedToken(context.Context, string) {}
// InvalidateCachedUser invalidates stub cached user.
func (s StubAuth) InvalidateCachedUser(context.Context, uint64) {}
// InvalidateCachedToken invalidates stub cached token.
func (s StubAuth) InvalidateCachedToken(context.Context, string) {}
func (s StubAuth) ListAuthSources(context.Context) ([]contracts.AuthSourceViewDTO, error) {
return s.Sources, nil
}