forked from baron/baron-sso
conent 이력 조회 soft delete 및 상태 필드 추가
This commit is contained in:
@@ -93,15 +93,17 @@ type clientEndpoints struct {
|
||||
}
|
||||
|
||||
type consentSummary struct {
|
||||
Subject string `json:"subject"`
|
||||
UserName string `json:"userName,omitempty"`
|
||||
ClientID string `json:"clientId"`
|
||||
ClientName string `json:"clientName,omitempty"`
|
||||
GrantedScopes []string `json:"grantedScopes"`
|
||||
AuthenticatedAt string `json:"authenticatedAt,omitempty"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
TenantID string `json:"tenantId,omitempty"`
|
||||
TenantName string `json:"tenantName,omitempty"`
|
||||
Subject string `json:"subject"`
|
||||
UserName string `json:"userName,omitempty"`
|
||||
ClientID string `json:"clientId"`
|
||||
ClientName string `json:"clientName,omitempty"`
|
||||
GrantedScopes []string `json:"grantedScopes"`
|
||||
AuthenticatedAt string `json:"authenticatedAt,omitempty"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
DeletedAt *time.Time `json:"deletedAt,omitempty"`
|
||||
Status string `json:"status"`
|
||||
TenantID string `json:"tenantId,omitempty"`
|
||||
TenantName string `json:"tenantName,omitempty"`
|
||||
}
|
||||
|
||||
type consentListResponse struct {
|
||||
@@ -648,6 +650,7 @@ func (h *DevHandler) ListConsents(c *fiber.Ctx) error {
|
||||
|
||||
// [Isolation] Get admin tenant ID from header or locals
|
||||
adminTenantID := c.Get("X-Tenant-ID") // Assume middleware sets this or trusted in dev
|
||||
statusFilter := strings.ToLower(strings.TrimSpace(c.Query("status")))
|
||||
|
||||
var consents []domain.ClientConsentWithTenantInfo
|
||||
var total int64
|
||||
@@ -686,6 +689,23 @@ func (h *DevHandler) ListConsents(c *fiber.Ctx) error {
|
||||
continue
|
||||
}
|
||||
|
||||
var deletedAt *time.Time
|
||||
status := "active"
|
||||
if consent.DeletedAt.Valid {
|
||||
deletedAt = &consent.DeletedAt.Time
|
||||
status = "revoked"
|
||||
}
|
||||
|
||||
// Filter by status if requested
|
||||
if statusFilter != "" && statusFilter != "all" {
|
||||
if statusFilter == "active" && status != "active" {
|
||||
continue
|
||||
}
|
||||
if statusFilter == "revoked" && status != "revoked" {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
userName := ""
|
||||
identity, err := h.KratosAdmin.GetIdentity(c.Context(), consent.Subject)
|
||||
if err == nil && identity != nil {
|
||||
@@ -703,6 +723,8 @@ func (h *DevHandler) ListConsents(c *fiber.Ctx) error {
|
||||
GrantedScopes: consent.GrantedScopes,
|
||||
AuthenticatedAt: consent.UpdatedAt.Format(time.RFC3339),
|
||||
CreatedAt: consent.CreatedAt,
|
||||
DeletedAt: deletedAt,
|
||||
Status: status,
|
||||
TenantID: consent.TenantID,
|
||||
TenantName: consent.TenantName,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user