diff --git a/api/swagger/docs.go b/api/swagger/docs.go index 94a83f5f..a53db363 100644 --- a/api/swagger/docs.go +++ b/api/swagger/docs.go @@ -3380,10 +3380,6 @@ const docTemplate = `{ "description": "URL of built image for app", "type": "string" }, - "note": { - "description": "additional note", - "type": "string" - }, "output": { "description": "output for task result", "type": "string" @@ -3415,6 +3411,10 @@ const docTemplate = `{ "description": "resource spec of app pod", "type": "string" }, + "rollbackVersion": { + "description": "rollback target version", + "type": "string" + }, "status": { "description": "status is app status", "type": "string" diff --git a/api/swagger/swagger.json b/api/swagger/swagger.json index 0b07b15a..da6b24fb 100644 --- a/api/swagger/swagger.json +++ b/api/swagger/swagger.json @@ -3373,10 +3373,6 @@ "description": "URL of built image for app", "type": "string" }, - "note": { - "description": "additional note", - "type": "string" - }, "output": { "description": "output for task result", "type": "string" @@ -3408,6 +3404,10 @@ "description": "resource spec of app pod", "type": "string" }, + "rollbackVersion": { + "description": "rollback target version", + "type": "string" + }, "status": { "description": "status is app status", "type": "string" diff --git a/api/swagger/swagger.yaml b/api/swagger/swagger.yaml index 9dd4d676..833915c1 100644 --- a/api/swagger/swagger.yaml +++ b/api/swagger/swagger.yaml @@ -185,9 +185,6 @@ definitions: imageUrl: description: URL of built image for app type: string - note: - description: additional note - type: string output: description: output for task result type: string @@ -210,6 +207,9 @@ definitions: resourceSpec: description: resource spec of app pod type: string + rollbackVersion: + description: rollback target version + type: string status: description: status is app status type: string diff --git a/internal/usecase/auth.go b/internal/usecase/auth.go index e20ade7f..f86929b1 100644 --- a/internal/usecase/auth.go +++ b/internal/usecase/auth.go @@ -8,6 +8,7 @@ import ( "net/http" "net/url" "strings" + "time" "github.com/openinfradev/tks-api/pkg/log" "github.com/spf13/viper" @@ -49,52 +50,6 @@ type AuthUsecase struct { appgroupRepository repository.IAppGroupRepository } -func (u *AuthUsecase) SingleSignOut(organizationId string) (map[string][]string, []*http.Cookie, error) { - urls := make(map[string][]string) - - clusters, err := u.clusterRepository.FetchByOrganizationId(organizationId) - log.Info("clusters", clusters) - if err != nil { - return nil, nil, err - } - if len(clusters) == 0 { - return nil, nil, nil - } - for _, cluster := range clusters { - appgroups, err := u.appgroupRepository.Fetch(cluster.ID) - log.Info("appgroups", appgroups) - if err != nil { - return nil, nil, err - } - if len(appgroups) == 0 { - continue - } - for _, appgroup := range appgroups { - for _, appType := range []domain.ApplicationType{domain.ApplicationType_GRAFANA, domain.ApplicationType_KIALI} { - apps, err := u.appgroupRepository.GetApplications(appgroup.ID, appType) - if err != nil { - return nil, nil, err - } - if urls[strings.ToLower(appType.String())] == nil { - urls[strings.ToLower(appType.String())] = []string{} - } - for _, app := range apps { - urls[strings.ToLower(appType.String())] = append(urls[strings.ToLower(appType.String())], app.Endpoint+"/logout") - } - } - } - } - - cookies := []*http.Cookie{ - { - Name: KEYCLOAK_IDENTITY_COOKIE, - MaxAge: -1, - }, - } - - return urls, cookies, nil -} - func NewAuthUsecase(r repository.Repository, kc keycloak.IKeycloak) IAuthUsecase { return &AuthUsecase{ kc: kc, @@ -300,6 +255,57 @@ func (u *AuthUsecase) SingleSignIn(organizationId, accountId, password string) ( return cookies, nil } +func (u *AuthUsecase) SingleSignOut(organizationId string) (map[string][]string, []*http.Cookie, error) { + urls := make(map[string][]string) + + clusters, err := u.clusterRepository.FetchByOrganizationId(organizationId) + log.Info("clusters", clusters) + if err != nil { + return nil, nil, err + } + if len(clusters) == 0 { + return nil, nil, nil + } + for _, cluster := range clusters { + appgroups, err := u.appgroupRepository.Fetch(cluster.ID) + log.Info("appgroups", appgroups) + if err != nil { + return nil, nil, err + } + if len(appgroups) == 0 { + continue + } + for _, appgroup := range appgroups { + for _, appType := range []domain.ApplicationType{domain.ApplicationType_GRAFANA, domain.ApplicationType_KIALI} { + apps, err := u.appgroupRepository.GetApplications(appgroup.ID, appType) + if err != nil { + return nil, nil, err + } + if urls[strings.ToLower(appType.String())] == nil { + urls[strings.ToLower(appType.String())] = []string{} + } + for _, app := range apps { + urls[strings.ToLower(appType.String())] = append(urls[strings.ToLower(appType.String())], app.Endpoint+"/logout") + } + } + } + } + + cookies := []*http.Cookie{ + { + Name: KEYCLOAK_IDENTITY_COOKIE, + MaxAge: -1, + Expires: time.Now().AddDate(0, 0, -1), + Path: "/auth/realms/" + organizationId, + HttpOnly: true, + Secure: true, + SameSite: http.SameSiteNoneMode, + }, + } + + return urls, cookies, nil +} + func (u *AuthUsecase) isExpiredEmailCode(code repository.CacheEmailCode) bool { return !helper.IsDurationExpired(code.UpdatedAt, internal.EmailCodeExpireTime) }