Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0ad3e3dead | ||
|
|
aebc53174b | ||
|
|
88e5ffedad | ||
|
|
71a841fee0 | ||
|
|
3029e084ce | ||
|
|
14bd29e48f | ||
|
|
32466576b0 | ||
|
|
121f63f57a | ||
|
|
7c9e12685d | ||
|
|
2b167919b1 | ||
|
|
f10153a53b | ||
|
|
83b10f368c | ||
|
|
8789f8a5ec | ||
|
|
3bbe1c3952 | ||
|
|
e1de1c31d8 |
No files matched your search
@@ -0,0 +1,60 @@
|
|||||||
|
name: Create and publish a Docker image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY: ghcr.io
|
||||||
|
IMAGE_NAME: ${{ github.repository }}
|
||||||
|
APP_NAME: ${{ github.event.repository.name }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-push-image:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
attestations: write
|
||||||
|
id-token: write
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Get version from tag
|
||||||
|
id: version_reader
|
||||||
|
run: |
|
||||||
|
VERSION=${GITHUB_REF_NAME#v}
|
||||||
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
with:
|
||||||
|
driver: docker-container
|
||||||
|
- name: Log in to the Container registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ${{ env.REGISTRY }}
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
- name: Build and push Docker image
|
||||||
|
id: push
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
push: true
|
||||||
|
tags: |
|
||||||
|
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version_reader.outputs.version }}
|
||||||
|
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
||||||
|
labels: |
|
||||||
|
org.opencontainers.image.title=${{ env.IMAGE_NAME }}
|
||||||
|
org.opencontainers.image.version=${{ steps.version_reader.outputs.version }}
|
||||||
|
build-args: |
|
||||||
|
app_name=${{ env.APP_NAME }}
|
||||||
|
version=${{ steps.version_reader.outputs.version }}
|
||||||
|
- name: Generate artifact attestation
|
||||||
|
uses: actions/attest-build-provenance@v2
|
||||||
|
with:
|
||||||
|
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
|
||||||
|
subject-digest: ${{ steps.push.outputs.digest }}
|
||||||
|
push-to-registry: true
|
||||||
+3
-23
@@ -1,23 +1,3 @@
|
|||||||
docker-build:
|
include:
|
||||||
image: docker:latest
|
- project: '$CI_PROJECT_PATH'
|
||||||
stage: build
|
file: '/ci-isp-go-service.yml'
|
||||||
services:
|
|
||||||
- docker:dind
|
|
||||||
before_script:
|
|
||||||
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
|
|
||||||
- export VERSION=`cat .version `
|
|
||||||
- echo $VERSION
|
|
||||||
- echo $CI_DOCKER_FILE
|
|
||||||
- echo $CI_REGISTRY
|
|
||||||
script:
|
|
||||||
- set
|
|
||||||
- mkdir -p migrations
|
|
||||||
- docker build -f "$CI_DOCKER_FILE" --force-rm --build-arg="version=$VERSION" --build-arg="app_name=$CI_PROJECT_NAME" --pull -t "$CI_REGISTRY/$CI_PROJECT_NAME:$VERSION" .
|
|
||||||
- |
|
|
||||||
docker tag "$CI_REGISTRY/$CI_PROJECT_NAME:$VERSION" "$CI_REGISTRY/$CI_PROJECT_NAME:latest"
|
|
||||||
docker push "$CI_REGISTRY/$CI_PROJECT_NAME:$VERSION"
|
|
||||||
docker push "$CI_REGISTRY/$CI_PROJECT_NAME:latest"
|
|
||||||
docker rmi -f "$CI_REGISTRY/$CI_PROJECT_NAME:$VERSION"
|
|
||||||
docker rmi -f "$CI_REGISTRY/$CI_PROJECT_NAME:latest"
|
|
||||||
- docker logout $CI_REGISTRY
|
|
||||||
|
|
||||||
+64
-51
@@ -1,56 +1,69 @@
|
|||||||
|
version: "2"
|
||||||
run:
|
run:
|
||||||
allow-parallel-runners: true
|
allow-parallel-runners: true
|
||||||
issues:
|
|
||||||
exclude-rules:
|
|
||||||
- path: controller #достаточное кол-во контекса на уровне контроллеров
|
|
||||||
linters:
|
|
||||||
- wrapcheck
|
|
||||||
- path: transaction #транзакции прозрачны
|
|
||||||
linters:
|
|
||||||
- wrapcheck
|
|
||||||
linters:
|
linters:
|
||||||
enable-all: true
|
default: all
|
||||||
disable:
|
disable:
|
||||||
- goimports #у нас собственные правила форматирования импортов
|
- contextcheck # не имеет смысла
|
||||||
- wsl #расставление пробелов очень индивидуально
|
- depguard # не всегда имеет смысл
|
||||||
- exhaustivestruct #не имеет смысла
|
- dupword # не имеет смысла
|
||||||
- varnamelen #очень индивидуально (db)
|
- exhaustruct # не имеет смысла
|
||||||
- exhaustruct #не имеет смысла
|
- godot # не актуально для swagger
|
||||||
- golint #устарел
|
- godox # не позволяет оставлять todo
|
||||||
- contextcheck #не имеет смысла
|
- musttag # у нас собственное правило: не используем теги, если работаем с пакетом isp-kit/json и с внутренними структурами(между нашими сервисами), при этом теги обязательный для всех внешних для нас структур
|
||||||
- gci #у нас собственные правила форматирования импортов
|
- nlreturn # не всегда имеет смысл
|
||||||
- gofumpt #у нас собственные правила форматирования импортов
|
- nolintlint # Goland все равно форматирует с отступом
|
||||||
- nolintlint #Goland все равно форматирует с отступом
|
- perfsprint # мнимая производительность в угоду читаемости
|
||||||
- nlreturn #не всегда имеет смысл
|
- tagalign # не всегда имеет смысл
|
||||||
- godot #не актуально для свагера
|
- varnamelen # очень индивидуально (db)
|
||||||
- ifshort #приняли решение, что мы так не пишем if err := ...; err != nil {}
|
- wsl # расставление пробелов очень индивидуально
|
||||||
- godox #не позволяет оставлять todo
|
- wsl_v5 # расставление пробелов очень индивидуально
|
||||||
- maligned #аллокацией памяти для структур конфликтует с удобством их чтения
|
settings:
|
||||||
- nosnakecase #не позволяет заводить пакеты используя snake_case
|
cyclop:
|
||||||
- depguard #не всегда имеет смысл
|
max-complexity: 15 # по умолчанию 10 мало
|
||||||
- dupword #не имеет смысла
|
funlen:
|
||||||
- tagalign #не всегда имеет смысл
|
lines: 80
|
||||||
- musttag #у нас собственные правило: не используем теги, если работаем с пакетом isp-kit/json и с внутренними структурами(между нашими сервисами), при этом теги обязательный для всех внених для нас структур
|
lll:
|
||||||
- perfsprint #мнимая производительность в угоду читаемости
|
line-length: 150
|
||||||
- gomnd
|
revive:
|
||||||
linters-settings:
|
rules:
|
||||||
funlen:
|
- name: var-naming # отключаем Id -> ID
|
||||||
lines: 80
|
disabled: true
|
||||||
lll:
|
staticcheck:
|
||||||
line-length: 150
|
checks: # отключаем Id -> ID
|
||||||
cyclop:
|
- -ST1000
|
||||||
max-complexity: 15 #по умолчанию 10 мало
|
- -ST1016
|
||||||
revive:
|
- -ST1020
|
||||||
|
- -ST1021
|
||||||
|
- -ST1022
|
||||||
|
testifylint:
|
||||||
|
disable:
|
||||||
|
- compares
|
||||||
|
- equal-values
|
||||||
|
exclusions:
|
||||||
|
generated: lax
|
||||||
|
presets:
|
||||||
|
- comments
|
||||||
|
- common-false-positives
|
||||||
|
- legacy
|
||||||
|
- std-error-handling
|
||||||
rules:
|
rules:
|
||||||
- name: var-naming #отключаем Id -> ID
|
- linters:
|
||||||
disabled: true
|
- wrapcheck
|
||||||
stylecheck:
|
path: controller # достаточное кол-во контекста на уровне контроллеров
|
||||||
checks: #отключаем Id -> ID
|
- linters:
|
||||||
- "-ST1000"
|
- wrapcheck
|
||||||
- "-ST1016"
|
path: transaction # транзакции прозрачны
|
||||||
- "-ST1020"
|
paths:
|
||||||
- "-ST1021"
|
- third_party$
|
||||||
- "-ST1022"
|
- builtin$
|
||||||
testifylint:
|
- examples$
|
||||||
disable:
|
formatters:
|
||||||
- compares
|
enable:
|
||||||
|
- gofmt
|
||||||
|
exclusions:
|
||||||
|
generated: lax
|
||||||
|
paths:
|
||||||
|
- third_party$
|
||||||
|
- builtin$
|
||||||
|
- examples$
|
||||||
@@ -1,3 +1,38 @@
|
|||||||
|
### v6.7.0
|
||||||
|
* Обновлены методы `admin/log/all`, `admin/session/all` и `admin/user/get_users`: добавлена сортировка и поиск
|
||||||
|
* Добавлен воркер выставления статуса 'EXPIRED' для токенов сессий
|
||||||
|
* Добавлено поле `fullName` пользователя, содержащее полное ФИО, получаемое от sudir
|
||||||
|
* Обновлены зависимости
|
||||||
|
### v6.6.1
|
||||||
|
* Добавлено поле `roleNames` в метод `admin/user/get_profile`
|
||||||
|
### v6.6.0
|
||||||
|
* Добавлено отдельное событие 'user_blocked' для блокировки/разблокировки пользователей
|
||||||
|
* Обновлены зависимости
|
||||||
|
### v6.5.0
|
||||||
|
* Изменена уникальность учетных записей с "email" на связку "email + sudir_id"
|
||||||
|
* Добавлен метод `admin/auth/logout_with_reason` для вывода логов `Выхода по бездействию` в журнал ИБ
|
||||||
|
### v6.4.0
|
||||||
|
* Обновлены зависимости
|
||||||
|
### v6.3.1
|
||||||
|
* Корневой путь до методов СУДИР перенесён в конфигурацию
|
||||||
|
* Ранее: В конфигурации `https://sudir-domain/` + фиксированно в коде `/blitz/oauth/*`
|
||||||
|
* Сейчас: В конфигурации `https://sudir-domain/<указать, что необходимо>` + фиксированно в коде `/oauth/*`
|
||||||
|
### v6.3.0
|
||||||
|
* убрана интеграция с LDAP
|
||||||
|
* исправлен сброс разблокировки и назначения ролей на пользователя
|
||||||
|
### v6.2.6
|
||||||
|
* добавлен `Dockerfile` и скрипт для сборки и публикации образа в `GitHub Contaier Registry`
|
||||||
|
* обновлены зависимости
|
||||||
|
### v6.2.5
|
||||||
|
* исправлена паника при отсутствии ролей у пользователя
|
||||||
|
* обновлены зависимости
|
||||||
|
### v6.2.4
|
||||||
|
* обновлены зависимости
|
||||||
|
### v6.2.3
|
||||||
|
* обновлены зависимости
|
||||||
|
* добавлены новые разрешения для ролей по умолчанию
|
||||||
|
### v6.2.2
|
||||||
|
* обновлены зависимости
|
||||||
### v6.2.0
|
### v6.2.0
|
||||||
* обновлены зависимости
|
* обновлены зависимости
|
||||||
* добавлено недостающее разрешение `user_view`
|
* добавлено недостающее разрешение `user_view`
|
||||||
|
|||||||
+47
@@ -0,0 +1,47 @@
|
|||||||
|
FROM golang:1.25-alpine as builder
|
||||||
|
WORKDIR /build
|
||||||
|
ARG version
|
||||||
|
ENV version_env=$version
|
||||||
|
ARG app_name
|
||||||
|
ENV app_name_env=$app_name
|
||||||
|
COPY . .
|
||||||
|
RUN --mount=type=cache,target=/go/pkg/mod/ \
|
||||||
|
--mount=type=bind,source=go.sum,target=go.sum \
|
||||||
|
--mount=type=bind,source=go.mod,target=go.mod \
|
||||||
|
go mod download -x
|
||||||
|
RUN --mount=type=cache,target=/go/pkg/mod/ \
|
||||||
|
--mount=type=bind,target=. \
|
||||||
|
go build -ldflags="-X 'main.version=$version_env'" -o /main .
|
||||||
|
|
||||||
|
FROM alpine:3.23
|
||||||
|
|
||||||
|
RUN apk add --no-cache tzdata
|
||||||
|
RUN cp /usr/share/zoneinfo/Europe/Moscow /etc/localtime
|
||||||
|
RUN echo "Europe/Moscow" > /etc/timezone
|
||||||
|
|
||||||
|
ARG UID=10001
|
||||||
|
RUN adduser \
|
||||||
|
--disabled-password \
|
||||||
|
--gecos "" \
|
||||||
|
--home "/nonexistent" \
|
||||||
|
--shell "/sbin/nologin" \
|
||||||
|
--no-create-home \
|
||||||
|
--uid "${UID}" \
|
||||||
|
appuser
|
||||||
|
|
||||||
|
RUN mkdir -p /app/data
|
||||||
|
RUN chown appuser:appuser /app/data
|
||||||
|
VOLUME /app/data
|
||||||
|
|
||||||
|
USER appuser
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
ARG app_name
|
||||||
|
ENV app_name_env=$app_name
|
||||||
|
COPY --from=builder main /app/$app_name_env
|
||||||
|
COPY /conf/config.yml /app/config.yml
|
||||||
|
COPY /conf/default_remote_config.json* /app/default_remote_config.json
|
||||||
|
COPY /migrations /app/migrations
|
||||||
|
|
||||||
|
ENTRYPOINT /app/$app_name_env
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
FROM dockerhub.mos.ru/mosos/arbat:15.5 as builder
|
FROM dockerhub.mos.ru/mosos/arbat:15.5 as builder
|
||||||
RUN zypper --no-gpg-checks update -y && zypper --no-gpg-checks install -y go1.23 git
|
RUN zypper --no-gpg-checks update -y && zypper --no-gpg-checks install -y go1.24 git
|
||||||
WORKDIR /build
|
WORKDIR /build
|
||||||
ARG version
|
ARG version
|
||||||
ENV version_env=$version
|
ENV version_env=$version
|
||||||
|
|||||||
+16
-16
@@ -2,6 +2,12 @@ package assembly
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"msp-admin-service/conf"
|
||||||
|
"msp-admin-service/service/delete_old_audit_worker"
|
||||||
|
"msp-admin-service/service/inactive_worker"
|
||||||
|
"msp-admin-service/service/session_worker"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/txix-open/isp-kit/app"
|
"github.com/txix-open/isp-kit/app"
|
||||||
@@ -14,11 +20,6 @@ import (
|
|||||||
"github.com/txix-open/isp-kit/http/httpcli"
|
"github.com/txix-open/isp-kit/http/httpcli"
|
||||||
"github.com/txix-open/isp-kit/http/httpclix"
|
"github.com/txix-open/isp-kit/http/httpclix"
|
||||||
"github.com/txix-open/isp-kit/log"
|
"github.com/txix-open/isp-kit/log"
|
||||||
"msp-admin-service/conf"
|
|
||||||
ldapRepo "msp-admin-service/repository/ldap"
|
|
||||||
"msp-admin-service/service/delete_old_audit_worker"
|
|
||||||
"msp-admin-service/service/inactive_worker"
|
|
||||||
"msp-admin-service/service/ldap"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Assembly struct {
|
type Assembly struct {
|
||||||
@@ -31,15 +32,16 @@ type Assembly struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func New(boot *bootstrap.Bootstrap) (*Assembly, error) {
|
func New(boot *bootstrap.Bootstrap) (*Assembly, error) {
|
||||||
|
logger := boot.App.Logger()
|
||||||
server := grpc.NewServer()
|
server := grpc.NewServer()
|
||||||
httpCli := httpclix.Default(httpcli.WithMiddlewares(httpclix.Log(boot.App.Logger())))
|
httpCli := httpclix.Default(httpcli.WithMiddlewares(httpclix.Log(logger)))
|
||||||
db := dbrx.New(dbx.WithMigrationRunner(boot.MigrationsDir, boot.App.Logger()))
|
db := dbrx.New(logger, dbx.WithMigrationRunner(boot.MigrationsDir, logger))
|
||||||
bgjobCli := bgjobx.NewClient(db, boot.App.Logger())
|
bgjobCli := bgjobx.NewClient(db, logger)
|
||||||
return &Assembly{
|
return &Assembly{
|
||||||
boot: boot,
|
boot: boot,
|
||||||
db: db,
|
db: db,
|
||||||
server: server,
|
server: server,
|
||||||
logger: boot.App.Logger(),
|
logger: logger,
|
||||||
httpCli: httpCli,
|
httpCli: httpCli,
|
||||||
bgjobCli: bgjobCli,
|
bgjobCli: bgjobCli,
|
||||||
}, nil
|
}, nil
|
||||||
@@ -63,13 +65,7 @@ func (a *Assembly) ReceiveConfig(ctx context.Context, remoteConfig []byte) error
|
|||||||
}
|
}
|
||||||
|
|
||||||
locator := NewLocator(a.logger, a.httpCli, a.db)
|
locator := NewLocator(a.logger, a.httpCli, a.db)
|
||||||
config := locator.Config(ctx, func(config *conf.Ldap) (ldap.Repo, error) {
|
config := locator.Config(ctx, newCfg, time.Minute)
|
||||||
repo, err := ldapRepo.NewRepository(config)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.WithMessage(err, "new repository")
|
|
||||||
}
|
|
||||||
return repo, nil
|
|
||||||
}, newCfg)
|
|
||||||
|
|
||||||
a.server.Upgrade(config.Handler)
|
a.server.Upgrade(config.Handler)
|
||||||
|
|
||||||
@@ -86,6 +82,10 @@ func (a *Assembly) ReceiveConfig(ctx context.Context, remoteConfig []byte) error
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
a.logger.Fatal(ctx, errors.WithMessage(err, "seed inactive user worker"))
|
a.logger.Fatal(ctx, errors.WithMessage(err, "seed inactive user worker"))
|
||||||
}
|
}
|
||||||
|
err = session_worker.EnqueueSeedJob(ctx, a.bgjobCli)
|
||||||
|
if err != nil {
|
||||||
|
a.logger.Fatal(ctx, errors.WithMessage(err, "seed expire session worker"))
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
+20
-18
@@ -4,12 +4,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/txix-open/isp-kit/bgjobx"
|
|
||||||
"github.com/txix-open/isp-kit/db"
|
|
||||||
"github.com/txix-open/isp-kit/grpc/endpoint"
|
|
||||||
"github.com/txix-open/isp-kit/grpc/isp"
|
|
||||||
"github.com/txix-open/isp-kit/http/httpcli"
|
|
||||||
"github.com/txix-open/isp-kit/log"
|
|
||||||
"msp-admin-service/conf"
|
"msp-admin-service/conf"
|
||||||
"msp-admin-service/controller"
|
"msp-admin-service/controller"
|
||||||
"msp-admin-service/repository"
|
"msp-admin-service/repository"
|
||||||
@@ -17,13 +11,16 @@ import (
|
|||||||
"msp-admin-service/service"
|
"msp-admin-service/service"
|
||||||
"msp-admin-service/service/delete_old_audit_worker"
|
"msp-admin-service/service/delete_old_audit_worker"
|
||||||
"msp-admin-service/service/inactive_worker"
|
"msp-admin-service/service/inactive_worker"
|
||||||
"msp-admin-service/service/ldap"
|
|
||||||
"msp-admin-service/service/secure"
|
"msp-admin-service/service/secure"
|
||||||
|
"msp-admin-service/service/session_worker"
|
||||||
"msp-admin-service/transaction"
|
"msp-admin-service/transaction"
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
"github.com/txix-open/isp-kit/bgjobx"
|
||||||
JobPollInterval = 1 * time.Minute //nolint:gochecknoglobals
|
"github.com/txix-open/isp-kit/db"
|
||||||
|
"github.com/txix-open/isp-kit/grpc/endpoint"
|
||||||
|
"github.com/txix-open/isp-kit/grpc/isp"
|
||||||
|
"github.com/txix-open/isp-kit/http/httpcli"
|
||||||
|
"github.com/txix-open/isp-kit/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DB interface {
|
type DB interface {
|
||||||
@@ -51,7 +48,11 @@ type Config struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//nolint:funlen
|
//nolint:funlen
|
||||||
func (l Locator) Config(ctx context.Context, ldapRepoSupplier ldap.RepoSupplier, cfg conf.Remote) Config {
|
func (l Locator) Config(
|
||||||
|
ctx context.Context,
|
||||||
|
cfg conf.Remote,
|
||||||
|
jobPollInterval time.Duration,
|
||||||
|
) Config {
|
||||||
sudirRepo := repository.NewSudir(l.httpCli, cfg.SudirAuth)
|
sudirRepo := repository.NewSudir(l.httpCli, cfg.SudirAuth)
|
||||||
roleRepo := repository.NewRole(l.db)
|
roleRepo := repository.NewRole(l.db)
|
||||||
userRepo := repository.NewUser(l.db)
|
userRepo := repository.NewUser(l.db)
|
||||||
@@ -67,8 +68,6 @@ func (l Locator) Config(ctx context.Context, ldapRepoSupplier ldap.RepoSupplier,
|
|||||||
|
|
||||||
txManager := transaction.NewManager(l.db)
|
txManager := transaction.NewManager(l.db)
|
||||||
|
|
||||||
ldapService := ldap.NewService(cfg.Ldap, ldapRepoSupplier, userRoleRepo, roleRepo, l.logger)
|
|
||||||
|
|
||||||
userService := service.NewUser(
|
userService := service.NewUser(
|
||||||
userRepo,
|
userRepo,
|
||||||
userRoleRepo,
|
userRoleRepo,
|
||||||
@@ -76,7 +75,6 @@ func (l Locator) Config(ctx context.Context, ldapRepoSupplier ldap.RepoSupplier,
|
|||||||
tokenRepo,
|
tokenRepo,
|
||||||
auditService,
|
auditService,
|
||||||
txManager,
|
txManager,
|
||||||
ldapService,
|
|
||||||
tokenService,
|
tokenService,
|
||||||
cfg.IdleTimeoutMs,
|
cfg.IdleTimeoutMs,
|
||||||
l.logger,
|
l.logger,
|
||||||
@@ -114,28 +112,32 @@ func (l Locator) Config(ctx context.Context, ldapRepoSupplier ldap.RepoSupplier,
|
|||||||
)
|
)
|
||||||
|
|
||||||
inactiveBlocker := inactive_worker.NewInactiveBlocker(
|
inactiveBlocker := inactive_worker.NewInactiveBlocker(
|
||||||
tokenRepo,
|
|
||||||
userRepo,
|
userRepo,
|
||||||
auditService,
|
auditService,
|
||||||
userRoleRepo,
|
userRoleRepo,
|
||||||
ldapService,
|
|
||||||
cfg.BlockInactiveWorker,
|
cfg.BlockInactiveWorker,
|
||||||
l.logger,
|
l.logger,
|
||||||
)
|
)
|
||||||
deleteOldAuditWorker := delete_old_audit_worker.NewService(l.logger, auditRepo, cfg.Audit.AuditTTl)
|
deleteOldAuditWorker := delete_old_audit_worker.NewService(l.logger, auditRepo, cfg.Audit.AuditTTl)
|
||||||
|
expireSessionWorker := session_worker.NewExpireSessionWorker(l.logger, txManager)
|
||||||
|
|
||||||
return Config{
|
return Config{
|
||||||
Handler: handler,
|
Handler: handler,
|
||||||
BgJobCfg: []bgjobx.WorkerConfig{{
|
BgJobCfg: []bgjobx.WorkerConfig{{
|
||||||
Queue: delete_old_audit_worker.QueueName,
|
Queue: delete_old_audit_worker.QueueName,
|
||||||
Concurrency: 1,
|
Concurrency: 1,
|
||||||
PollInterval: JobPollInterval,
|
PollInterval: jobPollInterval,
|
||||||
Handle: deleteOldAuditWorker,
|
Handle: deleteOldAuditWorker,
|
||||||
}, {
|
}, {
|
||||||
Queue: inactive_worker.QueueName,
|
Queue: inactive_worker.QueueName,
|
||||||
Concurrency: 1,
|
Concurrency: 1,
|
||||||
PollInterval: JobPollInterval,
|
PollInterval: jobPollInterval,
|
||||||
Handle: inactiveBlocker,
|
Handle: inactiveBlocker,
|
||||||
|
}, {
|
||||||
|
Queue: session_worker.QueueName,
|
||||||
|
Concurrency: 1,
|
||||||
|
PollInterval: jobPollInterval,
|
||||||
|
Handle: expireSessionWorker,
|
||||||
}},
|
}},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+132
-28
@@ -20,6 +20,10 @@
|
|||||||
{
|
{
|
||||||
"event": "user_changed",
|
"event": "user_changed",
|
||||||
"name": "Изменение пользователя"
|
"name": "Изменение пользователя"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"event": "user_blocked",
|
||||||
|
"name": "Изменение статуса блокировки пользователя"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"auditTTl": {
|
"auditTTl": {
|
||||||
@@ -29,64 +33,164 @@
|
|||||||
},
|
},
|
||||||
"permissions": [
|
"permissions": [
|
||||||
{
|
{
|
||||||
"key": "user_view",
|
"name": "Просмотр экрана \"Профиль\"",
|
||||||
"name": "Просмотр списка пользователей"
|
"key": "profile_view"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": "user_block",
|
"name": "Смена пароля",
|
||||||
"name": "Блокировка пользователя"
|
"key": "profile_change_password"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": "user_create",
|
"name": "Просмотр экрана \"Приложения\"",
|
||||||
"name": "Создать пользователя"
|
"key": "application_group_view"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": "user_update",
|
"name": "Добавление новой группы",
|
||||||
"name": "Обновить пользователя"
|
"key": "application_group_add"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": "user_delete",
|
"name": "Редактирование существующей группы",
|
||||||
"name": "Удаление пользователя"
|
"key": "application_group_edit"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": "session_view",
|
"name": "Удаление группы",
|
||||||
"name": "Просмотр списка пользовательских сессий"
|
"key": "application_group_delete"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": "session_revoke",
|
"name": "Добавление нового приложения",
|
||||||
"name": "Отзыв сессии"
|
"key": "application_group_app_add"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": "role_view",
|
"name": "Редактирование существующего приложения",
|
||||||
"name": "Просмотр экрана ролей"
|
"key": "application_group_app_edit"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": "role_add",
|
"name": "Удаление приложения",
|
||||||
"name": "Создание роли"
|
"key": "application_group_app_delete"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": "role_update",
|
"name": "Просмотр раздела \"Токены\"",
|
||||||
"name": "Обновление роли"
|
"key": "application_group_token_view"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": "role_delete",
|
"name": "Выпуск нового токена",
|
||||||
"name": "Удаление роли"
|
"key": "application_group_token_add"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": "security_log_view",
|
"name": "Отзыв токена",
|
||||||
"name": "Просмотр журналов ИБ"
|
"key": "application_group_token_delete"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": "audit_management_view",
|
"name": "Просмотр экрана \"Доступы приложений\"",
|
||||||
"name": "Управление событиями аудита"
|
"key": "app_access_view"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Редактирование доступов приложений",
|
||||||
|
"key": "app_access_edit"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Просмотр экрана \"Переменные\"",
|
||||||
|
"key": "variable_view"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Добавление новой переменной",
|
||||||
|
"key": "variable_add"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Редактирование переменной",
|
||||||
|
"key": "variable_edit"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Удаление переменной",
|
||||||
|
"key": "variable_delete"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Просмотр экрана \"Модули\"",
|
||||||
|
"key": "module_view"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Удаление модуля",
|
||||||
|
"key": "module_delete"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Небезопасное сохранение конфигурации модуля",
|
||||||
|
"key": "module_configuration_save_unsafe"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Активация/деактивация конфигурации",
|
||||||
|
"key": "module_configuration_set_active"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Восстановление версии конфигурации",
|
||||||
|
"key": "module_history_set"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Удаление версии конфигурации",
|
||||||
|
"key": "module_history_delete_version"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Редактирование конфигураций модуля",
|
||||||
|
"key": "module_configuration_edit"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Создание новой конфигурации",
|
||||||
|
"key": "module_configuration_add"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Просмотр экрана \"Пользователи\"",
|
||||||
|
"key": "user_view"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Блокировка/разблокировка пользователя",
|
||||||
|
"key": "user_block"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Создание пользователя",
|
||||||
|
"key": "user_create"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Обновление пользователя",
|
||||||
|
"key": "user_update"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Удаление пользователя",
|
||||||
|
"key": "user_delete"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Просмотр экрана \"Пользовательские сессии\"",
|
||||||
|
"key": "session_view"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Отзыв сессии",
|
||||||
|
"key": "session_revoke"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Просмотр экрана \"Просмотр журналов ИБ\"",
|
||||||
|
"key": "security_log_view"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Просмотр экрана ролей",
|
||||||
|
"key": "role_view"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Создание роли",
|
||||||
|
"key": "role_add"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Обновление роли",
|
||||||
|
"key": "role_update"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Удаление роли",
|
||||||
|
"key": "role_delete"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": "read",
|
"key": "read",
|
||||||
"name": "Просмотр настроек системы"
|
"name": "Просмотр настроек системы (Устарело)"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": "write",
|
"key": "write",
|
||||||
"name": "Изменение настроек системы"
|
"name": "Изменение настроек системы (Устарело)"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"database": {
|
"database": {
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ type Remote struct {
|
|||||||
AntiBruteforce AntiBruteforce `schema:"Настройки антибрут для admin login"`
|
AntiBruteforce AntiBruteforce `schema:"Настройки антибрут для admin login"`
|
||||||
BlockInactiveWorker BlockInactiveWorker `validate:"required" schema:"Блокировка неактивных УЗ"`
|
BlockInactiveWorker BlockInactiveWorker `validate:"required" schema:"Блокировка неактивных УЗ"`
|
||||||
Permissions []Permission `schema:"Список разрешений"`
|
Permissions []Permission `schema:"Список разрешений"`
|
||||||
Ldap *Ldap `schema:"Настройки LDAP"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Audit struct {
|
type Audit struct {
|
||||||
@@ -73,10 +72,3 @@ type Permission struct {
|
|||||||
Key string
|
Key string
|
||||||
Name string
|
Name string
|
||||||
}
|
}
|
||||||
|
|
||||||
type Ldap struct {
|
|
||||||
Address string `validate:"required" schema:"Адрес LDAP"`
|
|
||||||
Username string `validate:"required" schema:"Пользователь сервисной УЗ"`
|
|
||||||
Password string `validate:"required" schema:"Пароль сервисной УЗ"`
|
|
||||||
BaseDn string `validate:"required"`
|
|
||||||
}
|
|
||||||
+13
-5
@@ -3,14 +3,15 @@ package controller
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
"msp-admin-service/domain"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
"google.golang.org/grpc/status"
|
"google.golang.org/grpc/status"
|
||||||
"msp-admin-service/domain"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type AuditService interface {
|
type AuditService interface {
|
||||||
All(ctx context.Context, limit int, offset int) (*domain.AuditResponse, error)
|
All(ctx context.Context, req domain.AuditPageRequest) (*domain.AuditResponse, error)
|
||||||
Events(ctx context.Context) ([]domain.AuditEvent, error)
|
Events(ctx context.Context) ([]domain.AuditEvent, error)
|
||||||
SetEvents(ctx context.Context, req []domain.SetAuditEvent) error
|
SetEvents(ctx context.Context, req []domain.SetAuditEvent) error
|
||||||
}
|
}
|
||||||
@@ -31,13 +32,20 @@ func NewAudit(service AuditService) Audit {
|
|||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param X-AUTH-ADMIN header string true "Токен администратора"
|
// @Param X-AUTH-ADMIN header string true "Токен администратора"
|
||||||
// @Param body body domain.PageRequest true "Тело запроса"
|
// @Param body body domain.AuditPageRequest true "Тело запроса"
|
||||||
// @Success 200 {object} domain.AuditResponse
|
// @Success 200 {object} domain.AuditResponse
|
||||||
// @Failure 400 {object} domain.GrpcError "Невалидное тело запроса"
|
// @Failure 400 {object} domain.GrpcError "Невалидное тело запроса"
|
||||||
// @Failure 500 {object} domain.GrpcError
|
// @Failure 500 {object} domain.GrpcError
|
||||||
// @Router /log/all [POST]
|
// @Router /log/all [POST]
|
||||||
func (c Audit) All(ctx context.Context, req domain.PageRequest) (*domain.AuditResponse, error) {
|
func (c Audit) All(ctx context.Context, req domain.AuditPageRequest) (*domain.AuditResponse, error) {
|
||||||
return c.service.All(ctx, req.Limit, req.Offset)
|
if req.Order == nil {
|
||||||
|
req.Order = &domain.OrderParams{
|
||||||
|
Field: domain.DefaultOrderField,
|
||||||
|
Type: domain.DefaultOrderType,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.service.All(ctx, req)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Events
|
// Events
|
||||||
|
|||||||
+30
-3
@@ -4,19 +4,20 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"msp-admin-service/domain"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/txix-open/isp-kit/grpc"
|
"github.com/txix-open/isp-kit/grpc"
|
||||||
"github.com/txix-open/isp-kit/log"
|
"github.com/txix-open/isp-kit/log"
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
"google.golang.org/grpc/metadata"
|
"google.golang.org/grpc/metadata"
|
||||||
"google.golang.org/grpc/status"
|
"google.golang.org/grpc/status"
|
||||||
"msp-admin-service/domain"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type authService interface {
|
type authService interface {
|
||||||
Login(ctx context.Context, request domain.LoginRequest) (*domain.LoginResponse, error)
|
Login(ctx context.Context, request domain.LoginRequest) (*domain.LoginResponse, error)
|
||||||
LoginWithSudir(ctx context.Context, request domain.LoginSudirRequest) (*domain.LoginResponse, error)
|
LoginWithSudir(ctx context.Context, request domain.LoginSudirRequest) (*domain.LoginResponse, error)
|
||||||
Logout(ctx context.Context, adminId int64) error
|
Logout(ctx context.Context, adminId int64, request *domain.LogoutRequest) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type Auth struct {
|
type Auth struct {
|
||||||
@@ -48,7 +49,33 @@ func (a Auth) Logout(ctx context.Context, authData grpc.AuthData) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = a.authService.Logout(ctx, adminId)
|
err = a.authService.Logout(ctx, adminId, nil)
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "logout")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// LogoutWithReason
|
||||||
|
// @Tags auth
|
||||||
|
// @Summary Выход по бездействию из авторизованной сессии
|
||||||
|
// @Description Выход по бездействию из авторизованной сессии администрирования
|
||||||
|
// @Accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Param body body domain.LogoutRequest true "Тело запроса"
|
||||||
|
// @Param X-AUTH-ADMIN header string true "Токен администратора"
|
||||||
|
// @Success 200
|
||||||
|
// @Failure 400 {object} domain.GrpcError "Невалидный токен"
|
||||||
|
// @Failure 500 {object} domain.GrpcError
|
||||||
|
// @Router /auth/logout_with_reason [POST]
|
||||||
|
func (a Auth) LogoutWithReason(ctx context.Context, authData grpc.AuthData, logoutRequest domain.LogoutRequest) error {
|
||||||
|
adminId, err := getAdminId(authData)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = a.authService.Logout(ctx, adminId, &logoutRequest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessage(err, "logout")
|
return errors.WithMessage(err, "logout")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ func NewPermissions(permissionsService permissionsService) Permissions {
|
|||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Success 200 {array} domain.Permission
|
// @Success 200 {array} domain.Permission
|
||||||
// @Router /user/get_profile [POST]
|
// @Router /user/get_permissions [POST]
|
||||||
func (u Permissions) GetPermissions(ctx context.Context) []domain.Permission {
|
func (u Permissions) GetPermissions(ctx context.Context) []domain.Permission {
|
||||||
return u.permissionsService.All(ctx)
|
return u.permissionsService.All(ctx)
|
||||||
}
|
}
|
||||||
+12
-5
@@ -7,7 +7,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type SessionService interface {
|
type SessionService interface {
|
||||||
All(ctx context.Context, limit int, offset int) (*domain.SessionResponse, error)
|
All(ctx context.Context, req domain.SessionPageRequest) (*domain.SessionResponse, error)
|
||||||
Revoke(ctx context.Context, id int) error
|
Revoke(ctx context.Context, id int) error
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,13 +27,20 @@ func NewSession(service SessionService) Session {
|
|||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param X-AUTH-ADMIN header string true "Токен администратора"
|
// @Param X-AUTH-ADMIN header string true "Токен администратора"
|
||||||
// @Param body body domain.SessionRequest true "Тело запроса"
|
// @Param body body domain.SessionPageRequest true "Тело запроса"
|
||||||
// @Success 200 {object} domain.PageRequest
|
// @Success 200 {object} domain.SessionResponse
|
||||||
// @Failure 400 {object} domain.GrpcError "Невалидное тело запроса"
|
// @Failure 400 {object} domain.GrpcError "Невалидное тело запроса"
|
||||||
// @Failure 500 {object} domain.GrpcError
|
// @Failure 500 {object} domain.GrpcError
|
||||||
// @Router /session/all [POST]
|
// @Router /session/all [POST]
|
||||||
func (c Session) All(ctx context.Context, req domain.PageRequest) (*domain.SessionResponse, error) {
|
func (c Session) All(ctx context.Context, req domain.SessionPageRequest) (*domain.SessionResponse, error) {
|
||||||
return c.service.All(ctx, req.Limit, req.Offset)
|
if req.Order == nil {
|
||||||
|
req.Order = &domain.OrderParams{
|
||||||
|
Field: domain.DefaultOrderField,
|
||||||
|
Type: domain.DefaultOrderType,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.service.All(ctx, req)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Revoke
|
// Revoke
|
||||||
|
|||||||
+14
-5
@@ -2,18 +2,20 @@ package controller
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/txix-open/isp-kit/grpc/apierrors"
|
"github.com/txix-open/isp-kit/grpc/apierrors"
|
||||||
|
|
||||||
|
"msp-admin-service/domain"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/txix-open/isp-kit/grpc"
|
"github.com/txix-open/isp-kit/grpc"
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
"google.golang.org/grpc/status"
|
"google.golang.org/grpc/status"
|
||||||
"msp-admin-service/domain"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type userService interface {
|
type userService interface {
|
||||||
GetProfileById(ctx context.Context, userId int64) (*domain.AdminUserShort, error)
|
GetProfileById(ctx context.Context, userId int64) (*domain.AdminUserShort, error)
|
||||||
GetUsers(ctx context.Context, identities domain.UsersRequest) (*domain.UsersResponse, error)
|
GetUsers(ctx context.Context, req domain.UsersPageRequest) (*domain.UsersResponse, error)
|
||||||
CreateUser(ctx context.Context, req domain.CreateUserRequest, adminId int64) (*domain.User, error)
|
CreateUser(ctx context.Context, req domain.CreateUserRequest, adminId int64) (*domain.User, error)
|
||||||
UpdateUser(ctx context.Context, req domain.UpdateUserRequest, adminId int64) (*domain.User, error)
|
UpdateUser(ctx context.Context, req domain.UpdateUserRequest, adminId int64) (*domain.User, error)
|
||||||
DeleteUsers(ctx context.Context, ids []int64, adminId int64) (int, error)
|
DeleteUsers(ctx context.Context, ids []int64, adminId int64) (int, error)
|
||||||
@@ -70,13 +72,20 @@ func (u User) GetProfile(ctx context.Context, authData grpc.AuthData) (*domain.A
|
|||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param X-AUTH-ADMIN header string true "Токен администратора"
|
// @Param X-AUTH-ADMIN header string true "Токен администратора"
|
||||||
// @Param body body domain.UsersRequest true "Тело запроса"
|
// @Param body body domain.UsersPageRequest true "Тело запроса"
|
||||||
// @Success 200 {object} domain.UsersResponse
|
// @Success 200 {object} domain.UsersResponse
|
||||||
// @Failure 400 {object} domain.GrpcError
|
// @Failure 400 {object} domain.GrpcError
|
||||||
// @Failure 500 {object} domain.GrpcError
|
// @Failure 500 {object} domain.GrpcError
|
||||||
// @Router /user/get_users [POST]
|
// @Router /user/get_users [POST]
|
||||||
func (u User) GetUsers(ctx context.Context, identities domain.UsersRequest) (*domain.UsersResponse, error) {
|
func (u User) GetUsers(ctx context.Context, req domain.UsersPageRequest) (*domain.UsersResponse, error) {
|
||||||
users, err := u.userService.GetUsers(ctx, identities)
|
if req.Order == nil {
|
||||||
|
req.Order = &domain.OrderParams{
|
||||||
|
Field: domain.DefaultOrderField,
|
||||||
|
Type: domain.DefaultOrderType,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
users, err := u.userService.GetUsers(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessage(err, "get users")
|
return nil, errors.WithMessage(err, "get users")
|
||||||
}
|
}
|
||||||
|
|||||||
+190
-17
@@ -1,5 +1,15 @@
|
|||||||
basePath: /api/admin
|
basePath: /api/admin
|
||||||
definitions:
|
definitions:
|
||||||
|
apierrors.Error:
|
||||||
|
properties:
|
||||||
|
details:
|
||||||
|
additionalProperties: {}
|
||||||
|
type: object
|
||||||
|
errorCode:
|
||||||
|
type: integer
|
||||||
|
errorMessage:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
conf.UIDesign:
|
conf.UIDesign:
|
||||||
properties:
|
properties:
|
||||||
name:
|
name:
|
||||||
@@ -13,6 +23,8 @@ definitions:
|
|||||||
type: string
|
type: string
|
||||||
firstName:
|
firstName:
|
||||||
type: string
|
type: string
|
||||||
|
fullName:
|
||||||
|
type: string
|
||||||
idleTimeoutMs:
|
idleTimeoutMs:
|
||||||
type: integer
|
type: integer
|
||||||
lastName:
|
lastName:
|
||||||
@@ -23,6 +35,10 @@ definitions:
|
|||||||
type: array
|
type: array
|
||||||
role:
|
role:
|
||||||
type: string
|
type: string
|
||||||
|
roleNames:
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
type: array
|
||||||
roles:
|
roles:
|
||||||
items:
|
items:
|
||||||
type: integer
|
type: integer
|
||||||
@@ -50,6 +66,31 @@ definitions:
|
|||||||
name:
|
name:
|
||||||
type: string
|
type: string
|
||||||
type: object
|
type: object
|
||||||
|
domain.AuditPageRequest:
|
||||||
|
properties:
|
||||||
|
limit:
|
||||||
|
type: integer
|
||||||
|
offset:
|
||||||
|
format: int64
|
||||||
|
type: integer
|
||||||
|
order:
|
||||||
|
$ref: '#/definitions/domain.OrderParams'
|
||||||
|
query:
|
||||||
|
$ref: '#/definitions/domain.AuditQuery'
|
||||||
|
required:
|
||||||
|
- limit
|
||||||
|
type: object
|
||||||
|
domain.AuditQuery:
|
||||||
|
properties:
|
||||||
|
createdAt:
|
||||||
|
$ref: '#/definitions/domain.DateFromToParams'
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
message:
|
||||||
|
type: string
|
||||||
|
userId:
|
||||||
|
type: integer
|
||||||
|
type: object
|
||||||
domain.AuditResponse:
|
domain.AuditResponse:
|
||||||
properties:
|
properties:
|
||||||
items:
|
items:
|
||||||
@@ -102,6 +143,16 @@ definitions:
|
|||||||
- email
|
- email
|
||||||
- password
|
- password
|
||||||
type: object
|
type: object
|
||||||
|
domain.DateFromToParams:
|
||||||
|
properties:
|
||||||
|
from:
|
||||||
|
type: string
|
||||||
|
to:
|
||||||
|
type: string
|
||||||
|
required:
|
||||||
|
- from
|
||||||
|
- to
|
||||||
|
type: object
|
||||||
domain.DeleteResponse:
|
domain.DeleteResponse:
|
||||||
properties:
|
properties:
|
||||||
deleted:
|
deleted:
|
||||||
@@ -164,14 +215,22 @@ definitions:
|
|||||||
required:
|
required:
|
||||||
- authCode
|
- authCode
|
||||||
type: object
|
type: object
|
||||||
domain.PageRequest:
|
domain.LogoutRequest:
|
||||||
properties:
|
properties:
|
||||||
limit:
|
reason:
|
||||||
type: integer
|
type: string
|
||||||
offset:
|
type: object
|
||||||
type: integer
|
domain.OrderParams:
|
||||||
required:
|
properties:
|
||||||
- limit
|
field:
|
||||||
|
type: string
|
||||||
|
type:
|
||||||
|
enum:
|
||||||
|
- asc
|
||||||
|
- desc
|
||||||
|
- ASC
|
||||||
|
- DESC
|
||||||
|
type: string
|
||||||
type: object
|
type: object
|
||||||
domain.Permission:
|
domain.Permission:
|
||||||
properties:
|
properties:
|
||||||
@@ -218,6 +277,7 @@ definitions:
|
|||||||
domain.SecureAuthResponse:
|
domain.SecureAuthResponse:
|
||||||
properties:
|
properties:
|
||||||
adminId:
|
adminId:
|
||||||
|
format: int64
|
||||||
type: integer
|
type: integer
|
||||||
authenticated:
|
authenticated:
|
||||||
type: boolean
|
type: boolean
|
||||||
@@ -236,11 +296,53 @@ definitions:
|
|||||||
authorized:
|
authorized:
|
||||||
type: boolean
|
type: boolean
|
||||||
type: object
|
type: object
|
||||||
domain.SessionRequest:
|
domain.Session:
|
||||||
|
properties:
|
||||||
|
createdAt:
|
||||||
|
type: string
|
||||||
|
expiredAt:
|
||||||
|
type: string
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
status:
|
||||||
|
type: string
|
||||||
|
userId:
|
||||||
|
type: integer
|
||||||
|
type: object
|
||||||
|
domain.SessionPageRequest:
|
||||||
properties:
|
properties:
|
||||||
limit:
|
limit:
|
||||||
type: integer
|
type: integer
|
||||||
offset:
|
offset:
|
||||||
|
format: int64
|
||||||
|
type: integer
|
||||||
|
order:
|
||||||
|
$ref: '#/definitions/domain.OrderParams'
|
||||||
|
query:
|
||||||
|
$ref: '#/definitions/domain.SessionQuery'
|
||||||
|
required:
|
||||||
|
- limit
|
||||||
|
type: object
|
||||||
|
domain.SessionQuery:
|
||||||
|
properties:
|
||||||
|
createdAt:
|
||||||
|
$ref: '#/definitions/domain.DateFromToParams'
|
||||||
|
expiredAt:
|
||||||
|
$ref: '#/definitions/domain.DateFromToParams'
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
status:
|
||||||
|
type: string
|
||||||
|
userId:
|
||||||
|
type: integer
|
||||||
|
type: object
|
||||||
|
domain.SessionResponse:
|
||||||
|
properties:
|
||||||
|
items:
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/domain.Session'
|
||||||
|
type: array
|
||||||
|
totalCount:
|
||||||
type: integer
|
type: integer
|
||||||
type: object
|
type: object
|
||||||
domain.SetAuditEvent:
|
domain.SetAuditEvent:
|
||||||
@@ -298,7 +400,10 @@ definitions:
|
|||||||
type: string
|
type: string
|
||||||
firstName:
|
firstName:
|
||||||
type: string
|
type: string
|
||||||
|
fullName:
|
||||||
|
type: string
|
||||||
id:
|
id:
|
||||||
|
format: int64
|
||||||
type: integer
|
type: integer
|
||||||
lastName:
|
lastName:
|
||||||
type: string
|
type: string
|
||||||
@@ -311,18 +416,36 @@ definitions:
|
|||||||
updatedAt:
|
updatedAt:
|
||||||
type: string
|
type: string
|
||||||
type: object
|
type: object
|
||||||
domain.UsersRequest:
|
domain.UserQuery:
|
||||||
properties:
|
properties:
|
||||||
|
description:
|
||||||
|
type: string
|
||||||
email:
|
email:
|
||||||
type: string
|
type: string
|
||||||
ids:
|
id:
|
||||||
|
type: integer
|
||||||
|
lastSessionCreatedAt:
|
||||||
|
$ref: '#/definitions/domain.DateFromToParams'
|
||||||
|
roles:
|
||||||
items:
|
items:
|
||||||
type: integer
|
type: integer
|
||||||
type: array
|
type: array
|
||||||
|
userId:
|
||||||
|
type: integer
|
||||||
|
type: object
|
||||||
|
domain.UsersPageRequest:
|
||||||
|
properties:
|
||||||
limit:
|
limit:
|
||||||
type: integer
|
type: integer
|
||||||
offset:
|
offset:
|
||||||
|
format: int64
|
||||||
type: integer
|
type: integer
|
||||||
|
order:
|
||||||
|
$ref: '#/definitions/domain.OrderParams'
|
||||||
|
query:
|
||||||
|
$ref: '#/definitions/domain.UserQuery'
|
||||||
|
required:
|
||||||
|
- limit
|
||||||
type: object
|
type: object
|
||||||
domain.UsersResponse:
|
domain.UsersResponse:
|
||||||
properties:
|
properties:
|
||||||
@@ -435,6 +558,39 @@ paths:
|
|||||||
summary: Выход из авторизованной сессии
|
summary: Выход из авторизованной сессии
|
||||||
tags:
|
tags:
|
||||||
- auth
|
- auth
|
||||||
|
/auth/logout_with_reason:
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: Выход по бездействию из авторизованной сессии администрирования
|
||||||
|
parameters:
|
||||||
|
- description: Тело запроса
|
||||||
|
in: body
|
||||||
|
name: body
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/domain.LogoutRequest'
|
||||||
|
- description: Токен администратора
|
||||||
|
in: header
|
||||||
|
name: X-AUTH-ADMIN
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
"400":
|
||||||
|
description: Невалидный токен
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/domain.GrpcError'
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/domain.GrpcError'
|
||||||
|
summary: Выход по бездействию из авторизованной сессии
|
||||||
|
tags:
|
||||||
|
- auth
|
||||||
/log/all:
|
/log/all:
|
||||||
post:
|
post:
|
||||||
consumes:
|
consumes:
|
||||||
@@ -450,7 +606,7 @@ paths:
|
|||||||
name: body
|
name: body
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/domain.PageRequest'
|
$ref: '#/definitions/domain.AuditPageRequest'
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
responses:
|
responses:
|
||||||
@@ -748,14 +904,14 @@ paths:
|
|||||||
name: body
|
name: body
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/domain.SessionRequest'
|
$ref: '#/definitions/domain.SessionPageRequest'
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: OK
|
description: OK
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/domain.PageRequest'
|
$ref: '#/definitions/domain.SessionResponse'
|
||||||
"400":
|
"400":
|
||||||
description: Невалидное тело запроса
|
description: Невалидное тело запроса
|
||||||
schema:
|
schema:
|
||||||
@@ -855,11 +1011,11 @@ paths:
|
|||||||
"400":
|
"400":
|
||||||
description: Невалидное тело запроса
|
description: Невалидное тело запроса
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/domain.GrpcError'
|
$ref: '#/definitions/apierrors.Error'
|
||||||
"500":
|
"500":
|
||||||
description: Internal Server Error
|
description: внутренняя ошибка
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/domain.GrpcError'
|
$ref: '#/definitions/apierrors.Error'
|
||||||
summary: Метод изменения пароля пользователя
|
summary: Метод изменения пароля пользователя
|
||||||
tags:
|
tags:
|
||||||
- user
|
- user
|
||||||
@@ -995,6 +1151,23 @@ paths:
|
|||||||
summary: Получение внешнего вида
|
summary: Получение внешнего вида
|
||||||
tags:
|
tags:
|
||||||
- user
|
- user
|
||||||
|
/user/get_permissions:
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: Получить все разрашения
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/domain.Permission'
|
||||||
|
type: array
|
||||||
|
summary: Получить все разрашения
|
||||||
|
tags:
|
||||||
|
- user
|
||||||
/user/get_profile:
|
/user/get_profile:
|
||||||
post:
|
post:
|
||||||
consumes:
|
consumes:
|
||||||
@@ -1044,7 +1217,7 @@ paths:
|
|||||||
name: body
|
name: body
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/domain.UsersRequest'
|
$ref: '#/definitions/domain.UsersPageRequest'
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
responses:
|
responses:
|
||||||
|
|||||||
+12
-3
@@ -16,9 +16,18 @@ type AuditResponse struct {
|
|||||||
Items []Audit
|
Items []Audit
|
||||||
}
|
}
|
||||||
|
|
||||||
type PageRequest struct {
|
type AuditPageRequest struct {
|
||||||
Limit int `validate:"required"`
|
LimitOffestParams
|
||||||
Offset int
|
|
||||||
|
Order *OrderParams
|
||||||
|
Query *AuditQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
type AuditQuery struct {
|
||||||
|
Id *int
|
||||||
|
UserId *int
|
||||||
|
Message *string
|
||||||
|
CreatedAt *DateFromToParams
|
||||||
}
|
}
|
||||||
|
|
||||||
type SetAuditEvent struct {
|
type SetAuditEvent struct {
|
||||||
|
|||||||
@@ -6,6 +6,10 @@ const (
|
|||||||
AdminAuthIdHeader = "x-admin-id"
|
AdminAuthIdHeader = "x-admin-id"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type LogoutRequest struct {
|
||||||
|
Reason string
|
||||||
|
}
|
||||||
|
|
||||||
type LoginRequest struct {
|
type LoginRequest struct {
|
||||||
Email string `validate:"required"`
|
Email string `validate:"required"`
|
||||||
Password string ` validate:"required"`
|
Password string ` validate:"required"`
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package domain
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
const (
|
||||||
|
DefaultOrderField = "created_at"
|
||||||
|
DefaultOrderType = "desc"
|
||||||
|
)
|
||||||
|
|
||||||
|
type LimitOffestParams struct {
|
||||||
|
Limit uint64 `validate:"required"`
|
||||||
|
Offset uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
type OrderParams struct {
|
||||||
|
Field string
|
||||||
|
Type string `validate:"oneof=asc desc ASC DESC"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DateFromToParams struct {
|
||||||
|
From time.Time `validate:"required"`
|
||||||
|
To time.Time `validate:"required"`
|
||||||
|
}
|
||||||
+15
-5
@@ -12,16 +12,26 @@ type Session struct {
|
|||||||
CreatedAt time.Time
|
CreatedAt time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SessionPageRequest struct {
|
||||||
|
LimitOffestParams
|
||||||
|
|
||||||
|
Order *OrderParams
|
||||||
|
Query *SessionQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
type SessionQuery struct {
|
||||||
|
Id *int
|
||||||
|
UserId *int
|
||||||
|
Status *string
|
||||||
|
CreatedAt *DateFromToParams
|
||||||
|
ExpiredAt *DateFromToParams
|
||||||
|
}
|
||||||
|
|
||||||
type SessionResponse struct {
|
type SessionResponse struct {
|
||||||
TotalCount int
|
TotalCount int
|
||||||
Items []Session
|
Items []Session
|
||||||
}
|
}
|
||||||
|
|
||||||
type SessionRequest struct {
|
|
||||||
Limit int
|
|
||||||
Offset int
|
|
||||||
}
|
|
||||||
|
|
||||||
type RevokeRequest struct {
|
type RevokeRequest struct {
|
||||||
Id int `validate:"required"`
|
Id int `validate:"required"`
|
||||||
}
|
}
|
||||||
+17
-5
@@ -9,6 +9,7 @@ type User struct {
|
|||||||
Roles []int
|
Roles []int
|
||||||
FirstName string
|
FirstName string
|
||||||
LastName string
|
LastName string
|
||||||
|
FullName string
|
||||||
Email string
|
Email string
|
||||||
Description string
|
Description string
|
||||||
Blocked bool
|
Blocked bool
|
||||||
@@ -21,19 +22,30 @@ type UsersResponse struct {
|
|||||||
Items []User
|
Items []User
|
||||||
}
|
}
|
||||||
|
|
||||||
type UsersRequest struct {
|
type UserQuery struct {
|
||||||
Ids []int64
|
Id *int
|
||||||
Offset int
|
UserId *int
|
||||||
Limit int
|
Description *string
|
||||||
Email string
|
Email *string
|
||||||
|
Roles []int
|
||||||
|
LastSessionCreatedAt *DateFromToParams
|
||||||
|
}
|
||||||
|
|
||||||
|
type UsersPageRequest struct {
|
||||||
|
LimitOffestParams
|
||||||
|
|
||||||
|
Order *OrderParams
|
||||||
|
Query *UserQuery
|
||||||
}
|
}
|
||||||
|
|
||||||
type AdminUserShort struct {
|
type AdminUserShort struct {
|
||||||
FirstName string
|
FirstName string
|
||||||
LastName string
|
LastName string
|
||||||
|
FullName string
|
||||||
Email string `validate:"required"`
|
Email string `validate:"required"`
|
||||||
Role string
|
Role string
|
||||||
Roles []int
|
Roles []int
|
||||||
|
RoleNames []string
|
||||||
Permissions []string
|
Permissions []string
|
||||||
IdleTimeoutMs int
|
IdleTimeoutMs int
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ const (
|
|||||||
EventUserChanged = "user_changed"
|
EventUserChanged = "user_changed"
|
||||||
EventUserPasswordChanged = "success_change_password"
|
EventUserPasswordChanged = "success_change_password"
|
||||||
EventErrorPasswordChange = "error_change_password"
|
EventErrorPasswordChange = "error_change_password"
|
||||||
|
EventUserBlocked = "user_blocked"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AuditEvent struct {
|
type AuditEvent struct {
|
||||||
|
|||||||
+1
-1
@@ -30,7 +30,7 @@ func (p *PermList) Scan(src any) error {
|
|||||||
return json.Unmarshal(src.([]byte), p)
|
return json.Unmarshal(src.([]byte), p)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p PermList) Value() (driver.Value, error) {
|
func (p *PermList) Value() (driver.Value, error) {
|
||||||
bytes, err := json.Marshal(p)
|
bytes, err := json.Marshal(p)
|
||||||
return driver.Value(bytes), err
|
return driver.Value(bytes), err
|
||||||
}
|
}
|
||||||
+2
-1
@@ -1,4 +1,4 @@
|
|||||||
// nolint:tagliatelle
|
// nolint:tagliatelle,errname
|
||||||
package entity
|
package entity
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -22,6 +22,7 @@ type SudirUserResponse struct {
|
|||||||
Sub string `json:"sub"`
|
Sub string `json:"sub"`
|
||||||
GivenName string `json:"given_name"`
|
GivenName string `json:"given_name"`
|
||||||
FamilyName string `json:"family_name"`
|
FamilyName string `json:"family_name"`
|
||||||
|
Name string `json:"name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SudirTokenResponse struct {
|
type SudirTokenResponse struct {
|
||||||
|
|||||||
+15
-10
@@ -3,16 +3,19 @@ package entity
|
|||||||
import "time"
|
import "time"
|
||||||
|
|
||||||
type User struct {
|
type User struct {
|
||||||
SudirUserId *string
|
SudirUserId *string
|
||||||
Id int64
|
Id int64
|
||||||
FirstName string
|
FirstName string
|
||||||
LastName string
|
LastName string
|
||||||
Description string
|
FullName string
|
||||||
Email string
|
Description string
|
||||||
Password string
|
Email string
|
||||||
Blocked bool
|
Password string
|
||||||
UpdatedAt time.Time
|
Blocked bool
|
||||||
CreatedAt time.Time
|
LastActiveAt time.Time
|
||||||
|
UpdatedAt time.Time
|
||||||
|
CreatedAt time.Time
|
||||||
|
LastSessionCreatedAt *time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
type SudirUser struct {
|
type SudirUser struct {
|
||||||
@@ -22,11 +25,13 @@ type SudirUser struct {
|
|||||||
LastName string
|
LastName string
|
||||||
Email string
|
Email string
|
||||||
Description string
|
Description string
|
||||||
|
FullName string
|
||||||
}
|
}
|
||||||
|
|
||||||
type UpdateUser struct {
|
type UpdateUser struct {
|
||||||
FirstName string
|
FirstName string
|
||||||
LastName string
|
LastName string
|
||||||
|
FullName string
|
||||||
Email string
|
Email string
|
||||||
Description string
|
Description string
|
||||||
}
|
}
|
||||||
@@ -1,85 +1,84 @@
|
|||||||
module msp-admin-service
|
module msp-admin-service
|
||||||
|
|
||||||
go 1.23
|
go 1.25
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/Masterminds/squirrel v1.5.4
|
github.com/Masterminds/squirrel v1.5.4
|
||||||
github.com/go-ldap/ldap/v3 v3.4.8
|
|
||||||
github.com/google/uuid v1.6.0
|
github.com/google/uuid v1.6.0
|
||||||
|
github.com/iancoleman/strcase v0.3.0
|
||||||
github.com/pkg/errors v0.9.1
|
github.com/pkg/errors v0.9.1
|
||||||
github.com/stretchr/testify v1.9.0
|
github.com/stretchr/testify v1.11.1
|
||||||
github.com/txix-open/bgjob v1.4.0
|
github.com/txix-open/bgjob v1.6.0
|
||||||
github.com/txix-open/isp-kit v1.39.1
|
github.com/txix-open/isp-kit v1.64.10
|
||||||
github.com/txix-open/jsonschema v1.2.0
|
github.com/txix-open/jsonschema v1.3.0
|
||||||
golang.org/x/crypto v0.28.0
|
golang.org/x/crypto v0.45.0
|
||||||
golang.org/x/sync v0.8.0
|
golang.org/x/sync v0.18.0
|
||||||
google.golang.org/grpc v1.67.1
|
google.golang.org/grpc v1.75.1
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358 // indirect
|
|
||||||
github.com/bahlo/generic-list-go v0.2.0 // indirect
|
github.com/bahlo/generic-list-go v0.2.0 // indirect
|
||||||
github.com/beorn7/perks v1.0.1 // indirect
|
github.com/beorn7/perks v1.0.1 // indirect
|
||||||
github.com/buger/jsonparser v1.1.1 // indirect
|
github.com/buger/jsonparser v1.1.1 // indirect
|
||||||
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
|
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
|
||||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||||
github.com/coder/websocket v1.8.12 // indirect
|
github.com/coder/websocket v1.8.14 // indirect
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/gabriel-vasile/mimetype v1.4.6 // indirect
|
github.com/gabriel-vasile/mimetype v1.4.10 // indirect
|
||||||
github.com/getsentry/sentry-go v0.29.1 // indirect
|
github.com/getsentry/sentry-go v0.35.2 // indirect
|
||||||
github.com/go-asn1-ber/asn1-ber v1.5.5 // indirect
|
github.com/go-logr/logr v1.4.3 // indirect
|
||||||
github.com/go-logr/logr v1.4.2 // indirect
|
|
||||||
github.com/go-logr/stdr v1.2.2 // indirect
|
github.com/go-logr/stdr v1.2.2 // indirect
|
||||||
github.com/go-playground/locales v0.14.1 // indirect
|
github.com/go-playground/locales v0.14.1 // indirect
|
||||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2 // indirect
|
||||||
github.com/iancoleman/strcase v0.3.0 // indirect
|
|
||||||
github.com/jackc/pgpassfile v1.0.0 // indirect
|
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||||
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
|
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
|
||||||
github.com/jackc/pgx/v5 v5.7.1 // indirect
|
github.com/jackc/pgx/v5 v5.7.6 // indirect
|
||||||
github.com/jackc/puddle/v2 v2.2.2 // indirect
|
github.com/jackc/puddle/v2 v2.2.2 // indirect
|
||||||
github.com/jmoiron/sqlx v1.4.0 // indirect
|
github.com/jmoiron/sqlx v1.4.0 // indirect
|
||||||
github.com/json-iterator/go v1.1.12 // indirect
|
github.com/json-iterator/go v1.1.12 // indirect
|
||||||
github.com/klauspost/compress v1.17.11 // indirect
|
|
||||||
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect
|
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect
|
||||||
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
|
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
|
||||||
github.com/leodido/go-urn v1.4.0 // indirect
|
github.com/leodido/go-urn v1.4.0 // indirect
|
||||||
github.com/mailru/easyjson v0.7.7 // indirect
|
github.com/mailru/easyjson v0.9.0 // indirect
|
||||||
github.com/mfridman/interpolate v0.0.2 // indirect
|
github.com/mfridman/interpolate v0.0.2 // indirect
|
||||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
github.com/pressly/goose/v3 v3.22.1 // indirect
|
github.com/pressly/goose/v3 v3.25.0 // indirect
|
||||||
github.com/prometheus/client_golang v1.20.5 // indirect
|
github.com/prometheus/client_golang v1.23.2 // indirect
|
||||||
github.com/prometheus/client_model v0.6.1 // indirect
|
github.com/prometheus/client_model v0.6.2 // indirect
|
||||||
github.com/prometheus/common v0.60.1 // indirect
|
github.com/prometheus/common v0.66.1 // indirect
|
||||||
github.com/prometheus/procfs v0.15.1 // indirect
|
github.com/prometheus/procfs v0.17.0 // indirect
|
||||||
|
github.com/robfig/cron/v3 v3.0.1 // indirect
|
||||||
github.com/sethvargo/go-retry v0.3.0 // indirect
|
github.com/sethvargo/go-retry v0.3.0 // indirect
|
||||||
github.com/txix-open/bellows v1.2.0 // indirect
|
github.com/txix-open/bellows v1.2.0 // indirect
|
||||||
github.com/txix-open/etp/v4 v4.0.1 // indirect
|
github.com/txix-open/etp/v4 v4.0.1 // indirect
|
||||||
github.com/txix-open/validator/v10 v10.0.0-20240401163703-e83541b40f99 // indirect
|
github.com/txix-open/validator/v10 v10.0.0-20250506161033-f8ce404fffdb // indirect
|
||||||
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
|
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
|
||||||
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
|
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
|
||||||
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
|
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
|
||||||
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
|
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
|
||||||
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.56.0 // indirect
|
go.opentelemetry.io/auto/sdk v1.2.0 // indirect
|
||||||
go.opentelemetry.io/otel v1.31.0 // indirect
|
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.63.0 // indirect
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.31.0 // indirect
|
go.opentelemetry.io/otel v1.38.0 // indirect
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.31.0 // indirect
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.38.0 // indirect
|
||||||
go.opentelemetry.io/otel/metric v1.31.0 // indirect
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.38.0 // indirect
|
||||||
go.opentelemetry.io/otel/sdk v1.31.0 // indirect
|
go.opentelemetry.io/otel/metric v1.38.0 // indirect
|
||||||
go.opentelemetry.io/otel/trace v1.31.0 // indirect
|
go.opentelemetry.io/otel/sdk v1.38.0 // indirect
|
||||||
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
|
go.opentelemetry.io/otel/trace v1.38.0 // indirect
|
||||||
|
go.opentelemetry.io/proto/otlp v1.8.0 // indirect
|
||||||
go.uber.org/multierr v1.11.0 // indirect
|
go.uber.org/multierr v1.11.0 // indirect
|
||||||
go.uber.org/zap v1.27.0 // indirect
|
go.uber.org/zap v1.27.0 // indirect
|
||||||
golang.org/x/net v0.30.0 // indirect
|
go.yaml.in/yaml/v2 v2.4.3 // indirect
|
||||||
golang.org/x/sys v0.26.0 // indirect
|
golang.org/x/net v0.47.0 // indirect
|
||||||
golang.org/x/text v0.19.0 // indirect
|
golang.org/x/sys v0.38.0 // indirect
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20241021214115-324edc3d5d38 // indirect
|
golang.org/x/text v0.31.0 // indirect
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38 // indirect
|
google.golang.org/genproto/googleapis/api v0.0.0-20250908214217-97024824d090 // indirect
|
||||||
google.golang.org/protobuf v1.35.1 // indirect
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20250908214217-97024824d090 // indirect
|
||||||
|
google.golang.org/protobuf v1.36.9 // indirect
|
||||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
|
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
)
|
)
|
||||||
@@ -1,11 +1,7 @@
|
|||||||
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
|
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
|
||||||
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
|
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
|
||||||
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358 h1:mFRzDkZVAjdal+s7s0MwaRv9igoPqLRdzOLzw/8Xvq8=
|
|
||||||
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358/go.mod h1:chxPXzSsl7ZWRAuOIE23GDNzjWuZquvFlgA8xmpunjU=
|
|
||||||
github.com/Masterminds/squirrel v1.5.4 h1:uUcX/aBc8O7Fg9kaISIUsHXdKuqehiXAMQTYX8afzqM=
|
github.com/Masterminds/squirrel v1.5.4 h1:uUcX/aBc8O7Fg9kaISIUsHXdKuqehiXAMQTYX8afzqM=
|
||||||
github.com/Masterminds/squirrel v1.5.4/go.mod h1:NNaOrjSoIDfDA40n7sr2tPNZRfjzjA400rg+riTZj10=
|
github.com/Masterminds/squirrel v1.5.4/go.mod h1:NNaOrjSoIDfDA40n7sr2tPNZRfjzjA400rg+riTZj10=
|
||||||
github.com/alexbrainman/sspi v0.0.0-20231016080023-1a75b4708caa h1:LHTHcTQiSGT7VVbI0o4wBRNQIgn917usHWOd6VAffYI=
|
|
||||||
github.com/alexbrainman/sspi v0.0.0-20231016080023-1a75b4708caa/go.mod h1:cEWa1LVoE5KvSD9ONXsZrj0z6KqySlCCNKHlLzbqAt4=
|
|
||||||
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so=
|
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so=
|
||||||
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
|
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
|
||||||
github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk=
|
github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk=
|
||||||
@@ -16,10 +12,12 @@ github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMU
|
|||||||
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
|
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
|
||||||
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
|
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
|
||||||
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
|
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
|
||||||
|
github.com/cenkalti/backoff/v5 v5.0.3 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1xcsSM=
|
||||||
|
github.com/cenkalti/backoff/v5 v5.0.3/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw=
|
||||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||||
github.com/coder/websocket v1.8.12 h1:5bUXkEPPIbewrnkU8LTCLVaxi4N4J8ahufH2vlo4NAo=
|
github.com/coder/websocket v1.8.14 h1:9L0p0iKiNOibykf283eHkKUHHrpG7f65OE3BhhO7v9g=
|
||||||
github.com/coder/websocket v1.8.12/go.mod h1:LNVeNrXQZfe5qhS9ALED3uA+l5pPqvwXg3CKoDBB2gs=
|
github.com/coder/websocket v1.8.14/go.mod h1:NX3SzP+inril6yawo5CQXx8+fk145lPDC6pumgx0mVg=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
@@ -27,19 +25,15 @@ github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkp
|
|||||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||||
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
|
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
|
||||||
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
||||||
github.com/gabriel-vasile/mimetype v1.4.6 h1:3+PzJTKLkvgjeTbts6msPJt4DixhT4YtFNf1gtGe3zc=
|
github.com/gabriel-vasile/mimetype v1.4.10 h1:zyueNbySn/z8mJZHLt6IPw0KoZsiQNszIpU+bX4+ZK0=
|
||||||
github.com/gabriel-vasile/mimetype v1.4.6/go.mod h1:JX1qVKqZd40hUPpAfiNTe0Sne7hdfKSbOqqmkq8GCXc=
|
github.com/gabriel-vasile/mimetype v1.4.10/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=
|
||||||
github.com/getsentry/sentry-go v0.29.1 h1:DyZuChN8Hz3ARxGVV8ePaNXh1dQ7d76AiB117xcREwA=
|
github.com/getsentry/sentry-go v0.35.2 h1:jKuujpRwa8FFRYMIwwZpu83Xh0voll9bmvyc6310WBM=
|
||||||
github.com/getsentry/sentry-go v0.29.1/go.mod h1:x3AtIzN01d6SiWkderzaH28Tm0lgkafpJ5Bm3li39O0=
|
github.com/getsentry/sentry-go v0.35.2/go.mod h1:mdL49ixwT2yi57k5eh7mpnDyPybixPzlzEJFu0Z76QA=
|
||||||
github.com/go-asn1-ber/asn1-ber v1.5.5 h1:MNHlNMBDgEKD4TcKr36vQN68BA00aDfjIt3/bD50WnA=
|
|
||||||
github.com/go-asn1-ber/asn1-ber v1.5.5/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0=
|
|
||||||
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
|
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
|
||||||
github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
|
github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
|
||||||
github.com/go-ldap/ldap/v3 v3.4.8 h1:loKJyspcRezt2Q3ZRMq2p/0v8iOurlmeXDPw6fikSvQ=
|
|
||||||
github.com/go-ldap/ldap/v3 v3.4.8/go.mod h1:qS3Sjlu76eHfHGpUdWkAXQTw4beih+cHsco2jXlIXrk=
|
|
||||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||||
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
|
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
|
||||||
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||||
@@ -48,55 +42,38 @@ github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/o
|
|||||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||||
github.com/go-resty/resty/v2 v2.15.3 h1:bqff+hcqAflpiF591hhJzNdkRsFhlB96CYfBwSFvql8=
|
github.com/go-resty/resty/v2 v2.16.5 h1:hBKqmWrr7uRc3euHVqmh1HTHcKn99Smr7o5spptdhTM=
|
||||||
github.com/go-resty/resty/v2 v2.15.3/go.mod h1:0fHAoK7JoBy/Ch36N8VFeMsK7xQOHhvWaC3iOktwmIU=
|
github.com/go-resty/resty/v2 v2.16.5/go.mod h1:hkJtXbA2iKHzJheXYvQ8snQES5ZLGKMwQ07xAwp/fiA=
|
||||||
github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y=
|
|
||||||
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
|
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
|
||||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
github.com/go-sql-driver/mysql v1.9.3 h1:U/N249h2WzJ3Ukj8SowVFjdtZKfu9vlLZxjPXV1aweo=
|
||||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
github.com/go-sql-driver/mysql v1.9.3/go.mod h1:qn46aNg1333BRMNU69Lq93t8du/dwxI64Gl8i5p1WMU=
|
||||||
|
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
|
||||||
|
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
|
||||||
|
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||||
|
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2 h1:8Tjv8EJ+pM1xP8mK6egEbD1OgnVTyacbefKhmbLhIhU=
|
||||||
github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM=
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2/go.mod h1:pkJQ2tZHJ0aFOVEEot6oZmaVEZcRme73eIFmhiVuRWs=
|
||||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 h1:asbCHRVmodnJTuQ3qamDwqVOIjwqUPTYmYuemVOx+Ys=
|
|
||||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0/go.mod h1:ggCgvZ2r7uOoQjOyu2Y1NhHmEPPzzuhWgcza5M1Ji1I=
|
|
||||||
github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
|
||||||
github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8=
|
|
||||||
github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
|
||||||
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
|
|
||||||
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
|
|
||||||
github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
|
github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
|
||||||
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
|
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
|
||||||
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
|
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
|
||||||
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
|
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
|
||||||
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=
|
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=
|
||||||
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
|
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
|
||||||
github.com/jackc/pgx/v5 v5.7.1 h1:x7SYsPBYDkHDksogeSmZZ5xzThcTgRz++I5E+ePFUcs=
|
github.com/jackc/pgx/v5 v5.7.6 h1:rWQc5FwZSPX58r1OQmkuaNicxdmExaEz5A2DO2hUuTk=
|
||||||
github.com/jackc/pgx/v5 v5.7.1/go.mod h1:e7O26IywZZ+naJtWWos6i6fvWK+29etgITqrqHLfoZA=
|
github.com/jackc/pgx/v5 v5.7.6/go.mod h1:aruU7o91Tc2q2cFp5h4uP3f6ztExVpyVv88Xl/8Vl8M=
|
||||||
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
|
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
|
||||||
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
|
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
|
||||||
github.com/jcmturner/aescts/v2 v2.0.0 h1:9YKLH6ey7H4eDBXW8khjYslgyqG2xZikXP0EQFKrle8=
|
|
||||||
github.com/jcmturner/aescts/v2 v2.0.0/go.mod h1:AiaICIRyfYg35RUkr8yESTqvSy7csK90qZ5xfvvsoNs=
|
|
||||||
github.com/jcmturner/dnsutils/v2 v2.0.0 h1:lltnkeZGL0wILNvrNiVCR6Ro5PGU/SeBvVO/8c/iPbo=
|
|
||||||
github.com/jcmturner/dnsutils/v2 v2.0.0/go.mod h1:b0TnjGOvI/n42bZa+hmXL+kFJZsFT7G4t3HTlQ184QM=
|
|
||||||
github.com/jcmturner/gofork v1.7.6 h1:QH0l3hzAU1tfT3rZCnW5zXl+orbkNMMRGJfdJjHVETg=
|
|
||||||
github.com/jcmturner/gofork v1.7.6/go.mod h1:1622LH6i/EZqLloHfE7IeZ0uEJwMSUyQ/nDd82IeqRo=
|
|
||||||
github.com/jcmturner/goidentity/v6 v6.0.1 h1:VKnZd2oEIMorCTsFBnJWbExfNN7yZr3EhJAxwOkZg6o=
|
|
||||||
github.com/jcmturner/goidentity/v6 v6.0.1/go.mod h1:X1YW3bgtvwAXju7V3LCIMpY0Gbxyjn/mY9zx4tFonSg=
|
|
||||||
github.com/jcmturner/gokrb5/v8 v8.4.4 h1:x1Sv4HaTpepFkXbt2IkL29DXRf8sOfZXo8eRKh687T8=
|
|
||||||
github.com/jcmturner/gokrb5/v8 v8.4.4/go.mod h1:1btQEpgT6k+unzCwX1KdWMEwPPkkgBtP+F6aCACiMrs=
|
|
||||||
github.com/jcmturner/rpc/v2 v2.0.3 h1:7FXXj8Ti1IaVFpSAziCZWNzbNuZmnvw/i6CqLNdWfZY=
|
|
||||||
github.com/jcmturner/rpc/v2 v2.0.3/go.mod h1:VUJYCIDm3PVOEHw8sgt091/20OJjskO/YJki3ELg/Hc=
|
|
||||||
github.com/jmoiron/sqlx v1.4.0 h1:1PLqN7S1UYp5t4SrVVnt4nUVNemrDAtxlulVe+Qgm3o=
|
github.com/jmoiron/sqlx v1.4.0 h1:1PLqN7S1UYp5t4SrVVnt4nUVNemrDAtxlulVe+Qgm3o=
|
||||||
github.com/jmoiron/sqlx v1.4.0/go.mod h1:ZrZ7UsYB/weZdl2Bxg6jCRO9c3YHl8r3ahlKmRT4JLY=
|
github.com/jmoiron/sqlx v1.4.0/go.mod h1:ZrZ7UsYB/weZdl2Bxg6jCRO9c3YHl8r3ahlKmRT4JLY=
|
||||||
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
|
|
||||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||||
github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=
|
github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=
|
||||||
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
|
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
|
||||||
github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc=
|
github.com/klauspost/compress v1.18.1 h1:bcSGx7UbpBqMChDtsF28Lw6v/G94LPrrbMbdC3JH2co=
|
||||||
github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
|
github.com/klauspost/compress v1.18.1/go.mod h1:ZQFFVG+MdnR0P+l6wpXgIL4NTtwiKIdBnrBd8Nrxr+0=
|
||||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||||
@@ -111,8 +88,8 @@ github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
|
|||||||
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
||||||
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
|
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
|
||||||
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||||
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
|
github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4=
|
||||||
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
|
github.com/mailru/easyjson v0.9.0/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU=
|
||||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||||
github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
|
github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
|
||||||
@@ -136,22 +113,24 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
|||||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/pressly/goose/v3 v3.22.1 h1:2zICEfr1O3yTP9BRZMGPj7qFxQ+ik6yeo+z1LMuioLc=
|
github.com/pressly/goose/v3 v3.25.0 h1:6WeYhMWGRCzpyd89SpODFnCBCKz41KrVbRT58nVjGng=
|
||||||
github.com/pressly/goose/v3 v3.22.1/go.mod h1:xtMpbstWyCpyH+0cxLTMCENWBG+0CSxvTsXhW95d5eo=
|
github.com/pressly/goose/v3 v3.25.0/go.mod h1:4hC1KrritdCxtuFsqgs1R4AU5bWtTAf+cnWvfhf2DNY=
|
||||||
github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
|
github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h0RJWRi/o0o=
|
||||||
github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
|
github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg=
|
||||||
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
|
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
|
||||||
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
|
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
|
||||||
github.com/prometheus/common v0.60.1 h1:FUas6GcOw66yB/73KC+BOZoFJmbo/1pojoILArPAaSc=
|
github.com/prometheus/common v0.66.1 h1:h5E0h5/Y8niHc5DlaLlWLArTQI7tMrsfQjHV+d9ZoGs=
|
||||||
github.com/prometheus/common v0.60.1/go.mod h1:h0LYf1R1deLSKtD4Vdg8gy4RuOvENW2J/h19V5NADQw=
|
github.com/prometheus/common v0.66.1/go.mod h1:gcaUsgf3KfRSwHY4dIMXLPV0K/Wg1oZ8+SbZk/HH/dA=
|
||||||
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
|
github.com/prometheus/procfs v0.17.0 h1:FuLQ+05u4ZI+SS/w9+BWEM2TXiHKsUQ9TADiRH7DuK0=
|
||||||
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
|
github.com/prometheus/procfs v0.17.0/go.mod h1:oPQLaDAMRbA+u8H5Pbfq+dl3VDAvHxMUOVhe0wYB2zw=
|
||||||
github.com/rabbitmq/amqp091-go v1.10.0 h1:STpn5XsHlHGcecLmMFCtg7mqq0RnD+zFr4uzukfVhBw=
|
github.com/rabbitmq/amqp091-go v1.10.0 h1:STpn5XsHlHGcecLmMFCtg7mqq0RnD+zFr4uzukfVhBw=
|
||||||
github.com/rabbitmq/amqp091-go v1.10.0/go.mod h1:Hy4jKW5kQART1u+JkDTF9YYOQUHXqMuhrgxOEeS7G4o=
|
github.com/rabbitmq/amqp091-go v1.10.0/go.mod h1:Hy4jKW5kQART1u+JkDTF9YYOQUHXqMuhrgxOEeS7G4o=
|
||||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
|
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
|
||||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
|
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
|
||||||
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
|
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
|
||||||
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
|
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
|
||||||
|
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
|
||||||
|
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
|
||||||
github.com/sethvargo/go-retry v0.3.0 h1:EEt31A35QhrcRZtrYFDTBg91cqZVnFL2navjDrah2SE=
|
github.com/sethvargo/go-retry v0.3.0 h1:EEt31A35QhrcRZtrYFDTBg91cqZVnFL2navjDrah2SE=
|
||||||
github.com/sethvargo/go-retry v0.3.0/go.mod h1:mNX17F0C/HguQMyMyJxcnU471gOZGxCLyYaFyAZraas=
|
github.com/sethvargo/go-retry v0.3.0/go.mod h1:mNX17F0C/HguQMyMyJxcnU471gOZGxCLyYaFyAZraas=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
@@ -160,28 +139,27 @@ github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpE
|
|||||||
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
|
||||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
|
||||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
|
||||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||||
|
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||||
|
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||||
github.com/txix-open/bellows v1.2.0 h1:CXv8nQaZtB/micraeRilYyj/gtfv+bqBgP5aPYQgjeY=
|
github.com/txix-open/bellows v1.2.0 h1:CXv8nQaZtB/micraeRilYyj/gtfv+bqBgP5aPYQgjeY=
|
||||||
github.com/txix-open/bellows v1.2.0/go.mod h1:qbKCy+RTgD30Qpw1fyb3y3jp5Y9mGhLLxgae1l0W92o=
|
github.com/txix-open/bellows v1.2.0/go.mod h1:qbKCy+RTgD30Qpw1fyb3y3jp5Y9mGhLLxgae1l0W92o=
|
||||||
github.com/txix-open/bgjob v1.4.0 h1:yfo0AgJKBa27nD34mHhV4YcDn4xfCXScDQw7WTigCZo=
|
github.com/txix-open/bgjob v1.6.0 h1:Vwj9cAsIhMrHPKRZVxfg6mHqE9LI/atDCq1aeihH3+I=
|
||||||
github.com/txix-open/bgjob v1.4.0/go.mod h1:akgEmwPCJatnIljUN7D7IyuwL8MTPBWxYPJ+216HWpY=
|
github.com/txix-open/bgjob v1.6.0/go.mod h1:aKbwpVclWmq82s7fchazp099yWjEpVKFkxT85i4hARM=
|
||||||
github.com/txix-open/etp/v4 v4.0.1 h1:5VSYgGsvnMz0tvUHsjVWFETI0qWBTCF1O3ARCHaCIgA=
|
github.com/txix-open/etp/v4 v4.0.1 h1:5VSYgGsvnMz0tvUHsjVWFETI0qWBTCF1O3ARCHaCIgA=
|
||||||
github.com/txix-open/etp/v4 v4.0.1/go.mod h1:FIu7TUDdwcgmtmF6tFTV1bGA2fRY/iVaPQdsGzvqYc8=
|
github.com/txix-open/etp/v4 v4.0.1/go.mod h1:FIu7TUDdwcgmtmF6tFTV1bGA2fRY/iVaPQdsGzvqYc8=
|
||||||
github.com/txix-open/grmq v1.6.0 h1:V4QRb0sI2CMfdMaMsFGvGvUIDGad5vr3khNU7A3LlP8=
|
github.com/txix-open/grmq v1.9.0 h1:ArDbJJcFX9zXKEcPf49rp9nYiRyGMJxGKJAxdbSsfaM=
|
||||||
github.com/txix-open/grmq v1.6.0/go.mod h1:s+NNNv42+32yLpjvl2tpqtyBbMB9e7kKFee3lfa/dyo=
|
github.com/txix-open/grmq v1.9.0/go.mod h1:EyFOP17KrwEFOUjR+PH8iH3LCtiN9TSQ8t0ysyk62po=
|
||||||
github.com/txix-open/isp-kit v1.39.1 h1:10zEILNQSPY7naiuaQkIKNS2/fnWxuE9bz+dTiAptXw=
|
github.com/txix-open/isp-kit v1.64.10 h1:lAowLtShBbICZbOWQJ4ptr9LaKKRZ7CE5DBK+7LcLqM=
|
||||||
github.com/txix-open/isp-kit v1.39.1/go.mod h1:xB6mkoOewZBI1ND8kjU5TR6kvLu3VQI3Rdkh6g6FE4I=
|
github.com/txix-open/isp-kit v1.64.10/go.mod h1:GvBsX5p2U3/ugK6PuWANYzSy/4YgawROm3eAKb35G6o=
|
||||||
github.com/txix-open/jsonschema v1.2.0 h1:B8TrdSsPhDvYv67oi/LVqf7/+PuqFlMsNwUzGeHfl1s=
|
github.com/txix-open/jsonschema v1.3.0 h1:XGuOTg22G7PdqfKypjajM20/i5FyGfFYsJKmheebKi4=
|
||||||
github.com/txix-open/jsonschema v1.2.0/go.mod h1:l8YDZ1nvJrw6uxWowSVOxCV/ebiMJyapffW87ZEqH00=
|
github.com/txix-open/jsonschema v1.3.0/go.mod h1:l8YDZ1nvJrw6uxWowSVOxCV/ebiMJyapffW87ZEqH00=
|
||||||
github.com/txix-open/validator/v10 v10.0.0-20240401163703-e83541b40f99 h1:Z0Sqf+U+Sc6hfIXtRCIZlbJprkCjwMFbS4ZbEPQ44To=
|
github.com/txix-open/validator/v10 v10.0.0-20250506161033-f8ce404fffdb h1:UJgT4u/QMv5QHKOQeJ7igShHa36c2/vIRqJiRLdDlf0=
|
||||||
github.com/txix-open/validator/v10 v10.0.0-20240401163703-e83541b40f99/go.mod h1:pA0NYmhL0uEkkxj55S+S7MZU4e2QIt46x9XSrzrWc3c=
|
github.com/txix-open/validator/v10 v10.0.0-20250506161033-f8ce404fffdb/go.mod h1:0biAFE0bgbcKeBBAwgEDhbZz6uT1vuSETCrFQlv2RiA=
|
||||||
github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc=
|
github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc=
|
||||||
github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw=
|
github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw=
|
||||||
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
|
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
|
||||||
@@ -191,112 +169,71 @@ github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHo
|
|||||||
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
|
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
|
||||||
github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
|
github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
|
||||||
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
|
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
|
||||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
go.opentelemetry.io/auto/sdk v1.2.0 h1:YpRtUFjvhSymycLS2T81lT6IGhcUP+LUPtv0iv1N8bM=
|
||||||
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.56.0 h1:4BZHA+B1wXEQoGNHxW8mURaLhcdGwvRnmhGbm+odRbc=
|
go.opentelemetry.io/auto/sdk v1.2.0/go.mod h1:1deq2zL7rwjwC8mR7XgY2N+tlIl6pjmEUoLDENMEzwk=
|
||||||
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.56.0/go.mod h1:3qi2EEwMgB4xnKgPLqsDP3j9qxnHDZeHsnAxfjQqTko=
|
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.63.0 h1:2pn7OzMewmYRiNtv1doZnLo3gONcnMHlFnmOR8Vgt+8=
|
||||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.56.0 h1:UP6IpuHFkUgOQL9FFQFrZ+5LiwhhYRbi7VZSIx6Nj5s=
|
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.63.0/go.mod h1:rjbQTDEPQymPE0YnRQp9/NuPwwtL0sesz/fnqRW/v84=
|
||||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.56.0/go.mod h1:qxuZLtbq5QDtdeSHsS7bcf6EH6uO6jUAgk764zd3rhM=
|
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.63.0 h1:RbKq8BG0FI8OiXhBfcRtqqHcZcka+gU3cskNuf05R18=
|
||||||
go.opentelemetry.io/otel v1.31.0 h1:NsJcKPIW0D0H3NgzPDHmo0WW6SptzPdqg/L1zsIm2hY=
|
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.63.0/go.mod h1:h06DGIukJOevXaj/xrNjhi/2098RZzcLTbc0jDAUbsg=
|
||||||
go.opentelemetry.io/otel v1.31.0/go.mod h1:O0C14Yl9FgkjqcCZAsE053C13OaddMYr/hz6clDkEJE=
|
go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8=
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.31.0 h1:K0XaT3DwHAcV4nKLzcQvwAgSyisUghWoY20I7huthMk=
|
go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM=
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.31.0/go.mod h1:B5Ki776z/MBnVha1Nzwp5arlzBbE3+1jk+pGmaP5HME=
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.38.0 h1:GqRJVj7UmLjCVyVJ3ZFLdPRmhDUp2zFmQe3RHIOsw24=
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.31.0 h1:lUsI2TYsQw2r1IASwoROaCnjdj2cvC2+Jbxvk6nHnWU=
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.38.0/go.mod h1:ri3aaHSmCTVYu2AWv44YMauwAQc0aqI9gHKIcSbI1pU=
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.31.0/go.mod h1:2HpZxxQurfGxJlJDblybejHB6RX6pmExPNe517hREw4=
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.38.0 h1:aTL7F04bJHUlztTsNGJ2l+6he8c+y/b//eR0jjjemT4=
|
||||||
go.opentelemetry.io/otel/metric v1.31.0 h1:FSErL0ATQAmYHUIzSezZibnyVlft1ybhy4ozRPcF2fE=
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.38.0/go.mod h1:kldtb7jDTeol0l3ewcmd8SDvx3EmIE7lyvqbasU3QC4=
|
||||||
go.opentelemetry.io/otel/metric v1.31.0/go.mod h1:C3dEloVbLuYoX41KpmAhOqNriGbA+qqH6PQ5E5mUfnY=
|
go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA=
|
||||||
go.opentelemetry.io/otel/sdk v1.31.0 h1:xLY3abVHYZ5HSfOg3l2E5LUj2Cwva5Y7yGxnSW9H5Gk=
|
go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI=
|
||||||
go.opentelemetry.io/otel/sdk v1.31.0/go.mod h1:TfRbMdhvxIIr/B2N2LQW2S5v9m3gOQ/08KsbbO5BPT0=
|
go.opentelemetry.io/otel/sdk v1.38.0 h1:l48sr5YbNf2hpCUj/FoGhW9yDkl+Ma+LrVl8qaM5b+E=
|
||||||
go.opentelemetry.io/otel/trace v1.31.0 h1:ffjsj1aRouKewfr85U2aGagJ46+MvodynlQ1HYdmJys=
|
go.opentelemetry.io/otel/sdk v1.38.0/go.mod h1:ghmNdGlVemJI3+ZB5iDEuk4bWA3GkTpW+DOoZMYBVVg=
|
||||||
go.opentelemetry.io/otel/trace v1.31.0/go.mod h1:TXZkRk7SM2ZQLtR6eoAWQFIHPvzQ06FJAsO1tJg480A=
|
go.opentelemetry.io/otel/sdk/metric v1.38.0 h1:aSH66iL0aZqo//xXzQLYozmWrXxyFkBJ6qT5wthqPoM=
|
||||||
go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0=
|
go.opentelemetry.io/otel/sdk/metric v1.38.0/go.mod h1:dg9PBnW9XdQ1Hd6ZnRz689CbtrUp0wMMs9iPcgT9EZA=
|
||||||
go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8=
|
go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE=
|
||||||
|
go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs=
|
||||||
|
go.opentelemetry.io/proto/otlp v1.8.0 h1:fRAZQDcAFHySxpJ1TwlA1cJ4tvcrw7nXl9xWWC8N5CE=
|
||||||
|
go.opentelemetry.io/proto/otlp v1.8.0/go.mod h1:tIeYOeNBU4cvmPqpaji1P+KbB4Oloai8wN4rWzRrFF0=
|
||||||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||||
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
||||||
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
||||||
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
||||||
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
|
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
|
||||||
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
|
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
go.yaml.in/yaml/v2 v2.4.3 h1:6gvOSjQoTB3vt1l+CU+tSyi/HOjfOjRLJ4YwYZGwRO0=
|
||||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
go.yaml.in/yaml/v2 v2.4.3/go.mod h1:zSxWcmIDjOzPXpjlTTbAsKokqkDNAVtZO0WOMiT90s8=
|
||||||
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
|
golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q=
|
||||||
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4=
|
||||||
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
|
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b h1:M2rDM6z3Fhozi9O7NWsxAkg/yqS/lQJ6PmkyIV3YP+o=
|
||||||
golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
|
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b/go.mod h1:3//PLf8L/X+8b4vuAfHzxeRUl04Adcb341+IGKfnqS8=
|
||||||
golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
|
golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY=
|
||||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU=
|
||||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
golang.org/x/sync v0.18.0 h1:kr88TuHDroi+UVf+0hZnirlk8o8T+4MrK6mr60WkH/I=
|
||||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/sync v0.18.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
|
||||||
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
|
||||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM=
|
||||||
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM=
|
||||||
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk=
|
||||||
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E=
|
||||||
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
|
google.golang.org/genproto/googleapis/api v0.0.0-20250908214217-97024824d090 h1:d8Nakh1G+ur7+P3GcMjpRDEkoLUcLW2iU92XVqR+XMQ=
|
||||||
golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
|
google.golang.org/genproto/googleapis/api v0.0.0-20250908214217-97024824d090/go.mod h1:U8EXRNSd8sUYyDfs/It7KVWodQr+Hf9xtxyxWudSwEw=
|
||||||
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20250908214217-97024824d090 h1:/OQuEa4YWtDt7uQWHd3q3sUMb+QOLQUg1xa8CEsRv5w=
|
||||||
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20250908214217-97024824d090/go.mod h1:GmFNa4BdJZ2a8G+wCe9Bg3wwThLrJun751XstdJt5Og=
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
google.golang.org/grpc v1.75.1 h1:/ODCNEuf9VghjgO3rqLcfg8fiOP0nSluljWFlDxELLI=
|
||||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
google.golang.org/grpc v1.75.1/go.mod h1:JtPAzKiq4v1xcAB2hydNlWI2RnF85XXcV0mhKXr2ecQ=
|
||||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
google.golang.org/protobuf v1.36.9 h1:w2gp2mA27hUeUzj9Ex9FBjsBm40zfaDtEWow293U7Iw=
|
||||||
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
|
google.golang.org/protobuf v1.36.9/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU=
|
||||||
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
|
||||||
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
|
||||||
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
|
|
||||||
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
|
||||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
|
||||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
|
||||||
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
|
|
||||||
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
|
|
||||||
golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58=
|
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
|
||||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
|
||||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
|
||||||
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
|
||||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
|
||||||
golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
|
|
||||||
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
|
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
|
||||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
|
||||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
|
||||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
|
||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20241021214115-324edc3d5d38 h1:2oV8dfuIkM1Ti7DwXc0BJfnwr9csz4TDXI9EmiI+Rbw=
|
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20241021214115-324edc3d5d38/go.mod h1:vuAjtvlwkDKF6L1GQ0SokiRLCGFfeBUXWr/aFFkHACc=
|
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38 h1:zciRKQ4kBpFgpfC5QQCVtnnNAcLIqweL7plyZRQHVpI=
|
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI=
|
|
||||||
google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E=
|
|
||||||
google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA=
|
|
||||||
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
|
|
||||||
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
|
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
|
||||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
|
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
|
||||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 h1:5D53IMaUuA5InSeMu9eJtlQXS2NxAhyWQvkKEgXZhHI=
|
modernc.org/libc v1.66.3 h1:cfCbjTUcdsKyyZZfEUKfoHcP3S0Wkvz3jgSzByEWVCQ=
|
||||||
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6/go.mod h1:Qz0X07sNOR1jWYCrJMEnbW/X55x206Q7Vt4mz6/wHp4=
|
modernc.org/libc v1.66.3/go.mod h1:XD9zO8kt59cANKvHPXpx7yS2ELPheAey0vjIuZOhOU8=
|
||||||
modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4=
|
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
|
||||||
modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo=
|
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
|
||||||
modernc.org/memory v1.8.0 h1:IqGTL6eFMaDZZhEWwcREgeMXYwmW83LYW8cROZYkg+E=
|
modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI=
|
||||||
modernc.org/memory v1.8.0/go.mod h1:XPZ936zp5OMKGWPqbD3JShgd/ZoQ7899TUuQqxY+peU=
|
modernc.org/memory v1.11.0/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw=
|
||||||
modernc.org/sqlite v1.33.0 h1:WWkA/T2G17okiLGgKAj4/RMIvgyMT19yQ038160IeYk=
|
modernc.org/sqlite v1.38.2 h1:Aclu7+tgjgcQVShZqim41Bbw9Cho0y/7WzYptXqkEek=
|
||||||
modernc.org/sqlite v1.33.0/go.mod h1:9uQ9hF/pCZoYZK73D/ud5Z7cIRIILSZI8NdIemVMTX8=
|
modernc.org/sqlite v1.38.2/go.mod h1:cPTJYSlgg3Sfg046yBShXENNtPrWrDX8bsbAQBzgQ5E=
|
||||||
modernc.org/strutil v1.2.0 h1:agBi9dp1I+eOnxXeiZawM8F4LawKv4NzGWSaLfyeNZA=
|
|
||||||
modernc.org/strutil v1.2.0/go.mod h1:/mdcBmfOibveCTBxUl5B5l6W+TTH1FXPLHZE6bTosX0=
|
|
||||||
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
|
|
||||||
modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
|
|
||||||
@@ -1,11 +1,13 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/txix-open/isp-kit/bootstrap"
|
|
||||||
"github.com/txix-open/isp-kit/shutdown"
|
|
||||||
"msp-admin-service/assembly"
|
"msp-admin-service/assembly"
|
||||||
"msp-admin-service/conf"
|
"msp-admin-service/conf"
|
||||||
"msp-admin-service/routes"
|
"msp-admin-service/routes"
|
||||||
|
|
||||||
|
"github.com/txix-open/isp-kit/bootstrap"
|
||||||
|
"github.com/txix-open/isp-kit/cluster"
|
||||||
|
"github.com/txix-open/isp-kit/shutdown"
|
||||||
)
|
)
|
||||||
|
|
||||||
var version = "1.0.0"
|
var version = "1.0.0"
|
||||||
@@ -19,11 +21,10 @@ var version = "1.0.0"
|
|||||||
// @host localhost:9000
|
// @host localhost:9000
|
||||||
// @BasePath /api/admin
|
// @BasePath /api/admin
|
||||||
|
|
||||||
//go:generate swag init
|
//go:generate swag init --parseDependency
|
||||||
//go:generate rm -f docs/swagger.json
|
//go:generate rm -f docs/swagger.json docs/docs.go
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
boot := bootstrap.New(version, conf.Remote{}, routes.EndpointDescriptors())
|
boot := bootstrap.New(version, conf.Remote{}, routes.EndpointDescriptors(), cluster.GrpcTransport)
|
||||||
app := boot.App
|
app := boot.App
|
||||||
logger := app.Logger()
|
logger := app.Logger()
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
-- +goose Up
|
||||||
|
update roles
|
||||||
|
set permissions = permissions || '[
|
||||||
|
"profile_view",
|
||||||
|
"profile_change_password",
|
||||||
|
"application_group_view",
|
||||||
|
"application_group_token_view",
|
||||||
|
"app_access_view",
|
||||||
|
"variable_view",
|
||||||
|
"module_view"
|
||||||
|
]'
|
||||||
|
where name = 'admin' or name = 'read_only_admin';
|
||||||
|
|
||||||
|
update roles
|
||||||
|
set permissions = permissions || '[
|
||||||
|
"application_group_add",
|
||||||
|
"application_group_edit",
|
||||||
|
"application_group_delete",
|
||||||
|
"application_group_app_add",
|
||||||
|
"application_group_app_edit",
|
||||||
|
"application_group_app_delete",
|
||||||
|
"application_group_token_add",
|
||||||
|
"application_group_token_delete",
|
||||||
|
"app_access_edit",
|
||||||
|
"variable_add",
|
||||||
|
"variable_edit",
|
||||||
|
"variable_delete",
|
||||||
|
"module_delete",
|
||||||
|
"module_configuration_save_unsafe",
|
||||||
|
"module_configuration_set_active",
|
||||||
|
"module_history_set",
|
||||||
|
"module_history_delete_version",
|
||||||
|
"module_configuration_edit",
|
||||||
|
"module_configuration_add"
|
||||||
|
]'
|
||||||
|
where name = 'admin';
|
||||||
|
|
||||||
|
-- +goose Down
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
-- +goose Up
|
||||||
|
ALTER TABLE users
|
||||||
|
ADD COLUMN last_active_at TIMESTAMP DEFAULT (now() at time zone 'utc') NOT NULL;
|
||||||
|
|
||||||
|
-- +goose Down
|
||||||
|
ALTER TABLE users
|
||||||
|
DROP COLUMN last_active_at;
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
-- +goose Up
|
||||||
|
ALTER TABLE users DROP CONSTRAINT users_email_key;
|
||||||
|
ALTER TABLE users ADD CONSTRAINT users_email_sudir_user_id_key UNIQUE (email, sudir_user_id);
|
||||||
|
|
||||||
|
-- +goose Down
|
||||||
|
ALTER TABLE users DROP CONSTRAINT users_email_sudir_user_id_key;
|
||||||
|
ALTER TABLE users ADD CONSTRAINT users_email_key UNIQUE (email);
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
-- +goose Up
|
||||||
|
INSERT INTO audit_event (event, enable)
|
||||||
|
VALUES
|
||||||
|
('user_blocked', true);
|
||||||
|
|
||||||
|
-- +goose Down
|
||||||
|
DELETE FROM audit_event WHERE event = 'user_blocked';
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
-- +goose Up
|
||||||
|
alter table bgjob_job
|
||||||
|
add column request_id text;
|
||||||
|
|
||||||
|
alter table bgjob_dead_job
|
||||||
|
add column request_id text;
|
||||||
|
|
||||||
|
update bgjob_job
|
||||||
|
set request_id = ''
|
||||||
|
where request_id is null;
|
||||||
|
|
||||||
|
update bgjob_dead_job
|
||||||
|
set request_id = ''
|
||||||
|
where request_id is null;
|
||||||
|
|
||||||
|
alter table bgjob_job
|
||||||
|
alter column request_id set default '',
|
||||||
|
alter column request_id set not null;
|
||||||
|
|
||||||
|
alter table bgjob_dead_job
|
||||||
|
alter column request_id set default '',
|
||||||
|
alter column request_id set not null;
|
||||||
|
|
||||||
|
-- +goose Down
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
-- +goose Up
|
||||||
|
ALTER TABLE users ADD COLUMN full_name VARCHAR(255) DEFAULT '' NOT NULL;
|
||||||
|
|
||||||
|
UPDATE users u SET full_name=u.first_name
|
||||||
|
WHERE (u.last_name = '') AND (u.first_name <> '');
|
||||||
|
|
||||||
|
UPDATE users u SET full_name=u.last_name || ' ' || u.first_name
|
||||||
|
WHERE (u.last_name <> '') AND (u.first_name <> '');
|
||||||
|
|
||||||
|
-- +goose Down
|
||||||
|
ALTER TABLE users DROP COLUMN full_name;
|
||||||
+51
-13
@@ -4,11 +4,15 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"msp-admin-service/domain"
|
||||||
|
"msp-admin-service/entity"
|
||||||
|
|
||||||
|
"github.com/Masterminds/squirrel"
|
||||||
|
"github.com/iancoleman/strcase"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/txix-open/isp-kit/db"
|
"github.com/txix-open/isp-kit/db"
|
||||||
"github.com/txix-open/isp-kit/db/query"
|
"github.com/txix-open/isp-kit/db/query"
|
||||||
"github.com/txix-open/isp-kit/metrics/sql_metrics"
|
"github.com/txix-open/isp-kit/metrics/sql_metrics"
|
||||||
"msp-admin-service/entity"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Audit struct {
|
type Audit struct {
|
||||||
@@ -43,35 +47,44 @@ func (r Audit) Insert(ctx context.Context, log entity.Audit) (int, error) {
|
|||||||
return id, nil
|
return id, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint:gosec
|
func (r Audit) AllByRequest(ctx context.Context, req domain.AuditPageRequest) ([]entity.Audit, error) {
|
||||||
func (r Audit) All(ctx context.Context, limit int, offset int) ([]entity.Audit, error) {
|
|
||||||
ctx = sql_metrics.OperationLabelToContext(ctx, "Audit.All")
|
ctx = sql_metrics.OperationLabelToContext(ctx, "Audit.All")
|
||||||
|
|
||||||
query, args, err := query.New().
|
q := query.New().
|
||||||
Select("*").
|
Select("*").
|
||||||
From("audit").
|
From("audit").
|
||||||
OrderBy("created_at DESC").
|
OrderBy(strcase.ToSnake(req.Order.Field) + " " + req.Order.Type).
|
||||||
Offset(uint64(offset)).
|
Offset(req.Offset).
|
||||||
Limit(uint64(limit)).
|
Limit(req.Limit)
|
||||||
ToSql()
|
|
||||||
|
query, args, err := reqAuditQuery(q, req.Query).ToSql()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessage(err, "build query")
|
return nil, errors.WithMessage(err, "build query")
|
||||||
}
|
}
|
||||||
|
|
||||||
tokens := make([]entity.Audit, 0)
|
logs := make([]entity.Audit, 0)
|
||||||
err = r.db.Select(ctx, &tokens, query, args...)
|
err = r.db.Select(ctx, &logs, query, args...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessagef(err, "select query: %s", query)
|
return nil, errors.WithMessagef(err, "select query: %s", query)
|
||||||
}
|
}
|
||||||
|
|
||||||
return tokens, nil
|
return logs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r Audit) Count(ctx context.Context) (int64, error) {
|
func (r Audit) Count(ctx context.Context, reqQuery *domain.AuditQuery) (int64, error) {
|
||||||
ctx = sql_metrics.OperationLabelToContext(ctx, "Audit.Count")
|
ctx = sql_metrics.OperationLabelToContext(ctx, "Audit.Count")
|
||||||
|
|
||||||
|
q := query.New().
|
||||||
|
Select("count(*)").
|
||||||
|
From("audit")
|
||||||
|
|
||||||
|
query, args, err := reqAuditQuery(q, reqQuery).ToSql()
|
||||||
|
if err != nil {
|
||||||
|
return 0, errors.WithMessage(err, "build query")
|
||||||
|
}
|
||||||
|
|
||||||
count := int64(0)
|
count := int64(0)
|
||||||
err := r.db.SelectRow(ctx, &count, "select count(*) from audit")
|
err = r.db.SelectRow(ctx, &count, query, args...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, errors.WithMessage(err, "select count")
|
return 0, errors.WithMessage(err, "select count")
|
||||||
}
|
}
|
||||||
@@ -96,3 +109,28 @@ func (r Audit) DeleteUpToCreatedAt(ctx context.Context, createdAt time.Time) err
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func reqAuditQuery(q squirrel.SelectBuilder, reqQuery *domain.AuditQuery) squirrel.SelectBuilder {
|
||||||
|
if reqQuery == nil {
|
||||||
|
return q
|
||||||
|
}
|
||||||
|
|
||||||
|
if reqQuery.Id != nil {
|
||||||
|
q = q.Where("id = ?", *reqQuery.Id)
|
||||||
|
}
|
||||||
|
|
||||||
|
if reqQuery.UserId != nil {
|
||||||
|
q = q.Where("user_id = ?", *reqQuery.UserId)
|
||||||
|
}
|
||||||
|
|
||||||
|
if reqQuery.Message != nil {
|
||||||
|
q = q.Where(squirrel.ILike{"message": "%" + *reqQuery.Message + "%"})
|
||||||
|
}
|
||||||
|
|
||||||
|
if reqQuery.CreatedAt != nil {
|
||||||
|
q = q.Where(squirrel.GtOrEq{"created_at": reqQuery.CreatedAt.From}).
|
||||||
|
Where(squirrel.Lt{"created_at": reqQuery.CreatedAt.To})
|
||||||
|
}
|
||||||
|
|
||||||
|
return q
|
||||||
|
}
|
||||||
@@ -1,105 +0,0 @@
|
|||||||
package ldap
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
"net"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/go-ldap/ldap/v3"
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"msp-admin-service/conf"
|
|
||||||
"msp-admin-service/domain"
|
|
||||||
"msp-admin-service/entity"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
dialTimeout = 5 * time.Second
|
|
||||||
)
|
|
||||||
|
|
||||||
type Repository struct {
|
|
||||||
baseDn string
|
|
||||||
conn *ldap.Conn
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewRepository(config *conf.Ldap) (*Repository, error) {
|
|
||||||
if config == nil {
|
|
||||||
return nil, errors.New("ldap config is not initialized")
|
|
||||||
}
|
|
||||||
|
|
||||||
c, err := net.DialTimeout("tcp", config.Address, dialTimeout)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.WithMessagef(err, "net dial to %s", config.Address)
|
|
||||||
}
|
|
||||||
|
|
||||||
conn := ldap.NewConn(c, false)
|
|
||||||
conn.Start()
|
|
||||||
|
|
||||||
err = conn.Bind(config.Username, config.Password)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.WithMessagef(err, "ldap auth, username: %s", config.Username)
|
|
||||||
}
|
|
||||||
|
|
||||||
return &Repository{
|
|
||||||
conn: conn,
|
|
||||||
baseDn: config.BaseDn,
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r Repository) IsExist(ctx context.Context, dn string) (bool, error) {
|
|
||||||
request := ldap.NewSearchRequest(
|
|
||||||
dn,
|
|
||||||
ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false,
|
|
||||||
"(objectClass=*)",
|
|
||||||
[]string{"name"},
|
|
||||||
nil,
|
|
||||||
)
|
|
||||||
result, err := r.conn.Search(request)
|
|
||||||
if err != nil {
|
|
||||||
return false, errors.WithMessage(err, "search by full dn")
|
|
||||||
}
|
|
||||||
return len(result.Entries) > 0, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r Repository) DnByUserPrincipalName(ctx context.Context, principalName string) (string, error) {
|
|
||||||
filter := fmt.Sprintf("(&(userPrincipalName=%s))", principalName)
|
|
||||||
request := ldap.NewSearchRequest(
|
|
||||||
r.baseDn, // The base dn to search
|
|
||||||
ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false,
|
|
||||||
filter,
|
|
||||||
[]string{"name"},
|
|
||||||
nil,
|
|
||||||
)
|
|
||||||
result, err := r.conn.Search(request)
|
|
||||||
if err != nil {
|
|
||||||
return "", errors.WithMessagef(err, "search by '%s'", filter)
|
|
||||||
}
|
|
||||||
if len(result.Entries) == 0 {
|
|
||||||
return "", errors.Errorf("not found entities by principalName: %s", principalName)
|
|
||||||
}
|
|
||||||
|
|
||||||
return result.Entries[0].DN, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r Repository) ModifyMemberAttr(ctx context.Context, userDn string, groupDn string, operation string) error {
|
|
||||||
modifyReq := ldap.NewModifyRequest(groupDn, nil)
|
|
||||||
switch operation {
|
|
||||||
case entity.GroupOperationAdd:
|
|
||||||
modifyReq.Add("member", []string{userDn})
|
|
||||||
case entity.GroupOperationDelete:
|
|
||||||
modifyReq.Delete("member", []string{userDn})
|
|
||||||
}
|
|
||||||
|
|
||||||
err := r.conn.Modify(modifyReq)
|
|
||||||
if ldap.IsErrorAnyOf(err, ldap.LDAPResultUnwillingToPerform, ldap.LDAPResultEntryAlreadyExists) {
|
|
||||||
return errors.WithMessage(domain.ErrNoActionRequired, err.Error())
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessagef(err, "modify entity by dn %s, operation: %s member from group", groupDn, operation)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r Repository) Close() error {
|
|
||||||
return errors.WithMessage(r.conn.Close(), "close ldap connection")
|
|
||||||
}
|
|
||||||
+2
-2
@@ -25,7 +25,7 @@ func NewSudir(httpCli *httpcli.Client, cfg *conf.SudirAuth) Sudir {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s Sudir) GetToken(ctx context.Context, authCode string) (*entity.SudirTokenResponse, error) {
|
func (s Sudir) GetToken(ctx context.Context, authCode string) (*entity.SudirTokenResponse, error) {
|
||||||
urlString, err := url.JoinPath(s.cfg.Host, "/blitz/oauth/te")
|
urlString, err := url.JoinPath(s.cfg.Host, "/oauth/te")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessage(err, "build url")
|
return nil, errors.WithMessage(err, "build url")
|
||||||
}
|
}
|
||||||
@@ -56,7 +56,7 @@ func (s Sudir) GetToken(ctx context.Context, authCode string) (*entity.SudirToke
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s Sudir) GetUser(ctx context.Context, accessToken string) (*entity.SudirUserResponse, error) {
|
func (s Sudir) GetUser(ctx context.Context, accessToken string) (*entity.SudirUserResponse, error) {
|
||||||
urlString, err := url.JoinPath(s.cfg.Host, "/blitz/oauth/me")
|
urlString, err := url.JoinPath(s.cfg.Host, "/oauth/me")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessage(err, "build url")
|
return nil, errors.WithMessage(err, "build url")
|
||||||
}
|
}
|
||||||
|
|||||||
+96
-39
@@ -3,15 +3,19 @@ package repository
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Masterminds/squirrel"
|
"github.com/Masterminds/squirrel"
|
||||||
|
"github.com/iancoleman/strcase"
|
||||||
|
|
||||||
|
"msp-admin-service/domain"
|
||||||
|
"msp-admin-service/entity"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/txix-open/isp-kit/db"
|
"github.com/txix-open/isp-kit/db"
|
||||||
"github.com/txix-open/isp-kit/db/query"
|
"github.com/txix-open/isp-kit/db/query"
|
||||||
"github.com/txix-open/isp-kit/metrics/sql_metrics"
|
"github.com/txix-open/isp-kit/metrics/sql_metrics"
|
||||||
"msp-admin-service/domain"
|
|
||||||
"msp-admin-service/entity"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Token struct {
|
type Token struct {
|
||||||
@@ -76,17 +80,34 @@ func (r Token) RevokeByUserId(ctx context.Context, userId int64, updatedAt time.
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint:gosec
|
func (r Token) All(ctx context.Context) ([]entity.Token, error) {
|
||||||
func (r Token) All(ctx context.Context, limit int, offset int) ([]entity.Token, error) {
|
|
||||||
ctx = sql_metrics.OperationLabelToContext(ctx, "Token.All")
|
ctx = sql_metrics.OperationLabelToContext(ctx, "Token.All")
|
||||||
|
|
||||||
query, args, err := query.New().
|
query, args, err := query.New().Select("*").From("tokens").ToSql()
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.WithMessage(err, "build query")
|
||||||
|
}
|
||||||
|
|
||||||
|
tokens := make([]entity.Token, 0)
|
||||||
|
err = r.db.Select(ctx, &tokens, query, args...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.WithMessagef(err, "select query %s", query)
|
||||||
|
}
|
||||||
|
|
||||||
|
return tokens, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r Token) AllByRequest(ctx context.Context, req domain.SessionPageRequest) ([]entity.Token, error) {
|
||||||
|
ctx = sql_metrics.OperationLabelToContext(ctx, "Token.AllByRequest")
|
||||||
|
|
||||||
|
q := query.New().
|
||||||
Select("*").
|
Select("*").
|
||||||
From("tokens").
|
From("tokens").
|
||||||
OrderBy("created_at DESC").
|
OrderBy(strcase.ToSnake(req.Order.Field) + " " + req.Order.Type).
|
||||||
Offset(uint64(offset)).
|
Offset(req.Offset).
|
||||||
Limit(uint64(limit)).
|
Limit(req.Limit)
|
||||||
ToSql()
|
|
||||||
|
query, args, err := reqTokenQuery(q, req.Query).ToSql()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessage(err, "build query")
|
return nil, errors.WithMessage(err, "build query")
|
||||||
}
|
}
|
||||||
@@ -114,11 +135,40 @@ func (r Token) UpdateStatus(ctx context.Context, id int, status string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r Token) Count(ctx context.Context) (int64, error) {
|
func (r Token) SetExpiredStatusByIds(ctx context.Context, ids []int) error {
|
||||||
|
ctx = sql_metrics.OperationLabelToContext(ctx, "Token.SetExpiredStatusByIds")
|
||||||
|
|
||||||
|
query, args, err := query.New().
|
||||||
|
Update("tokens").
|
||||||
|
Set("status", entity.TokenStatusExpired).
|
||||||
|
Where(squirrel.Eq{"id": ids}).
|
||||||
|
ToSql()
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "build query")
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = r.db.Exec(ctx, query, args...)
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "set tokens expired status")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r Token) Count(ctx context.Context, reqQuery *domain.SessionQuery) (int64, error) {
|
||||||
ctx = sql_metrics.OperationLabelToContext(ctx, "Token.Count")
|
ctx = sql_metrics.OperationLabelToContext(ctx, "Token.Count")
|
||||||
|
|
||||||
|
q := query.New().
|
||||||
|
Select("count(*)").
|
||||||
|
From("tokens")
|
||||||
|
|
||||||
|
query, args, err := reqTokenQuery(q, reqQuery).ToSql()
|
||||||
|
if err != nil {
|
||||||
|
return 0, errors.WithMessage(err, "build query")
|
||||||
|
}
|
||||||
|
|
||||||
count := int64(0)
|
count := int64(0)
|
||||||
err := r.db.SelectRow(ctx, &count, "select count(*) from tokens")
|
err = r.db.SelectRow(ctx, &count, query, args...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, errors.WithMessage(err, "select count")
|
return 0, errors.WithMessage(err, "select count")
|
||||||
}
|
}
|
||||||
@@ -139,33 +189,10 @@ func (r Token) UpdateStatusByUserId(ctx context.Context, userId int, status stri
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r Token) LastAccessNotBlockedUsers(ctx context.Context) (map[int64]time.Time, error) {
|
|
||||||
ctx = sql_metrics.OperationLabelToContext(ctx, "Token.LastAccessNotBlockedUsers")
|
|
||||||
|
|
||||||
query := `
|
|
||||||
select t.user_id, max(t.created_at) as created_at from tokens t
|
|
||||||
join users u on t.user_id = u.id
|
|
||||||
where u.blocked = false
|
|
||||||
group by t.user_id
|
|
||||||
`
|
|
||||||
tokens := make([]entity.Token, 0)
|
|
||||||
err := r.db.Select(ctx, &tokens, query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.WithMessagef(err, "select query: %s", query)
|
|
||||||
}
|
|
||||||
|
|
||||||
result := make(map[int64]time.Time, 0)
|
|
||||||
for _, token := range tokens {
|
|
||||||
result[token.UserId] = token.CreatedAt
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r Token) LastAccessByUserIds(ctx context.Context, userIds []int) (map[int64]*time.Time, error) {
|
func (r Token) LastAccessByUserIds(ctx context.Context, userIds []int) (map[int64]*time.Time, error) {
|
||||||
ctx = sql_metrics.OperationLabelToContext(ctx, "Token.LastAccessNotBlockedUsers")
|
ctx = sql_metrics.OperationLabelToContext(ctx, "Token.LastAccessByUserIds")
|
||||||
|
|
||||||
q, args, err := query.New().
|
query, args, err := query.New().
|
||||||
Select("user_id", "max(created_at) as created_at").
|
Select("user_id", "max(created_at) as created_at").
|
||||||
From("tokens").
|
From("tokens").
|
||||||
Where(squirrel.Eq{"user_id": userIds}).
|
Where(squirrel.Eq{"user_id": userIds}).
|
||||||
@@ -176,12 +203,12 @@ func (r Token) LastAccessByUserIds(ctx context.Context, userIds []int) (map[int6
|
|||||||
}
|
}
|
||||||
|
|
||||||
tokens := make([]entity.Token, 0)
|
tokens := make([]entity.Token, 0)
|
||||||
err = r.db.Select(ctx, &tokens, q, args...)
|
err = r.db.Select(ctx, &tokens, query, args...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessagef(err, "select query: %s", q)
|
return nil, errors.WithMessagef(err, "select query: %s", query)
|
||||||
}
|
}
|
||||||
|
|
||||||
result := make(map[int64]*time.Time, 0)
|
result := make(map[int64]*time.Time)
|
||||||
for _, token := range tokens {
|
for _, token := range tokens {
|
||||||
createdAt := token.CreatedAt
|
createdAt := token.CreatedAt
|
||||||
result[token.UserId] = &createdAt
|
result[token.UserId] = &createdAt
|
||||||
@@ -189,3 +216,33 @@ func (r Token) LastAccessByUserIds(ctx context.Context, userIds []int) (map[int6
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func reqTokenQuery(q squirrel.SelectBuilder, reqQuery *domain.SessionQuery) squirrel.SelectBuilder {
|
||||||
|
if reqQuery == nil {
|
||||||
|
return q
|
||||||
|
}
|
||||||
|
|
||||||
|
if reqQuery.Id != nil {
|
||||||
|
q = q.Where(squirrel.ILike{"id::text": strconv.Itoa(*reqQuery.Id) + "%"})
|
||||||
|
}
|
||||||
|
|
||||||
|
if reqQuery.UserId != nil {
|
||||||
|
q = q.Where("user_id = ?", *reqQuery.UserId)
|
||||||
|
}
|
||||||
|
|
||||||
|
if reqQuery.Status != nil {
|
||||||
|
q = q.Where("status = ?", *reqQuery.Status)
|
||||||
|
}
|
||||||
|
|
||||||
|
if reqQuery.CreatedAt != nil {
|
||||||
|
q = q.Where(squirrel.GtOrEq{"created_at": reqQuery.CreatedAt.From}).
|
||||||
|
Where(squirrel.Lt{"created_at": reqQuery.CreatedAt.To})
|
||||||
|
}
|
||||||
|
|
||||||
|
if reqQuery.ExpiredAt != nil {
|
||||||
|
q = q.Where(squirrel.GtOrEq{"expired_at": reqQuery.ExpiredAt.From}).
|
||||||
|
Where(squirrel.Lt{"expired_at": reqQuery.ExpiredAt.To})
|
||||||
|
}
|
||||||
|
|
||||||
|
return q
|
||||||
|
}
|
||||||
+142
-23
@@ -3,14 +3,18 @@ package repository
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
"strconv"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"msp-admin-service/domain"
|
||||||
|
"msp-admin-service/entity"
|
||||||
|
|
||||||
"github.com/Masterminds/squirrel"
|
"github.com/Masterminds/squirrel"
|
||||||
|
"github.com/iancoleman/strcase"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/txix-open/isp-kit/db"
|
"github.com/txix-open/isp-kit/db"
|
||||||
"github.com/txix-open/isp-kit/db/query"
|
"github.com/txix-open/isp-kit/db/query"
|
||||||
"github.com/txix-open/isp-kit/metrics/sql_metrics"
|
"github.com/txix-open/isp-kit/metrics/sql_metrics"
|
||||||
"msp-admin-service/domain"
|
|
||||||
"msp-admin-service/entity"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type User struct {
|
type User struct {
|
||||||
@@ -71,15 +75,46 @@ func (u User) GetUserById(ctx context.Context, identity int64) (*entity.User, er
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (u User) GetUserByEmailAndSudirId(ctx context.Context, email string, sudirUserId string) (*entity.User, error) {
|
||||||
|
ctx = sql_metrics.OperationLabelToContext(ctx, "User.GetUserByEmail")
|
||||||
|
|
||||||
|
equalClause := squirrel.Eq{"email": email, "sudir_user_id": nil}
|
||||||
|
if sudirUserId != "" {
|
||||||
|
equalClause["sudir_user_id"] = sudirUserId
|
||||||
|
}
|
||||||
|
|
||||||
|
q, args, err := query.New().
|
||||||
|
Select("*").
|
||||||
|
From("users").
|
||||||
|
Where(equalClause).
|
||||||
|
ToSql()
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.WithMessage(err, "build query")
|
||||||
|
}
|
||||||
|
|
||||||
|
user := entity.User{}
|
||||||
|
err = u.db.SelectRow(ctx, &user, q, args...)
|
||||||
|
|
||||||
|
switch {
|
||||||
|
case errors.Is(err, sql.ErrNoRows):
|
||||||
|
return nil, domain.ErrNotFound
|
||||||
|
case err != nil:
|
||||||
|
return nil, errors.WithMessage(err, "db select")
|
||||||
|
default:
|
||||||
|
return &user, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (u User) UpsertBySudirUserId(ctx context.Context, user entity.User) (*entity.User, error) {
|
func (u User) UpsertBySudirUserId(ctx context.Context, user entity.User) (*entity.User, error) {
|
||||||
ctx = sql_metrics.OperationLabelToContext(ctx, "User.UpsertBySudirUserId")
|
ctx = sql_metrics.OperationLabelToContext(ctx, "User.UpsertBySudirUserId")
|
||||||
|
|
||||||
selectQ := `
|
selectQ := `
|
||||||
insert into users as u (first_name, last_name, email, created_at, updated_at, sudir_user_id)
|
insert into users as u (first_name, last_name, full_name, email, created_at, updated_at, sudir_user_id)
|
||||||
values ($1, $2, $3, $4, $5, $6)
|
values ($1, $2, $3, $4, $5, $6, $7)
|
||||||
on conflict (sudir_user_id) do update
|
on conflict (sudir_user_id) do update
|
||||||
set first_name = excluded.first_name,
|
set first_name = excluded.first_name,
|
||||||
last_name = excluded.last_name,
|
last_name = excluded.last_name,
|
||||||
|
full_name = excluded.full_name,
|
||||||
email = excluded.email,
|
email = excluded.email,
|
||||||
updated_at = excluded.updated_at
|
updated_at = excluded.updated_at
|
||||||
where u.blocked = false
|
where u.blocked = false
|
||||||
@@ -89,7 +124,7 @@ func (u User) UpsertBySudirUserId(ctx context.Context, user entity.User) (*entit
|
|||||||
err := u.db.SelectRow(ctx,
|
err := u.db.SelectRow(ctx,
|
||||||
&result,
|
&result,
|
||||||
selectQ,
|
selectQ,
|
||||||
user.FirstName, user.LastName, user.Email, user.CreatedAt, user.UpdatedAt, user.SudirUserId,
|
user.FirstName, user.LastName, user.FullName, user.Email, user.CreatedAt, user.UpdatedAt, user.SudirUserId,
|
||||||
)
|
)
|
||||||
if errors.Is(err, sql.ErrNoRows) {
|
if errors.Is(err, sql.ErrNoRows) {
|
||||||
return nil, domain.ErrUserIsBlocked
|
return nil, domain.ErrUserIsBlocked
|
||||||
@@ -101,31 +136,28 @@ func (u User) UpsertBySudirUserId(ctx context.Context, user entity.User) (*entit
|
|||||||
return &result, nil
|
return &result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint:gosec
|
func (u User) GetUsers(ctx context.Context, req domain.UsersPageRequest) ([]entity.User, error) {
|
||||||
func (u User) GetUsers(ctx context.Context, ids []int64, offset, limit int, email string) ([]entity.User, error) {
|
|
||||||
ctx = sql_metrics.OperationLabelToContext(ctx, "User.GetUsers")
|
ctx = sql_metrics.OperationLabelToContext(ctx, "User.GetUsers")
|
||||||
|
|
||||||
q := query.New().
|
q := query.New().
|
||||||
Select("*").
|
Select("*", "(SELECT max(created_at) FROM tokens WHERE tokens.user_id = users.id) as last_session_created_at").
|
||||||
From("users")
|
From("users").
|
||||||
|
Offset(req.Offset).
|
||||||
|
Limit(req.Limit)
|
||||||
|
|
||||||
if len(ids) > 0 {
|
if req.Order.Field == "userId" {
|
||||||
q = q.Where(squirrel.Eq{"id": ids})
|
q = q.OrderBy("full_name " + req.Order.Type)
|
||||||
|
} else {
|
||||||
|
q = q.OrderBy(strcase.ToSnake(req.Order.Field) + " " + req.Order.Type)
|
||||||
}
|
}
|
||||||
if email != "" {
|
|
||||||
q = q.Where("email LIKE ?", "%"+email+"%")
|
query, args, err := reqUsersQuery(q, req.Query).ToSql()
|
||||||
}
|
|
||||||
qstring, args, err := q.
|
|
||||||
Limit(uint64(limit)).
|
|
||||||
Offset(uint64(offset)).
|
|
||||||
OrderBy("created_at DESC").
|
|
||||||
ToSql()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessage(err, "build query")
|
return nil, errors.WithMessage(err, "build query")
|
||||||
}
|
}
|
||||||
|
|
||||||
users := make([]entity.User, 0)
|
users := make([]entity.User, 0)
|
||||||
err = u.db.Select(ctx, &users, qstring, args...)
|
err = u.db.Select(ctx, &users, query, args...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessage(err, "db select")
|
return nil, errors.WithMessage(err, "db select")
|
||||||
}
|
}
|
||||||
@@ -133,14 +165,39 @@ func (u User) GetUsers(ctx context.Context, ids []int64, offset, limit int, emai
|
|||||||
return users, nil
|
return users, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (u User) GetUsersByEmail(ctx context.Context, email string) ([]entity.User, error) {
|
||||||
|
ctx = sql_metrics.OperationLabelToContext(ctx, "User.GetUserByEmail")
|
||||||
|
|
||||||
|
q, args, err := query.New().
|
||||||
|
Select("*").
|
||||||
|
From("users").
|
||||||
|
Where(squirrel.Eq{"email": email}).
|
||||||
|
ToSql()
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.WithMessage(err, "build query")
|
||||||
|
}
|
||||||
|
|
||||||
|
users := make([]entity.User, 0)
|
||||||
|
err = u.db.Select(ctx, &users, q, args...)
|
||||||
|
|
||||||
|
switch {
|
||||||
|
case errors.Is(err, sql.ErrNoRows) || len(users) == 0:
|
||||||
|
return nil, domain.ErrNotFound
|
||||||
|
case err != nil:
|
||||||
|
return nil, errors.WithMessage(err, "db select")
|
||||||
|
default:
|
||||||
|
return users, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (u User) Insert(ctx context.Context, user entity.User) (int, error) {
|
func (u User) Insert(ctx context.Context, user entity.User) (int, error) {
|
||||||
ctx = sql_metrics.OperationLabelToContext(ctx, "User.Insert")
|
ctx = sql_metrics.OperationLabelToContext(ctx, "User.Insert")
|
||||||
|
|
||||||
insertQ, args, err := query.New().
|
insertQ, args, err := query.New().
|
||||||
Insert("users").
|
Insert("users").
|
||||||
Columns("first_name", "last_name", "description",
|
Columns("first_name", "last_name", "full_name", "description",
|
||||||
"email", "password", "created_at", "updated_at").
|
"email", "password", "created_at", "updated_at").
|
||||||
Values(user.FirstName, user.LastName, user.Description,
|
Values(user.FirstName, user.LastName, user.FullName, user.Description,
|
||||||
user.Email, user.Password, user.CreatedAt, user.UpdatedAt).
|
user.Email, user.Password, user.CreatedAt, user.UpdatedAt).
|
||||||
Suffix("returning id").
|
Suffix("returning id").
|
||||||
ToSql()
|
ToSql()
|
||||||
@@ -166,11 +223,12 @@ func (u User) UpdateUser(ctx context.Context, id int64, user entity.UpdateUser)
|
|||||||
SetMap(map[string]interface{}{
|
SetMap(map[string]interface{}{
|
||||||
"first_name": user.FirstName,
|
"first_name": user.FirstName,
|
||||||
"last_name": user.LastName,
|
"last_name": user.LastName,
|
||||||
|
"full_name": user.FullName,
|
||||||
"email": user.Email,
|
"email": user.Email,
|
||||||
"description": user.Description,
|
"description": user.Description,
|
||||||
}).
|
}).
|
||||||
Where(squirrel.Eq{"id": id}).
|
Where(squirrel.Eq{"id": id}).
|
||||||
Suffix("RETURNING id, first_name, last_name, email, sudir_user_id, description, created_at, updated_at").
|
Suffix("RETURNING id, first_name, last_name, full_name, email, sudir_user_id, description, created_at, updated_at").
|
||||||
ToSql()
|
ToSql()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessage(err, "build query")
|
return nil, errors.WithMessage(err, "build query")
|
||||||
@@ -233,6 +291,32 @@ func (u User) Block(ctx context.Context, userId int) (*entity.User, error) {
|
|||||||
return &user, nil
|
return &user, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (u User) LastAccessNotBlockedUsers(ctx context.Context) (map[int64]time.Time, error) {
|
||||||
|
ctx = sql_metrics.OperationLabelToContext(ctx, "User.LastAccessNotBlockedUsers")
|
||||||
|
|
||||||
|
q, args, err := query.New().
|
||||||
|
Select("id, last_active_at").
|
||||||
|
From("users").
|
||||||
|
Where(squirrel.Eq{"blocked": false}).
|
||||||
|
ToSql()
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.WithMessage(err, "build query")
|
||||||
|
}
|
||||||
|
|
||||||
|
users := make([]entity.User, 0)
|
||||||
|
err = u.db.Select(ctx, &users, q, args...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.WithMessagef(err, "select query: %s", q)
|
||||||
|
}
|
||||||
|
|
||||||
|
result := make(map[int64]time.Time, 0)
|
||||||
|
for _, user := range users {
|
||||||
|
result[user.Id] = user.LastActiveAt
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (u User) ChangePassword(ctx context.Context, userId int64, newPassword string) error {
|
func (u User) ChangePassword(ctx context.Context, userId int64, newPassword string) error {
|
||||||
ctx = sql_metrics.OperationLabelToContext(ctx, "User.ChangePassword")
|
ctx = sql_metrics.OperationLabelToContext(ctx, "User.ChangePassword")
|
||||||
|
|
||||||
@@ -252,3 +336,38 @@ func (u User) ChangePassword(ctx context.Context, userId int64, newPassword stri
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (u User) UpdateLastActiveAt(ctx context.Context, userId int64, lastActiveAt time.Time) error {
|
||||||
|
ctx = sql_metrics.OperationLabelToContext(ctx, "User.UpdateLastActiveAt")
|
||||||
|
|
||||||
|
q := "update users set last_active_at = $1 where id = $2"
|
||||||
|
_, err := u.db.Exec(ctx, q, lastActiveAt, userId)
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessagef(err, "user.repo.UpdateLastActiveAt: exec query: %s", q)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func reqUsersQuery(q squirrel.SelectBuilder, reqQuery *domain.UserQuery) squirrel.SelectBuilder {
|
||||||
|
if reqQuery == nil {
|
||||||
|
return q
|
||||||
|
}
|
||||||
|
|
||||||
|
if reqQuery.Id != nil {
|
||||||
|
q = q.Where(squirrel.ILike{"id::text": strconv.Itoa(*reqQuery.Id) + "%"})
|
||||||
|
}
|
||||||
|
|
||||||
|
if reqQuery.UserId != nil { // поиск в ui по фио, но в бд - по id юзера
|
||||||
|
q = q.Where("id = ?", *reqQuery.UserId)
|
||||||
|
}
|
||||||
|
|
||||||
|
if reqQuery.Description != nil {
|
||||||
|
q = q.Where(squirrel.ILike{"description": "%" + *reqQuery.Description + "%"})
|
||||||
|
}
|
||||||
|
|
||||||
|
if reqQuery.Email != nil {
|
||||||
|
q = q.Where(squirrel.ILike{"email": "%" + *reqQuery.Email + "%"})
|
||||||
|
}
|
||||||
|
|
||||||
|
return q
|
||||||
|
}
|
||||||
@@ -49,6 +49,11 @@ func endpointDescriptors(c Controllers) []cluster.EndpointDescriptor {
|
|||||||
Inner: true,
|
Inner: true,
|
||||||
Handler: c.Auth.Logout,
|
Handler: c.Auth.Logout,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Path: "admin/auth/logout_with_reason",
|
||||||
|
Inner: true,
|
||||||
|
Handler: c.Auth.LogoutWithReason,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Path: "admin/user/get_profile",
|
Path: "admin/user/get_profile",
|
||||||
Inner: true,
|
Inner: true,
|
||||||
|
|||||||
+21
-17
@@ -4,18 +4,19 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/txix-open/isp-kit/log"
|
|
||||||
"golang.org/x/sync/errgroup"
|
|
||||||
"msp-admin-service/conf"
|
"msp-admin-service/conf"
|
||||||
"msp-admin-service/domain"
|
"msp-admin-service/domain"
|
||||||
"msp-admin-service/entity"
|
"msp-admin-service/entity"
|
||||||
|
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"github.com/txix-open/isp-kit/log"
|
||||||
|
"golang.org/x/sync/errgroup"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AuditRepository interface {
|
type AuditRepository interface {
|
||||||
Insert(ctx context.Context, log entity.Audit) (int, error)
|
Insert(ctx context.Context, log entity.Audit) (int, error)
|
||||||
All(ctx context.Context, limit int, offset int) ([]entity.Audit, error)
|
AllByRequest(ctx context.Context, req domain.AuditPageRequest) ([]entity.Audit, error)
|
||||||
Count(ctx context.Context) (int64, error)
|
Count(ctx context.Context, reqQuery *domain.AuditQuery) (int64, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type AuditEventRepository interface {
|
type AuditEventRepository interface {
|
||||||
@@ -45,6 +46,7 @@ func NewAudit(
|
|||||||
entity.EventSuccessLogout: true,
|
entity.EventSuccessLogout: true,
|
||||||
entity.EventRoleChanged: true,
|
entity.EventRoleChanged: true,
|
||||||
entity.EventUserChanged: true,
|
entity.EventUserChanged: true,
|
||||||
|
entity.EventUserBlocked: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
eventName := make(map[string]conf.AuditEventSetting)
|
eventName := make(map[string]conf.AuditEventSetting)
|
||||||
@@ -92,37 +94,39 @@ func (s Audit) SaveAuditAsync(ctx context.Context, userId int64, message string,
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s Audit) All(ctx context.Context, limit int, offset int) (*domain.AuditResponse, error) {
|
func (s Audit) All(ctx context.Context, req domain.AuditPageRequest) (*domain.AuditResponse, error) {
|
||||||
group, ctx := errgroup.WithContext(ctx)
|
var logs []entity.Audit
|
||||||
var tokens []entity.Audit
|
|
||||||
var total int64
|
var total int64
|
||||||
var err error
|
|
||||||
|
group, ctx := errgroup.WithContext(ctx)
|
||||||
group.Go(func() error {
|
group.Go(func() error {
|
||||||
tokens, err = s.auditRep.All(ctx, limit, offset)
|
var err error
|
||||||
|
logs, err = s.auditRep.AllByRequest(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessage(err, "get all audit")
|
return errors.WithMessage(err, "get all audit")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
group.Go(func() error {
|
group.Go(func() error {
|
||||||
total, err = s.auditRep.Count(ctx)
|
var err error
|
||||||
|
total, err = s.auditRep.Count(ctx, req.Query)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessage(err, "count all audit")
|
return errors.WithMessage(err, "count all audit")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
err = group.Wait()
|
err := group.Wait()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessage(err, "wait workers")
|
return nil, errors.WithMessage(err, "wait workers")
|
||||||
}
|
}
|
||||||
|
|
||||||
items := make([]domain.Audit, 0)
|
items := make([]domain.Audit, 0)
|
||||||
for _, token := range tokens {
|
for _, log := range logs {
|
||||||
items = append(items, domain.Audit{
|
items = append(items, domain.Audit{
|
||||||
Id: token.Id,
|
Id: log.Id,
|
||||||
UserId: token.UserId,
|
UserId: log.UserId,
|
||||||
Message: token.Message,
|
Message: log.Message,
|
||||||
CreatedAt: token.CreatedAt,
|
CreatedAt: log.CreatedAt,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
result := domain.AuditResponse{
|
result := domain.AuditResponse{
|
||||||
|
|||||||
+40
-8
@@ -5,11 +5,12 @@ import (
|
|||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"msp-admin-service/domain"
|
||||||
|
"msp-admin-service/entity"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/txix-open/isp-kit/log"
|
"github.com/txix-open/isp-kit/log"
|
||||||
"golang.org/x/crypto/bcrypt"
|
"golang.org/x/crypto/bcrypt"
|
||||||
"msp-admin-service/domain"
|
|
||||||
"msp-admin-service/entity"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type AuthTransaction interface {
|
type AuthTransaction interface {
|
||||||
@@ -31,6 +32,7 @@ type userRepository interface {
|
|||||||
GetUserByEmail(ctx context.Context, email string) (*entity.User, error)
|
GetUserByEmail(ctx context.Context, email string) (*entity.User, error)
|
||||||
UpsertBySudirUserId(ctx context.Context, user entity.User) (*entity.User, error)
|
UpsertBySudirUserId(ctx context.Context, user entity.User) (*entity.User, error)
|
||||||
UpdateUser(ctx context.Context, id int64, user entity.UpdateUser) (*entity.User, error)
|
UpdateUser(ctx context.Context, id int64, user entity.UpdateUser) (*entity.User, error)
|
||||||
|
UpdateLastActiveAt(ctx context.Context, userId int64, lastActiveAt time.Time) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type tokenService interface {
|
type tokenService interface {
|
||||||
@@ -118,6 +120,12 @@ func (a Auth) Login(ctx context.Context, request domain.LoginRequest) (*domain.L
|
|||||||
return errors.WithMessage(err, "generate token")
|
return errors.WithMessage(err, "generate token")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lastActiveAt := time.Now().UTC()
|
||||||
|
err = tx.UpdateLastActiveAt(ctx, user.Id, lastActiveAt)
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "update user last_active_at")
|
||||||
|
}
|
||||||
|
|
||||||
a.auditService.SaveAuditAsync(ctx, user.Id, "Успешный вход через форму входа", entity.EventSuccessLogin)
|
a.auditService.SaveAuditAsync(ctx, user.Id, "Успешный вход через форму входа", entity.EventSuccessLogin)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -162,6 +170,7 @@ func (a Auth) LoginWithSudir(ctx context.Context, request domain.LoginSudirReque
|
|||||||
SudirUserId: &sudirUser.SudirUserId,
|
SudirUserId: &sudirUser.SudirUserId,
|
||||||
FirstName: sudirUser.FirstName,
|
FirstName: sudirUser.FirstName,
|
||||||
LastName: sudirUser.LastName,
|
LastName: sudirUser.LastName,
|
||||||
|
FullName: sudirUser.FullName,
|
||||||
Email: sudirUser.Email,
|
Email: sudirUser.Email,
|
||||||
Password: "",
|
Password: "",
|
||||||
Blocked: false,
|
Blocked: false,
|
||||||
@@ -185,6 +194,12 @@ func (a Auth) LoginWithSudir(ctx context.Context, request domain.LoginSudirReque
|
|||||||
return errors.WithMessage(err, "generate token")
|
return errors.WithMessage(err, "generate token")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lastActiveAt := time.Now().UTC()
|
||||||
|
err = tx.UpdateLastActiveAt(ctx, user.Id, lastActiveAt)
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "update user last_active_at")
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -200,13 +215,30 @@ func (a Auth) LoginWithSudir(ctx context.Context, request domain.LoginSudirReque
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Auth) Logout(ctx context.Context, adminId int64) error {
|
func (a Auth) Logout(ctx context.Context, adminId int64, request *domain.LogoutRequest) error {
|
||||||
err := a.tokenService.RevokeAllByUserId(ctx, adminId)
|
err := a.txRunner.AuthTransaction(ctx, func(ctx context.Context, tx AuthTransaction) error {
|
||||||
if err != nil {
|
err := a.tokenService.RevokeAllByUserId(ctx, adminId)
|
||||||
return errors.WithMessage(err, "revoke all tokens by user id")
|
if err != nil {
|
||||||
}
|
return errors.WithMessage(err, "revoke all tokens by user id")
|
||||||
|
}
|
||||||
|
|
||||||
a.auditService.SaveAuditAsync(ctx, adminId, "Выход", entity.EventSuccessLogout)
|
lastActiveAt := time.Now().UTC()
|
||||||
|
err = tx.UpdateLastActiveAt(ctx, adminId, lastActiveAt)
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "update user last_active_at")
|
||||||
|
}
|
||||||
|
|
||||||
|
if request != nil && request.Reason == "idle" {
|
||||||
|
a.auditService.SaveAuditAsync(ctx, adminId, "Выход по бездействию", entity.EventSuccessLogout)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
a.auditService.SaveAuditAsync(ctx, adminId, "Выход", entity.EventSuccessLogout)
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "auth transaction")
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -4,10 +4,12 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"msp-admin-service/conf"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/txix-open/bgjob"
|
"github.com/txix-open/bgjob"
|
||||||
|
"github.com/txix-open/isp-kit/bgjobx/handler"
|
||||||
"github.com/txix-open/isp-kit/log"
|
"github.com/txix-open/isp-kit/log"
|
||||||
"msp-admin-service/conf"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -38,13 +40,13 @@ func NewService(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s Service) Handle(ctx context.Context, _ bgjob.Job) bgjob.Result {
|
func (s Service) Handle(ctx context.Context, _ bgjob.Job) handler.Result {
|
||||||
err := s.deleteOldAudit(ctx)
|
err := s.deleteOldAudit(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return bgjob.Retry(defaultRetryTimeout, errors.WithMessage(err, "sync state with worker"))
|
return handler.Retry(defaultRetryTimeout, errors.WithMessage(err, "sync state with worker"))
|
||||||
}
|
}
|
||||||
|
|
||||||
return bgjob.Reschedule(s.syncPeriod)
|
return handler.Reschedule(handler.ByAfterTime(s.syncPeriod, time.Now()))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s Service) deleteOldAudit(ctx context.Context) error {
|
func (s Service) deleteOldAudit(ctx context.Context) error {
|
||||||
|
|||||||
@@ -4,11 +4,13 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/txix-open/bgjob"
|
|
||||||
"github.com/txix-open/isp-kit/log"
|
|
||||||
"msp-admin-service/conf"
|
"msp-admin-service/conf"
|
||||||
"msp-admin-service/entity"
|
"msp-admin-service/entity"
|
||||||
|
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"github.com/txix-open/bgjob"
|
||||||
|
"github.com/txix-open/isp-kit/bgjobx/handler"
|
||||||
|
"github.com/txix-open/isp-kit/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -19,67 +21,54 @@ type AuditRepo interface {
|
|||||||
SaveAuditAsync(ctx context.Context, userId int64, message string, event string)
|
SaveAuditAsync(ctx context.Context, userId int64, message string, event string)
|
||||||
}
|
}
|
||||||
|
|
||||||
type TokenRepo interface {
|
|
||||||
LastAccessNotBlockedUsers(ctx context.Context) (map[int64]time.Time, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type UserRepo interface {
|
type UserRepo interface {
|
||||||
|
LastAccessNotBlockedUsers(ctx context.Context) (map[int64]time.Time, error)
|
||||||
Block(ctx context.Context, userId int) (*entity.User, error)
|
Block(ctx context.Context, userId int) (*entity.User, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type LdapService interface {
|
|
||||||
SyncGroups(ctx context.Context, user entity.User) error
|
|
||||||
}
|
|
||||||
|
|
||||||
type UserRoleRepo interface {
|
type UserRoleRepo interface {
|
||||||
UpsertUserRoleLinks(ctx context.Context, id int, roleIds []int) error
|
UpsertUserRoleLinks(ctx context.Context, id int, roleIds []int) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type Service struct {
|
type Service struct {
|
||||||
tokenRepo TokenRepo
|
|
||||||
userRepo UserRepo
|
userRepo UserRepo
|
||||||
auditRepo AuditRepo
|
auditRepo AuditRepo
|
||||||
userRoleRepo UserRoleRepo
|
userRoleRepo UserRoleRepo
|
||||||
ldapService LdapService
|
|
||||||
threshold time.Duration
|
threshold time.Duration
|
||||||
syncPeriod time.Duration
|
syncPeriod time.Duration
|
||||||
logger log.Logger
|
logger log.Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewInactiveBlocker(
|
func NewInactiveBlocker(
|
||||||
tokensRepo TokenRepo,
|
|
||||||
userRepo UserRepo,
|
userRepo UserRepo,
|
||||||
auditRepo AuditRepo,
|
auditRepo AuditRepo,
|
||||||
userRoleRepo UserRoleRepo,
|
userRoleRepo UserRoleRepo,
|
||||||
ldapService LdapService,
|
|
||||||
config conf.BlockInactiveWorker,
|
config conf.BlockInactiveWorker,
|
||||||
logger log.Logger,
|
logger log.Logger,
|
||||||
) Service {
|
) Service {
|
||||||
return Service{
|
return Service{
|
||||||
tokenRepo: tokensRepo,
|
|
||||||
userRepo: userRepo,
|
userRepo: userRepo,
|
||||||
auditRepo: auditRepo,
|
auditRepo: auditRepo,
|
||||||
userRoleRepo: userRoleRepo,
|
userRoleRepo: userRoleRepo,
|
||||||
ldapService: ldapService,
|
|
||||||
threshold: time.Duration(config.DaysThreshold) * 24 * time.Hour,
|
threshold: time.Duration(config.DaysThreshold) * 24 * time.Hour,
|
||||||
syncPeriod: time.Minute * time.Duration(config.RunIntervalInMinutes),
|
syncPeriod: time.Minute * time.Duration(config.RunIntervalInMinutes),
|
||||||
logger: logger,
|
logger: logger,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w Service) Handle(ctx context.Context, _ bgjob.Job) bgjob.Result {
|
func (w Service) Handle(ctx context.Context, _ bgjob.Job) handler.Result {
|
||||||
ctx = log.ToContext(ctx, log.String("worker", "inactiveBlocker"))
|
ctx = log.ToContext(ctx, log.String("worker", "inactiveBlocker"))
|
||||||
w.logger.Debug(ctx, "begin work")
|
w.logger.Debug(ctx, "begin work")
|
||||||
err := w.do(ctx)
|
err := w.do(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return bgjob.Retry(defaultRetryTimeout, errors.WithMessage(err, "sync state with worker"))
|
return handler.Retry(defaultRetryTimeout, errors.WithMessage(err, "sync state with worker"))
|
||||||
}
|
}
|
||||||
w.logger.Debug(ctx, "end work")
|
w.logger.Debug(ctx, "end work")
|
||||||
return bgjob.Reschedule(w.syncPeriod)
|
return handler.Reschedule(handler.ByAfterTime(w.syncPeriod, time.Now()))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w Service) do(ctx context.Context) error {
|
func (w Service) do(ctx context.Context) error {
|
||||||
lastAccess, err := w.tokenRepo.LastAccessNotBlockedUsers(ctx)
|
lastAccess, err := w.userRepo.LastAccessNotBlockedUsers(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessage(err, "get last access times")
|
return errors.WithMessage(err, "get last access times")
|
||||||
}
|
}
|
||||||
@@ -92,7 +81,7 @@ func (w Service) do(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
w.logger.Info(ctx, "block inactive user", log.Int64("userId", userId), log.Any("lastAccessTime", lastAccess))
|
w.logger.Info(ctx, "block inactive user", log.Int64("userId", userId), log.Any("lastAccessTime", lastAccess))
|
||||||
user, err := w.userRepo.Block(ctx, int(userId))
|
_, err := w.userRepo.Block(ctx, int(userId))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessagef(err, "block user %d", userId)
|
return errors.WithMessagef(err, "block user %d", userId)
|
||||||
}
|
}
|
||||||
@@ -102,11 +91,6 @@ func (w Service) do(ctx context.Context) error {
|
|||||||
return errors.WithMessage(err, "empty user roles links")
|
return errors.WithMessage(err, "empty user roles links")
|
||||||
}
|
}
|
||||||
|
|
||||||
err = w.ldapService.SyncGroups(ctx, *user)
|
|
||||||
if err != nil {
|
|
||||||
w.logger.Error(ctx, errors.WithMessage(err, "remove ldap groups"))
|
|
||||||
}
|
|
||||||
|
|
||||||
w.auditRepo.SaveAuditAsync(ctx, userId, "Блокировка неактивной УЗ", entity.EventUserChanged)
|
w.auditRepo.SaveAuditAsync(ctx, userId, "Блокировка неактивной УЗ", entity.EventUserChanged)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,148 +0,0 @@
|
|||||||
package ldap
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
"slices"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/txix-open/isp-kit/log"
|
|
||||||
"msp-admin-service/conf"
|
|
||||||
"msp-admin-service/domain"
|
|
||||||
"msp-admin-service/entity"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Repo interface {
|
|
||||||
IsExist(ctx context.Context, dn string) (bool, error)
|
|
||||||
DnByUserPrincipalName(ctx context.Context, principalName string) (string, error)
|
|
||||||
ModifyMemberAttr(ctx context.Context, userDn string, groupDn string, operation string) error
|
|
||||||
Close() error
|
|
||||||
}
|
|
||||||
|
|
||||||
type RoleRepo interface {
|
|
||||||
All(ctx context.Context) ([]entity.Role, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type UserRoleRepo interface {
|
|
||||||
GetRolesByUserIds(ctx context.Context, identity []int) ([]entity.UserRole, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type RepoSupplier func(config *conf.Ldap) (Repo, error)
|
|
||||||
|
|
||||||
type Service struct {
|
|
||||||
config *conf.Ldap
|
|
||||||
repoSuppler RepoSupplier
|
|
||||||
userRoleRepo UserRoleRepo
|
|
||||||
roleRepo RoleRepo
|
|
||||||
logger log.Logger
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewService(
|
|
||||||
config *conf.Ldap,
|
|
||||||
repoSuppler RepoSupplier,
|
|
||||||
userRoleRepo UserRoleRepo,
|
|
||||||
roleRepo RoleRepo,
|
|
||||||
logger log.Logger,
|
|
||||||
) Service {
|
|
||||||
return Service{
|
|
||||||
config: config,
|
|
||||||
repoSuppler: repoSuppler,
|
|
||||||
userRoleRepo: userRoleRepo,
|
|
||||||
roleRepo: roleRepo,
|
|
||||||
logger: logger,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s Service) SyncGroupsAsync(ctx context.Context, user entity.User) {
|
|
||||||
ctx = context.WithoutCancel(ctx)
|
|
||||||
go func() {
|
|
||||||
err := s.SyncGroups(ctx, user)
|
|
||||||
if err != nil {
|
|
||||||
s.logger.Warn(ctx, errors.WithMessage(err, "ldap sync groups"))
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s Service) SyncGroups(ctx context.Context, user entity.User) error {
|
|
||||||
ctx = log.ToContext(ctx, log.String("process", "ldap"), log.Int64("userId", user.Id))
|
|
||||||
|
|
||||||
ldapRepo, err := s.repoSuppler(s.config)
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessage(err, "init ldap repository")
|
|
||||||
}
|
|
||||||
defer ldapRepo.Close()
|
|
||||||
|
|
||||||
if user.SudirUserId == nil || *user.SudirUserId == "" {
|
|
||||||
s.logger.Info(ctx, "user has not sudir user id, skip")
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
userDn, err := ldapRepo.DnByUserPrincipalName(ctx, *user.SudirUserId)
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessagef(err, "get user dn by principal name %s", *user.SudirUserId)
|
|
||||||
}
|
|
||||||
|
|
||||||
userRoles, err := s.userRoleRepo.GetRolesByUserIds(ctx, []int{int(user.Id)})
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessage(err, "ger roles by user ids")
|
|
||||||
}
|
|
||||||
|
|
||||||
allRoles, err := s.roleRepo.All(ctx)
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessage(err, "get all roles")
|
|
||||||
}
|
|
||||||
|
|
||||||
for i := range allRoles {
|
|
||||||
role := allRoles[i]
|
|
||||||
contains := slices.ContainsFunc(userRoles, func(userRole entity.UserRole) bool {
|
|
||||||
return userRole.RoleId == role.Id
|
|
||||||
})
|
|
||||||
operation := entity.GroupOperationDelete
|
|
||||||
if contains {
|
|
||||||
operation = entity.GroupOperationAdd
|
|
||||||
}
|
|
||||||
|
|
||||||
err := s.handleRole(ctx, role, userDn, operation, ldapRepo)
|
|
||||||
if errors.Is(err, domain.ErrNoActionRequired) {
|
|
||||||
s.logger.Info(ctx, "no action required, role is already synced")
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
s.logger.Error(ctx, errors.WithMessage(err, "handle role"))
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s Service) handleRole(
|
|
||||||
ctx context.Context,
|
|
||||||
role entity.Role,
|
|
||||||
userDn string,
|
|
||||||
operation string,
|
|
||||||
ldapRepo Repo,
|
|
||||||
) error {
|
|
||||||
if role.ExternalGroup == "" {
|
|
||||||
s.logger.Info(ctx, "role has no external group mapping, skip", log.Int("roleId", role.Id))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
exist, err := ldapRepo.IsExist(ctx, role.ExternalGroup)
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessagef(err, "check dn %s is exist", role.ExternalGroup)
|
|
||||||
}
|
|
||||||
if !exist {
|
|
||||||
s.logger.Info(ctx, "role doesn't exist in ldap, skip", log.Int("roleId", role.Id))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
err = ldapRepo.ModifyMemberAttr(ctx, userDn, role.ExternalGroup, operation)
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessage(err, "modify group member attr")
|
|
||||||
}
|
|
||||||
|
|
||||||
s.logger.Info(ctx, fmt.Sprintf("group %s synced for user %s, operation %s", role.ExternalGroup, userDn, operation))
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package session_worker
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"github.com/txix-open/bgjob"
|
||||||
|
"github.com/txix-open/isp-kit/bgjobx"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
QueueName = "set_session_expired"
|
||||||
|
)
|
||||||
|
|
||||||
|
func EnqueueSeedJob(ctx context.Context, client *bgjobx.Client) error {
|
||||||
|
err := client.Enqueue(ctx, bgjob.EnqueueRequest{
|
||||||
|
Id: "set_session_expired",
|
||||||
|
Queue: QueueName,
|
||||||
|
Type: "set_session_expired",
|
||||||
|
})
|
||||||
|
if err != nil && !errors.Is(err, bgjob.ErrJobAlreadyExist) {
|
||||||
|
return errors.WithMessage(err, "enqueue job")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
package session_worker
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"msp-admin-service/entity"
|
||||||
|
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"github.com/txix-open/bgjob"
|
||||||
|
"github.com/txix-open/isp-kit/bgjobx/handler"
|
||||||
|
"github.com/txix-open/isp-kit/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
defaultRetryTimeout = 5 * time.Minute
|
||||||
|
rescheduleInterval = 1 * time.Minute
|
||||||
|
)
|
||||||
|
|
||||||
|
type TokenTransactionRunner interface {
|
||||||
|
TokenTransaction(ctx context.Context, tx func(ctx context.Context, tx TokenTransaction) error) error
|
||||||
|
}
|
||||||
|
|
||||||
|
type TokenTransaction interface {
|
||||||
|
All(ctx context.Context) ([]entity.Token, error)
|
||||||
|
SetExpiredStatusByIds(ctx context.Context, ids []int) error
|
||||||
|
}
|
||||||
|
|
||||||
|
type Service struct {
|
||||||
|
logger log.Logger
|
||||||
|
txRunner TokenTransactionRunner
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewExpireSessionWorker(
|
||||||
|
logger log.Logger,
|
||||||
|
txRunner TokenTransactionRunner,
|
||||||
|
) Service {
|
||||||
|
return Service{
|
||||||
|
logger: logger,
|
||||||
|
txRunner: txRunner,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w Service) Handle(ctx context.Context, _ bgjob.Job) handler.Result {
|
||||||
|
ctx = log.ToContext(ctx, log.String("worker", "expireSessionWorker"))
|
||||||
|
w.logger.Debug(ctx, "begin work")
|
||||||
|
|
||||||
|
err := w.do(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return handler.Retry(defaultRetryTimeout, errors.WithMessage(err, "expireSessionWorker do"))
|
||||||
|
}
|
||||||
|
|
||||||
|
w.logger.Debug(ctx, "end work")
|
||||||
|
return handler.Reschedule(handler.ByAfterTime(rescheduleInterval, time.Now()))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w Service) do(ctx context.Context) error {
|
||||||
|
err := w.txRunner.TokenTransaction(ctx, func(ctx context.Context, tx TokenTransaction) error {
|
||||||
|
tokens, err := tx.All(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "get all tokens")
|
||||||
|
}
|
||||||
|
|
||||||
|
expiredTokenIds := make([]int, 0)
|
||||||
|
now := time.Now().UTC()
|
||||||
|
for _, token := range tokens {
|
||||||
|
if now.After(token.ExpiredAt) {
|
||||||
|
expiredTokenIds = append(expiredTokenIds, token.Id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(expiredTokenIds) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
err = tx.SetExpiredStatusByIds(ctx, expiredTokenIds)
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "set expired status by id")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "token transaction")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
+3
-1
@@ -3,10 +3,11 @@ package service
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"msp-admin-service/conf"
|
"msp-admin-service/conf"
|
||||||
"msp-admin-service/domain"
|
"msp-admin-service/domain"
|
||||||
"msp-admin-service/entity"
|
"msp-admin-service/entity"
|
||||||
|
|
||||||
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
type sudirRepo interface {
|
type sudirRepo interface {
|
||||||
@@ -72,6 +73,7 @@ func (s Sudir) Authenticate(ctx context.Context, authCode string, roleRepo roleR
|
|||||||
SudirUserId: user.Sub,
|
SudirUserId: user.Sub,
|
||||||
FirstName: user.GivenName,
|
FirstName: user.GivenName,
|
||||||
LastName: user.FamilyName,
|
LastName: user.FamilyName,
|
||||||
|
FullName: user.Name,
|
||||||
Email: email,
|
Email: email,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
+15
-15
@@ -6,18 +6,19 @@ import (
|
|||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"golang.org/x/sync/errgroup"
|
|
||||||
"msp-admin-service/domain"
|
"msp-admin-service/domain"
|
||||||
"msp-admin-service/entity"
|
"msp-admin-service/entity"
|
||||||
|
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"golang.org/x/sync/errgroup"
|
||||||
)
|
)
|
||||||
|
|
||||||
type TokenRep interface {
|
type TokenRep interface {
|
||||||
TokenSaver
|
TokenSaver
|
||||||
Get(ctx context.Context, token string) (*entity.Token, error)
|
Get(ctx context.Context, token string) (*entity.Token, error)
|
||||||
RevokeByUserId(ctx context.Context, userId int64, updatedAt time.Time) error
|
RevokeByUserId(ctx context.Context, userId int64, updatedAt time.Time) error
|
||||||
All(ctx context.Context, limit int, offset int) ([]entity.Token, error)
|
AllByRequest(ctx context.Context, req domain.SessionPageRequest) ([]entity.Token, error)
|
||||||
Count(ctx context.Context) (int64, error)
|
Count(ctx context.Context, reqQuery *domain.SessionQuery) (int64, error)
|
||||||
UpdateStatus(ctx context.Context, id int, status string) error
|
UpdateStatus(ctx context.Context, id int, status string) error
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,44 +74,43 @@ func (s Token) RevokeAllByUserId(ctx context.Context, userId int64) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s Token) All(ctx context.Context, limit int, offset int) (*domain.SessionResponse, error) {
|
func (s Token) All(ctx context.Context, req domain.SessionPageRequest) (*domain.SessionResponse, error) {
|
||||||
group, ctx := errgroup.WithContext(ctx)
|
|
||||||
var tokens []entity.Token
|
var tokens []entity.Token
|
||||||
var total int64
|
var total int64
|
||||||
var err error
|
|
||||||
|
group, ctx := errgroup.WithContext(ctx)
|
||||||
group.Go(func() error {
|
group.Go(func() error {
|
||||||
tokens, err = s.tokenRep.All(ctx, limit, offset)
|
var err error
|
||||||
|
tokens, err = s.tokenRep.AllByRequest(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessage(err, "get all tokens")
|
return errors.WithMessage(err, "get all tokens")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
group.Go(func() error {
|
group.Go(func() error {
|
||||||
total, err = s.tokenRep.Count(ctx)
|
var err error
|
||||||
|
total, err = s.tokenRep.Count(ctx, req.Query)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessage(err, "count all tokens")
|
return errors.WithMessage(err, "count all tokens")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
err = group.Wait()
|
err := group.Wait()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessage(err, "wait workers")
|
return nil, errors.WithMessage(err, "wait workers")
|
||||||
}
|
}
|
||||||
|
|
||||||
items := make([]domain.Session, 0)
|
items := make([]domain.Session, 0)
|
||||||
for _, token := range tokens {
|
for _, token := range tokens {
|
||||||
status := token.Status
|
|
||||||
if time.Now().UTC().After(token.ExpiredAt) {
|
|
||||||
status = entity.TokenStatusExpired
|
|
||||||
}
|
|
||||||
items = append(items, domain.Session{
|
items = append(items, domain.Session{
|
||||||
Id: token.Id,
|
Id: token.Id,
|
||||||
UserId: int(token.UserId),
|
UserId: int(token.UserId),
|
||||||
Status: status,
|
Status: token.Status,
|
||||||
ExpiredAt: token.ExpiredAt,
|
ExpiredAt: token.ExpiredAt,
|
||||||
CreatedAt: token.CreatedAt,
|
CreatedAt: token.CreatedAt,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
result := domain.SessionResponse{
|
result := domain.SessionResponse{
|
||||||
TotalCount: int(total),
|
TotalCount: int(total),
|
||||||
Items: items,
|
Items: items,
|
||||||
|
|||||||
+179
-98
@@ -8,11 +8,12 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"msp-admin-service/domain"
|
||||||
|
"msp-admin-service/entity"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/txix-open/isp-kit/log"
|
"github.com/txix-open/isp-kit/log"
|
||||||
"golang.org/x/crypto/bcrypt"
|
"golang.org/x/crypto/bcrypt"
|
||||||
"msp-admin-service/domain"
|
|
||||||
"msp-admin-service/entity"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type UserTransaction interface {
|
type UserTransaction interface {
|
||||||
@@ -27,13 +28,15 @@ type UserTransactionRunner interface {
|
|||||||
|
|
||||||
type UserRepo interface {
|
type UserRepo interface {
|
||||||
GetUserById(ctx context.Context, identity int64) (*entity.User, error)
|
GetUserById(ctx context.Context, identity int64) (*entity.User, error)
|
||||||
GetUsers(ctx context.Context, ids []int64, offset, limit int, email string) ([]entity.User, error)
|
GetUsers(ctx context.Context, req domain.UsersPageRequest) ([]entity.User, error)
|
||||||
GetUserByEmail(ctx context.Context, email string) (*entity.User, error)
|
GetUserByEmailAndSudirId(ctx context.Context, email string, sudirUserId string) (*entity.User, error)
|
||||||
|
GetUsersByEmail(ctx context.Context, email string) ([]entity.User, error)
|
||||||
UpdateUser(ctx context.Context, id int64, user entity.UpdateUser) (*entity.User, error)
|
UpdateUser(ctx context.Context, id int64, user entity.UpdateUser) (*entity.User, error)
|
||||||
DeleteUser(ctx context.Context, ids []int64) (int, error)
|
DeleteUser(ctx context.Context, ids []int64) (int, error)
|
||||||
Insert(ctx context.Context, user entity.User) (int, error)
|
Insert(ctx context.Context, user entity.User) (int, error)
|
||||||
ChangeBlockStatus(ctx context.Context, userId int) (bool, error)
|
ChangeBlockStatus(ctx context.Context, userId int) (bool, error)
|
||||||
ChangePassword(ctx context.Context, userId int64, newPassword string) error
|
ChangePassword(ctx context.Context, userId int64, newPassword string) error
|
||||||
|
UpdateLastActiveAt(ctx context.Context, userId int64, lastActiveAt time.Time) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type TokenRepo interface {
|
type TokenRepo interface {
|
||||||
@@ -50,10 +53,6 @@ type roleRepoUser interface {
|
|||||||
GetRoleByIds(ctx context.Context, id []int) ([]entity.Role, error)
|
GetRoleByIds(ctx context.Context, id []int) ([]entity.Role, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type LdapService interface {
|
|
||||||
SyncGroupsAsync(ctx context.Context, user entity.User)
|
|
||||||
}
|
|
||||||
|
|
||||||
type User struct {
|
type User struct {
|
||||||
userRepo UserRepo
|
userRepo UserRepo
|
||||||
userRoleRepo UserRoleRepo
|
userRoleRepo UserRoleRepo
|
||||||
@@ -61,7 +60,6 @@ type User struct {
|
|||||||
tokenRepo TokenRepo
|
tokenRepo TokenRepo
|
||||||
auditService auditService
|
auditService auditService
|
||||||
txRunner UserTransactionRunner
|
txRunner UserTransactionRunner
|
||||||
ldapService LdapService
|
|
||||||
tokenService tokenService
|
tokenService tokenService
|
||||||
idleTimeoutMs int
|
idleTimeoutMs int
|
||||||
logger log.Logger
|
logger log.Logger
|
||||||
@@ -74,7 +72,6 @@ func NewUser(
|
|||||||
tokenRepo TokenRepo,
|
tokenRepo TokenRepo,
|
||||||
service auditService,
|
service auditService,
|
||||||
txRunner UserTransactionRunner,
|
txRunner UserTransactionRunner,
|
||||||
ldapService LdapService,
|
|
||||||
tokenService tokenService,
|
tokenService tokenService,
|
||||||
idleTimeoutMs int,
|
idleTimeoutMs int,
|
||||||
logger log.Logger,
|
logger log.Logger,
|
||||||
@@ -86,7 +83,6 @@ func NewUser(
|
|||||||
tokenRepo: tokenRepo,
|
tokenRepo: tokenRepo,
|
||||||
auditService: service,
|
auditService: service,
|
||||||
txRunner: txRunner,
|
txRunner: txRunner,
|
||||||
ldapService: ldapService,
|
|
||||||
tokenService: tokenService,
|
tokenService: tokenService,
|
||||||
idleTimeoutMs: idleTimeoutMs,
|
idleTimeoutMs: idleTimeoutMs,
|
||||||
logger: logger,
|
logger: logger,
|
||||||
@@ -108,27 +104,39 @@ func (u User) GetProfileById(ctx context.Context, userId int64) (*domain.AdminUs
|
|||||||
}
|
}
|
||||||
roleIds := RolesIds(roles)
|
roleIds := RolesIds(roles)
|
||||||
|
|
||||||
var roleList []entity.Role
|
var (
|
||||||
|
roleList []entity.Role
|
||||||
|
roleName string
|
||||||
|
roleNames []string
|
||||||
|
)
|
||||||
if len(roleIds) != 0 {
|
if len(roleIds) != 0 {
|
||||||
roleList, err = u.roleRepoUser.GetRoleByIds(ctx, roleIds)
|
roleList, err = u.roleRepoUser.GetRoleByIds(ctx, roleIds)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessage(err, "get roles")
|
return nil, errors.WithMessage(err, "get roles")
|
||||||
}
|
}
|
||||||
|
if len(roleList) > 0 {
|
||||||
|
roleName = roleList[0].Name
|
||||||
|
for _, r := range roleList {
|
||||||
|
roleNames = append(roleNames, r.Name)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return &domain.AdminUserShort{
|
return &domain.AdminUserShort{
|
||||||
FirstName: user.FirstName,
|
FirstName: user.FirstName,
|
||||||
LastName: user.LastName,
|
LastName: user.LastName,
|
||||||
|
FullName: user.FullName,
|
||||||
Email: user.Email,
|
Email: user.Email,
|
||||||
Role: roleList[0].Name,
|
Role: roleName,
|
||||||
Roles: roleIds,
|
Roles: roleIds,
|
||||||
|
RoleNames: roleNames,
|
||||||
IdleTimeoutMs: u.idleTimeoutMs,
|
IdleTimeoutMs: u.idleTimeoutMs,
|
||||||
Permissions: mergePermissions(roleList),
|
Permissions: mergePermissions(roleList),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u User) GetUsers(ctx context.Context, req domain.UsersRequest) (*domain.UsersResponse, error) {
|
func (u User) GetUsers(ctx context.Context, req domain.UsersPageRequest) (*domain.UsersResponse, error) {
|
||||||
users, err := u.userRepo.GetUsers(ctx, req.Ids, req.Offset, req.Limit, req.Email)
|
users, err := u.userRepo.GetUsers(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessage(err, "get users from repo")
|
return nil, errors.WithMessage(err, "get users from repo")
|
||||||
}
|
}
|
||||||
@@ -138,27 +146,24 @@ func (u User) GetUsers(ctx context.Context, req domain.UsersRequest) (*domain.Us
|
|||||||
userIds = append(userIds, int(user.Id))
|
userIds = append(userIds, int(user.Id))
|
||||||
}
|
}
|
||||||
|
|
||||||
rolesByUsers, err := u.userRoleRepo.GetRolesByUserIds(ctx, userIds)
|
userRoles, err := u.userRoleRepo.GetRolesByUserIds(ctx, userIds)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessage(err, "get roles by user ids")
|
return nil, errors.WithMessage(err, "get roles by user ids and roles id")
|
||||||
}
|
|
||||||
|
|
||||||
lastSessionsByUsers, err := u.tokenRepo.LastAccessByUserIds(ctx, userIds)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.WithMessage(err, "get last sessions by user ids")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
items := make([]domain.User, 0, len(users))
|
items := make([]domain.User, 0, len(users))
|
||||||
for _, user := range users {
|
for _, user := range users {
|
||||||
roles := make([]int, 0)
|
roles := make([]int, 0)
|
||||||
|
|
||||||
for _, role := range rolesByUsers {
|
for _, role := range userRoles {
|
||||||
if role.UserId == int(user.Id) {
|
if role.UserId == int(user.Id) {
|
||||||
roles = append(roles, role.RoleId)
|
roles = append(roles, role.RoleId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
items = append(items, u.toDomain(user, roles, lastSessionsByUsers[user.Id]))
|
if filteredRoles(req.Query, roles) && filteredLastSession(req.Query, user.LastSessionCreatedAt) {
|
||||||
|
items = append(items, u.toDomain(user, roles, user.LastSessionCreatedAt))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return &domain.UsersResponse{Items: items}, nil
|
return &domain.UsersResponse{Items: items}, nil
|
||||||
@@ -168,7 +173,7 @@ func (u User) CreateUser(ctx context.Context, req domain.CreateUserRequest, admi
|
|||||||
var usr entity.User
|
var usr entity.User
|
||||||
|
|
||||||
err := u.txRunner.UserTransaction(ctx, func(ctx context.Context, tx UserTransaction) error {
|
err := u.txRunner.UserTransaction(ctx, func(ctx context.Context, tx UserTransaction) error {
|
||||||
user, err := tx.GetUserByEmail(ctx, req.Email)
|
user, err := tx.GetUserByEmailAndSudirId(ctx, req.Email, "")
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(err, domain.ErrNotFound):
|
case errors.Is(err, domain.ErrNotFound):
|
||||||
break
|
break
|
||||||
@@ -188,6 +193,7 @@ func (u User) CreateUser(ctx context.Context, req domain.CreateUserRequest, admi
|
|||||||
Id: 0,
|
Id: 0,
|
||||||
FirstName: req.FirstName,
|
FirstName: req.FirstName,
|
||||||
LastName: req.LastName,
|
LastName: req.LastName,
|
||||||
|
FullName: createFullName(req.FirstName, req.LastName),
|
||||||
Email: req.Email,
|
Email: req.Email,
|
||||||
Password: encryptedPassword,
|
Password: encryptedPassword,
|
||||||
Description: req.Description,
|
Description: req.Description,
|
||||||
@@ -211,18 +217,14 @@ func (u User) CreateUser(ctx context.Context, req domain.CreateUserRequest, admi
|
|||||||
return nil, errors.WithMessage(err, "create user transaction")
|
return nil, errors.WithMessage(err, "create user transaction")
|
||||||
}
|
}
|
||||||
|
|
||||||
u.ldapService.SyncGroupsAsync(ctx, usr)
|
|
||||||
|
|
||||||
slices.Sort(req.Roles)
|
slices.Sort(req.Roles)
|
||||||
diff := diffToString(map[string]any{
|
diff := diffToString(map[string]any{
|
||||||
"Имя": "",
|
"ФИО": "",
|
||||||
"Фамилия": "",
|
|
||||||
"Описание": "",
|
"Описание": "",
|
||||||
"Email": "",
|
"Email": "",
|
||||||
"Роли (ID)": []int{},
|
"Роли (ID)": []int{},
|
||||||
}, map[string]any{
|
}, map[string]any{
|
||||||
"Имя": req.FirstName,
|
"ФИО": usr.FullName,
|
||||||
"Фамилия": req.LastName,
|
|
||||||
"Описание": req.Description,
|
"Описание": req.Description,
|
||||||
"Email": req.Email,
|
"Email": req.Email,
|
||||||
"Роли (ID)": req.Roles,
|
"Роли (ID)": req.Roles,
|
||||||
@@ -236,9 +238,11 @@ func (u User) CreateUser(ctx context.Context, req domain.CreateUserRequest, admi
|
|||||||
return &result, nil
|
return &result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//nolint:cyclop,funlen
|
||||||
func (u User) UpdateUser(ctx context.Context, req domain.UpdateUserRequest, adminId int64) (*domain.User, error) {
|
func (u User) UpdateUser(ctx context.Context, req domain.UpdateUserRequest, adminId int64) (*domain.User, error) {
|
||||||
var (
|
var (
|
||||||
user *entity.User
|
user *entity.User
|
||||||
|
updatedUser *entity.User
|
||||||
lastSessionCreatedAt *time.Time
|
lastSessionCreatedAt *time.Time
|
||||||
)
|
)
|
||||||
oldRoles, err := u.userRoleRepo.GetRolesByUserIds(ctx, []int{int(req.Id)})
|
oldRoles, err := u.userRoleRepo.GetRolesByUserIds(ctx, []int{int(req.Id)})
|
||||||
@@ -246,7 +250,7 @@ func (u User) UpdateUser(ctx context.Context, req domain.UpdateUserRequest, admi
|
|||||||
return nil, errors.WithMessage(err, "get user roles")
|
return nil, errors.WithMessage(err, "get user roles")
|
||||||
}
|
}
|
||||||
err = u.txRunner.UserTransaction(ctx, func(ctx context.Context, tx UserTransaction) error {
|
err = u.txRunner.UserTransaction(ctx, func(ctx context.Context, tx UserTransaction) error {
|
||||||
_, err := tx.GetUserById(ctx, req.Id)
|
user, err = tx.GetUserById(ctx, req.Id)
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(err, domain.ErrNotFound):
|
case errors.Is(err, domain.ErrNotFound):
|
||||||
return err // nolint:wrapcheck
|
return err // nolint:wrapcheck
|
||||||
@@ -254,37 +258,48 @@ func (u User) UpdateUser(ctx context.Context, req domain.UpdateUserRequest, admi
|
|||||||
return errors.WithMessage(err, "get user by id")
|
return errors.WithMessage(err, "get user by id")
|
||||||
}
|
}
|
||||||
|
|
||||||
user, err = tx.GetUserByEmail(ctx, req.Email)
|
users, err := tx.GetUsersByEmail(ctx, req.Email)
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(err, domain.ErrNotFound):
|
case errors.Is(err, domain.ErrNotFound):
|
||||||
break
|
break
|
||||||
case err != nil:
|
case err != nil:
|
||||||
return errors.WithMessage(err, "get user by email or phone")
|
return errors.WithMessage(err, "get user by email or phone")
|
||||||
case user.Id != req.Id:
|
}
|
||||||
return domain.ErrAlreadyExists
|
|
||||||
|
for _, usr := range users {
|
||||||
|
// check in internal user space
|
||||||
|
if (user.SudirUserId == nil && usr.SudirUserId == nil) && (usr.Id != req.Id) {
|
||||||
|
return domain.ErrAlreadyExists
|
||||||
|
}
|
||||||
|
|
||||||
|
// check in sudir user space
|
||||||
|
if usr.SudirUserId != nil && user.SudirUserId != nil && (*user.SudirUserId != *usr.SudirUserId) {
|
||||||
|
return domain.ErrAlreadyExists
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateEntity := entity.UpdateUser{
|
updateEntity := entity.UpdateUser{
|
||||||
FirstName: req.FirstName,
|
FirstName: req.FirstName,
|
||||||
LastName: req.LastName,
|
LastName: req.LastName,
|
||||||
|
FullName: createFullName(req.FirstName, req.LastName),
|
||||||
Email: req.Email,
|
Email: req.Email,
|
||||||
Description: req.Description,
|
Description: req.Description,
|
||||||
}
|
}
|
||||||
user, err = tx.UpdateUser(ctx, req.Id, updateEntity)
|
updatedUser, err = tx.UpdateUser(ctx, req.Id, updateEntity)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessage(err, "update user")
|
return errors.WithMessage(err, "update user")
|
||||||
}
|
}
|
||||||
|
|
||||||
err = tx.UpsertUserRoleLinks(ctx, int(user.Id), req.Roles)
|
err = tx.UpsertUserRoleLinks(ctx, int(updatedUser.Id), req.Roles)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessage(err, "update user role links")
|
return errors.WithMessage(err, "update user role links")
|
||||||
}
|
}
|
||||||
|
|
||||||
userLastSession, err := tx.LastAccessByUserIds(ctx, []int{int(user.Id)})
|
userLastSession, err := tx.LastAccessByUserIds(ctx, []int{int(updatedUser.Id)})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessage(err, "get last user session")
|
return errors.WithMessage(err, "get last user session")
|
||||||
}
|
}
|
||||||
lastSessionCreatedAt = userLastSession[user.Id]
|
lastSessionCreatedAt = userLastSession[updatedUser.Id]
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
@@ -292,28 +307,24 @@ func (u User) UpdateUser(ctx context.Context, req domain.UpdateUserRequest, admi
|
|||||||
return nil, errors.WithMessage(err, "update user transaction")
|
return nil, errors.WithMessage(err, "update user transaction")
|
||||||
}
|
}
|
||||||
|
|
||||||
u.ldapService.SyncGroupsAsync(ctx, *user)
|
|
||||||
|
|
||||||
slices.Sort(req.Roles)
|
slices.Sort(req.Roles)
|
||||||
diff := diffToString(map[string]any{
|
diff := diffToString(map[string]any{
|
||||||
"Имя": user.FirstName,
|
"ФИО": user.FullName,
|
||||||
"Фамилия": user.LastName,
|
|
||||||
"Описание": user.Description,
|
"Описание": user.Description,
|
||||||
"Email": user.Email,
|
"Email": user.Email,
|
||||||
"Роли (ID)": RolesIds(oldRoles),
|
"Роли (ID)": RolesIds(oldRoles),
|
||||||
}, map[string]any{
|
}, map[string]any{
|
||||||
"Имя": req.FirstName,
|
"ФИО": updatedUser.FullName,
|
||||||
"Фамилия": req.LastName,
|
|
||||||
"Описание": req.Description,
|
"Описание": req.Description,
|
||||||
"Email": req.Email,
|
"Email": req.Email,
|
||||||
"Роли (ID)": req.Roles,
|
"Роли (ID)": req.Roles,
|
||||||
})
|
})
|
||||||
u.auditService.SaveAuditAsync(ctx, adminId,
|
u.auditService.SaveAuditAsync(ctx, adminId,
|
||||||
fmt.Sprintf("Пользователь. Изменение пользователя %d.\n %s", user.Id, diff),
|
fmt.Sprintf("Пользователь. Изменение пользователя %d.\n %s", updatedUser.Id, diff),
|
||||||
entity.EventUserChanged,
|
entity.EventUserChanged,
|
||||||
)
|
)
|
||||||
|
|
||||||
result := u.toDomain(*user, req.Roles, lastSessionCreatedAt)
|
result := u.toDomain(*updatedUser, req.Roles, lastSessionCreatedAt)
|
||||||
return &result, nil
|
return &result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -365,7 +376,7 @@ func (u User) Block(ctx context.Context, adminId int64, userId int) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if blocked {
|
if blocked {
|
||||||
err := tx.UpdateStatusByUserId(ctx, userId, entity.TokenStatusRevoked)
|
err = tx.UpdateStatusByUserId(ctx, userId, entity.TokenStatusRevoked)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessage(err, "revoke tokens")
|
return errors.WithMessage(err, "revoke tokens")
|
||||||
}
|
}
|
||||||
@@ -373,6 +384,11 @@ func (u User) Block(ctx context.Context, adminId int64, userId int) error {
|
|||||||
|
|
||||||
if !blocked {
|
if !blocked {
|
||||||
userBlocked = "разблокировка"
|
userBlocked = "разблокировка"
|
||||||
|
lastActiveAt := time.Now().UTC()
|
||||||
|
err = tx.UpdateLastActiveAt(ctx, int64(userId), lastActiveAt)
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "update user last_active_at")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -383,37 +399,12 @@ func (u User) Block(ctx context.Context, adminId int64, userId int) error {
|
|||||||
|
|
||||||
u.auditService.SaveAuditAsync(ctx, adminId,
|
u.auditService.SaveAuditAsync(ctx, adminId,
|
||||||
fmt.Sprintf("Пользователь. %s пользователя ID %d.", userBlocked, userId),
|
fmt.Sprintf("Пользователь. %s пользователя ID %d.", userBlocked, userId),
|
||||||
entity.EventUserChanged,
|
entity.EventUserBlocked,
|
||||||
)
|
)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint:gomnd
|
|
||||||
func (u User) cryptPassword(password string) (string, error) {
|
|
||||||
passwordBytes, err := bcrypt.GenerateFromPassword([]byte(password), 12) //nolint:mnd
|
|
||||||
if err != nil {
|
|
||||||
return "", errors.WithMessage(err, "gen bcrypt from password")
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(passwordBytes), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u User) toDomain(user entity.User, roleIds []int, lastSessionCreatedAt *time.Time) domain.User {
|
|
||||||
return domain.User{
|
|
||||||
Id: user.Id,
|
|
||||||
Roles: roleIds,
|
|
||||||
FirstName: user.FirstName,
|
|
||||||
Description: user.Description,
|
|
||||||
LastName: user.LastName,
|
|
||||||
Email: user.Email,
|
|
||||||
Blocked: user.Blocked,
|
|
||||||
UpdatedAt: user.UpdatedAt,
|
|
||||||
CreatedAt: user.CreatedAt,
|
|
||||||
LastSessionCreatedAt: lastSessionCreatedAt,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func RolesIds(roles []entity.UserRole) []int {
|
func RolesIds(roles []entity.UserRole) []int {
|
||||||
roleList := make([]int, 0)
|
roleList := make([]int, 0)
|
||||||
|
|
||||||
@@ -463,32 +454,122 @@ func diffToString(a map[string]any, b map[string]any) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (u User) ChangePassword(ctx context.Context, adminId int64, oldPassword string, newPassword string) error {
|
func (u User) ChangePassword(ctx context.Context, adminId int64, oldPassword string, newPassword string) error {
|
||||||
admin, err := u.userRepo.GetUserById(ctx, adminId)
|
err := u.txRunner.UserTransaction(ctx, func(ctx context.Context, tx UserTransaction) error {
|
||||||
|
admin, err := tx.GetUserById(ctx, adminId)
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "user.service.ChangePassword: get user by id")
|
||||||
|
}
|
||||||
|
|
||||||
|
err = bcrypt.CompareHashAndPassword([]byte(admin.Password), []byte(oldPassword))
|
||||||
|
if err != nil {
|
||||||
|
u.auditService.SaveAuditAsync(ctx, adminId, "Указан неверный старый пароль", entity.EventErrorPasswordChange)
|
||||||
|
return domain.ErrInvalidPassword
|
||||||
|
}
|
||||||
|
|
||||||
|
encryptedPassword, err := u.cryptPassword(newPassword)
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "user.service.ChangePassword: crypt new password")
|
||||||
|
}
|
||||||
|
|
||||||
|
err = tx.ChangePassword(ctx, adminId, encryptedPassword)
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "user.service.ChangePassword: change password ")
|
||||||
|
}
|
||||||
|
|
||||||
|
err = u.tokenService.RevokeAllByUserId(ctx, adminId)
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "revoke all tokens by user id")
|
||||||
|
}
|
||||||
|
|
||||||
|
lastActiveAt := time.Now().UTC()
|
||||||
|
err = tx.UpdateLastActiveAt(ctx, adminId, lastActiveAt)
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "update user last_active_at")
|
||||||
|
}
|
||||||
|
|
||||||
|
u.auditService.SaveAuditAsync(ctx, adminId, "Сменил пароль", entity.EventUserPasswordChanged)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessage(err, "user.service.ChangePassword: get user by id")
|
return errors.WithMessage(err, "user transaction")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := bcrypt.CompareHashAndPassword([]byte(admin.Password), []byte(oldPassword)); err != nil {
|
|
||||||
u.auditService.SaveAuditAsync(ctx, adminId, "Указан неверный старый пароль", entity.EventErrorPasswordChange)
|
|
||||||
return domain.ErrInvalidPassword
|
|
||||||
}
|
|
||||||
|
|
||||||
encryptedPassword, err := u.cryptPassword(newPassword)
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessage(err, "user.service.ChangePassword: crypt new password")
|
|
||||||
}
|
|
||||||
|
|
||||||
err = u.userRepo.ChangePassword(ctx, adminId, encryptedPassword)
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessage(err, "user.service.ChangePassword: change password ")
|
|
||||||
}
|
|
||||||
|
|
||||||
err = u.tokenService.RevokeAllByUserId(ctx, adminId)
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessage(err, "revoke all tokens by user id")
|
|
||||||
}
|
|
||||||
|
|
||||||
u.auditService.SaveAuditAsync(ctx, adminId, "Сменил пароль", entity.EventUserPasswordChanged)
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (u User) cryptPassword(password string) (string, error) {
|
||||||
|
passwordBytes, err := bcrypt.GenerateFromPassword([]byte(password), 12) //nolint:mnd
|
||||||
|
if err != nil {
|
||||||
|
return "", errors.WithMessage(err, "gen bcrypt from password")
|
||||||
|
}
|
||||||
|
|
||||||
|
return string(passwordBytes), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u User) toDomain(user entity.User, roleIds []int, lastSessionCreatedAt *time.Time) domain.User {
|
||||||
|
return domain.User{
|
||||||
|
Id: user.Id,
|
||||||
|
Roles: roleIds,
|
||||||
|
FirstName: user.FirstName,
|
||||||
|
LastName: user.LastName,
|
||||||
|
FullName: user.FullName,
|
||||||
|
Description: user.Description,
|
||||||
|
Email: user.Email,
|
||||||
|
Blocked: user.Blocked,
|
||||||
|
UpdatedAt: user.UpdatedAt,
|
||||||
|
CreatedAt: user.CreatedAt,
|
||||||
|
LastSessionCreatedAt: lastSessionCreatedAt,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func filteredRoles(reqQuery *domain.UserQuery, roleIds []int) bool {
|
||||||
|
if reqQuery == nil {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
if reqQuery.Roles == nil {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(reqQuery.Roles) == 0 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, roleId := range roleIds {
|
||||||
|
if slices.Contains(reqQuery.Roles, roleId) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func filteredLastSession(reqQuery *domain.UserQuery, lastSessionCreatedAt *time.Time) bool {
|
||||||
|
if reqQuery == nil {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
if reqQuery.LastSessionCreatedAt == nil {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
if lastSessionCreatedAt == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if reqQuery.LastSessionCreatedAt.From.Compare(*lastSessionCreatedAt) <= 0 &&
|
||||||
|
reqQuery.LastSessionCreatedAt.To.Compare(*lastSessionCreatedAt) > 0 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func createFullName(firstName string, lastName string) string {
|
||||||
|
if len(lastName) == 0 {
|
||||||
|
return firstName
|
||||||
|
}
|
||||||
|
|
||||||
|
return strings.Join([]string{lastName, firstName}, " ")
|
||||||
|
}
|
||||||
+83
-8
@@ -3,6 +3,13 @@ package tests_test
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"msp-admin-service/assembly"
|
||||||
|
"msp-admin-service/conf"
|
||||||
|
"msp-admin-service/domain"
|
||||||
|
"msp-admin-service/entity"
|
||||||
|
"msp-admin-service/repository"
|
||||||
|
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
"github.com/txix-open/isp-kit/dbx"
|
"github.com/txix-open/isp-kit/dbx"
|
||||||
@@ -13,11 +20,6 @@ import (
|
|||||||
"github.com/txix-open/isp-kit/test/grpct"
|
"github.com/txix-open/isp-kit/test/grpct"
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
"google.golang.org/grpc/status"
|
"google.golang.org/grpc/status"
|
||||||
"msp-admin-service/assembly"
|
|
||||||
"msp-admin-service/conf"
|
|
||||||
"msp-admin-service/domain"
|
|
||||||
"msp-admin-service/entity"
|
|
||||||
"msp-admin-service/repository"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAuditSuite(t *testing.T) {
|
func TestAuditSuite(t *testing.T) {
|
||||||
@@ -27,6 +29,7 @@ func TestAuditSuite(t *testing.T) {
|
|||||||
|
|
||||||
type AuditSuite struct {
|
type AuditSuite struct {
|
||||||
suite.Suite
|
suite.Suite
|
||||||
|
|
||||||
test *test.Test
|
test *test.Test
|
||||||
db *dbt.TestDb
|
db *dbt.TestDb
|
||||||
grpcCli *client.Client
|
grpcCli *client.Client
|
||||||
@@ -60,12 +63,18 @@ func (t *AuditSuite) SetupTest() {
|
|||||||
Event: entity.EventUserChanged,
|
Event: entity.EventUserChanged,
|
||||||
Name: "изменение пользователя",
|
Name: "изменение пользователя",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Event: entity.EventUserBlocked,
|
||||||
|
Name: "изменение статуса блокировки пользователя",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
AuditTTl: conf.AuditTTlSetting{},
|
AuditTTl: conf.AuditTTlSetting{},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
cfg := assembly.NewLocator(testInstance.Logger(), httpcli.New(), t.db).
|
cfg := assembly.NewLocator(testInstance.Logger(), httpcli.New(), t.db).
|
||||||
Config(context.Background(), emptyLdap, remote)
|
Config(context.Background(), remote, time.Minute)
|
||||||
|
|
||||||
|
t.insertAuditLogs()
|
||||||
|
|
||||||
server, apiCli := grpct.TestServer(testInstance, cfg.Handler)
|
server, apiCli := grpct.TestServer(testInstance, cfg.Handler)
|
||||||
t.grpcCli = apiCli
|
t.grpcCli = apiCli
|
||||||
@@ -89,6 +98,7 @@ func (t *AuditSuite) Test_Events_DefaultEvents() {
|
|||||||
entity.EventSuccessLogout: "успешный выход",
|
entity.EventSuccessLogout: "успешный выход",
|
||||||
entity.EventRoleChanged: "изменение роли",
|
entity.EventRoleChanged: "изменение роли",
|
||||||
entity.EventUserChanged: "изменение пользователя",
|
entity.EventUserChanged: "изменение пользователя",
|
||||||
|
entity.EventUserBlocked: "изменение статуса блокировки пользователя",
|
||||||
}
|
}
|
||||||
for _, event := range response {
|
for _, event := range response {
|
||||||
name, found := expectedEventList[event.Event]
|
name, found := expectedEventList[event.Event]
|
||||||
@@ -108,6 +118,7 @@ func (t *AuditSuite) Test_Events_SortEvents() {
|
|||||||
{Event: entity.EventSuccessLogout, Enable: true},
|
{Event: entity.EventSuccessLogout, Enable: true},
|
||||||
{Event: entity.EventRoleChanged, Enable: false},
|
{Event: entity.EventRoleChanged, Enable: false},
|
||||||
{Event: entity.EventUserChanged, Enable: true},
|
{Event: entity.EventUserChanged, Enable: true},
|
||||||
|
{Event: entity.EventUserBlocked, Enable: true},
|
||||||
{Event: "новый#2", Enable: false},
|
{Event: "новый#2", Enable: false},
|
||||||
})
|
})
|
||||||
t.Require().NoError(err)
|
t.Require().NoError(err)
|
||||||
@@ -120,9 +131,9 @@ func (t *AuditSuite) Test_Events_SortEvents() {
|
|||||||
t.Require().NoError(err)
|
t.Require().NoError(err)
|
||||||
|
|
||||||
expectedSort := []bool{
|
expectedSort := []bool{
|
||||||
true, true, true, false, false, false, false,
|
true, true, true, true, false, false, false, false,
|
||||||
}
|
}
|
||||||
t.Require().Equal(len(expectedSort), len(response))
|
t.Require().Equal(len(expectedSort), len(response)) // nolint:testifylint
|
||||||
for i, event := range response {
|
for i, event := range response {
|
||||||
t.Require().Equal(expectedSort[i], event.Enabled)
|
t.Require().Equal(expectedSort[i], event.Enabled)
|
||||||
}
|
}
|
||||||
@@ -144,6 +155,7 @@ func (t *AuditSuite) Test_SetEvents_HappyPath() {
|
|||||||
entity.EventSuccessLogout: true,
|
entity.EventSuccessLogout: true,
|
||||||
entity.EventRoleChanged: false,
|
entity.EventRoleChanged: false,
|
||||||
entity.EventUserChanged: true,
|
entity.EventUserChanged: true,
|
||||||
|
entity.EventUserBlocked: true,
|
||||||
}
|
}
|
||||||
eventRep := repository.NewAuditEvent(t.db)
|
eventRep := repository.NewAuditEvent(t.db)
|
||||||
eventList, err := eventRep.All(context.Background())
|
eventList, err := eventRep.All(context.Background())
|
||||||
@@ -170,3 +182,66 @@ func (t *AuditSuite) Test_SetEvents_InvalidEvent() {
|
|||||||
t.Require().True(isStatus)
|
t.Require().True(isStatus)
|
||||||
t.Require().Equal(codes.InvalidArgument, s.Code())
|
t.Require().Equal(codes.InvalidArgument, s.Code())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *AuditSuite) Test_All_Logs() {
|
||||||
|
request := domain.AuditPageRequest{
|
||||||
|
LimitOffestParams: domain.LimitOffestParams{
|
||||||
|
Limit: 3,
|
||||||
|
Offset: 5,
|
||||||
|
},
|
||||||
|
Order: &domain.OrderParams{
|
||||||
|
Field: "user_id",
|
||||||
|
Type: "desc",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
var response *domain.AuditResponse
|
||||||
|
err := t.grpcCli.
|
||||||
|
Invoke("admin/log/all").
|
||||||
|
JsonRequestBody(request).
|
||||||
|
JsonResponseBody(&response).
|
||||||
|
Do(context.Background())
|
||||||
|
t.Require().NoError(err)
|
||||||
|
|
||||||
|
t.Require().Len(response.Items, 3)
|
||||||
|
t.Require().EqualValues(5, response.Items[0].UserId)
|
||||||
|
t.Require().EqualValues(4, response.Items[1].UserId)
|
||||||
|
t.Require().EqualValues(3, response.Items[2].UserId)
|
||||||
|
|
||||||
|
msg := "Выход"
|
||||||
|
request.Query = &domain.AuditQuery{
|
||||||
|
Message: &msg,
|
||||||
|
}
|
||||||
|
request.Limit = 10
|
||||||
|
request.Offset = 0
|
||||||
|
|
||||||
|
err = t.grpcCli.
|
||||||
|
Invoke("admin/log/all").
|
||||||
|
JsonRequestBody(request).
|
||||||
|
JsonResponseBody(&response).
|
||||||
|
Do(context.Background())
|
||||||
|
t.Require().NoError(err)
|
||||||
|
|
||||||
|
t.Require().Len(response.Items, 6)
|
||||||
|
t.Require().EqualValues(6, response.TotalCount)
|
||||||
|
t.Require().EqualValues(10, response.Items[0].UserId)
|
||||||
|
t.Require().EqualValues(9, response.Items[1].UserId)
|
||||||
|
t.Require().EqualValues(8, response.Items[2].UserId)
|
||||||
|
t.Require().EqualValues(7, response.Items[3].UserId)
|
||||||
|
t.Require().EqualValues(6, response.Items[4].UserId)
|
||||||
|
t.Require().EqualValues(5, response.Items[5].UserId)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *AuditSuite) insertAuditLogs() {
|
||||||
|
t.db.Must().Exec(`INSERT INTO audit (user_id, message, created_at, event)
|
||||||
|
VALUES (1, 'Успешный вход', NOW(), 'success_login'),
|
||||||
|
(2, 'Успешный вход', NOW(), 'success_login'),
|
||||||
|
(3, 'Неуспешный вход', NOW(), 'unsuccess_login'),
|
||||||
|
(4, 'Неуспешный вход', NOW(), 'unsuccess_login'),
|
||||||
|
(5, 'Успешный выход', NOW(), 'success_logout'),
|
||||||
|
(6, 'Успешный выход', NOW(), 'success_logout'),
|
||||||
|
(7, 'Неуспешный выход', NOW(), 'unsuccess_logout'),
|
||||||
|
(8, 'Неуспешный выход', NOW(), 'unsuccess_logout'),
|
||||||
|
(9, 'Выход', NOW(), 'logout'),
|
||||||
|
(10, 'Выход', NOW(), 'logout')`)
|
||||||
|
}
|
||||||
+70
-37
@@ -5,19 +5,21 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"golang.org/x/sync/errgroup"
|
|
||||||
"msp-admin-service/assembly"
|
"msp-admin-service/assembly"
|
||||||
"msp-admin-service/conf"
|
"msp-admin-service/conf"
|
||||||
"msp-admin-service/domain"
|
"msp-admin-service/domain"
|
||||||
"msp-admin-service/entity"
|
"msp-admin-service/entity"
|
||||||
"msp-admin-service/repository"
|
"msp-admin-service/repository"
|
||||||
|
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"golang.org/x/sync/errgroup"
|
||||||
|
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
"github.com/txix-open/isp-kit/dbx"
|
"github.com/txix-open/isp-kit/dbx"
|
||||||
"github.com/txix-open/isp-kit/grpc/client"
|
"github.com/txix-open/isp-kit/grpc/client"
|
||||||
@@ -37,6 +39,7 @@ func TestAuthTestSuite(t *testing.T) {
|
|||||||
|
|
||||||
type AuthTestSuite struct {
|
type AuthTestSuite struct {
|
||||||
suite.Suite
|
suite.Suite
|
||||||
|
|
||||||
test *test.Test
|
test *test.Test
|
||||||
db *dbt.TestDb
|
db *dbt.TestDb
|
||||||
grpcCli *client.Client
|
grpcCli *client.Client
|
||||||
@@ -50,12 +53,13 @@ func (s *AuthTestSuite) SetupTest() {
|
|||||||
s.httpCli = httpcli.New()
|
s.httpCli = httpcli.New()
|
||||||
|
|
||||||
mocksrv, host := s.initMockSudir()
|
mocksrv, host := s.initMockSudir()
|
||||||
|
sudirHost, _ := url.JoinPath(host, "/blitz/")
|
||||||
|
|
||||||
remote := conf.Remote{
|
remote := conf.Remote{
|
||||||
SudirAuth: &conf.SudirAuth{
|
SudirAuth: &conf.SudirAuth{
|
||||||
ClientId: "admin",
|
ClientId: "admin",
|
||||||
ClientSecret: "admin",
|
ClientSecret: "admin",
|
||||||
Host: host,
|
Host: sudirHost,
|
||||||
RedirectURI: "http://localhost",
|
RedirectURI: "http://localhost",
|
||||||
},
|
},
|
||||||
ExpireSec: 3600,
|
ExpireSec: 3600,
|
||||||
@@ -65,7 +69,7 @@ func (s *AuthTestSuite) SetupTest() {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
cfg := assembly.NewLocator(testInstance.Logger(), s.httpCli, s.db).
|
cfg := assembly.NewLocator(testInstance.Logger(), s.httpCli, s.db).
|
||||||
Config(context.Background(), emptyLdap, remote)
|
Config(context.Background(), remote, time.Minute)
|
||||||
|
|
||||||
server, apiCli := grpct.TestServer(testInstance, cfg.Handler)
|
server, apiCli := grpct.TestServer(testInstance, cfg.Handler)
|
||||||
s.grpcCli = apiCli
|
s.grpcCli = apiCli
|
||||||
@@ -96,6 +100,8 @@ func (s *AuthTestSuite) TestLoginHappyPath() {
|
|||||||
|
|
||||||
tokenInfo := SelectTokenEntityByToken(s.db, response.Token)
|
tokenInfo := SelectTokenEntityByToken(s.db, response.Token)
|
||||||
s.Require().Equal(tokenInfo.UserId, id)
|
s.Require().Equal(tokenInfo.UserId, id)
|
||||||
|
|
||||||
|
time.Sleep(1 * time.Second) // wait for go SaveAuditAsync()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *AuthTestSuite) TestLoginNotFound() {
|
func (s *AuthTestSuite) TestLoginNotFound() {
|
||||||
@@ -109,6 +115,8 @@ func (s *AuthTestSuite) TestLoginNotFound() {
|
|||||||
st, ok := status.FromError(err)
|
st, ok := status.FromError(err)
|
||||||
s.Require().True(ok)
|
s.Require().True(ok)
|
||||||
s.Require().Equal(codes.Unauthenticated, st.Code())
|
s.Require().Equal(codes.Unauthenticated, st.Code())
|
||||||
|
|
||||||
|
time.Sleep(1 * time.Second) // wait for go SaveAuditAsync()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *AuthTestSuite) TestBlockedUser() {
|
func (s *AuthTestSuite) TestBlockedUser() {
|
||||||
@@ -130,6 +138,8 @@ func (s *AuthTestSuite) TestBlockedUser() {
|
|||||||
st, ok := status.FromError(err)
|
st, ok := status.FromError(err)
|
||||||
s.Require().True(ok)
|
s.Require().True(ok)
|
||||||
s.Require().Equal(codes.Unauthenticated, st.Code())
|
s.Require().Equal(codes.Unauthenticated, st.Code())
|
||||||
|
|
||||||
|
time.Sleep(1 * time.Second) // wait for go SaveAuditAsync()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *AuthTestSuite) TestLoginWrongPassword() {
|
func (s *AuthTestSuite) TestLoginWrongPassword() {
|
||||||
@@ -150,6 +160,8 @@ func (s *AuthTestSuite) TestLoginWrongPassword() {
|
|||||||
st, ok := status.FromError(err)
|
st, ok := status.FromError(err)
|
||||||
s.Require().True(ok)
|
s.Require().True(ok)
|
||||||
s.Require().Equal(codes.Unauthenticated, st.Code())
|
s.Require().Equal(codes.Unauthenticated, st.Code())
|
||||||
|
|
||||||
|
time.Sleep(1 * time.Second) // wait for go SaveAuditAsync()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *AuthTestSuite) TestSudirLoginHappyPath() {
|
func (s *AuthTestSuite) TestSudirLoginHappyPath() {
|
||||||
@@ -163,42 +175,14 @@ func (s *AuthTestSuite) TestSudirLoginHappyPath() {
|
|||||||
Do(context.Background())
|
Do(context.Background())
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
user := entity.User{}
|
user := entity.User{}
|
||||||
s.db.Must().SelectRow(&user, "select id, email from users where sudir_user_id = $1", "sudirUser1")
|
s.db.Must().SelectRow(&user, "select id, email, full_name from users where sudir_user_id = $1", "sudirUser1")
|
||||||
s.Require().Equal("sudir@email.ru", user.Email)
|
s.Require().Equal("sudir@email.ru", user.Email)
|
||||||
|
s.Require().Equal("surname name patronymic", user.FullName)
|
||||||
|
|
||||||
tokenInfo := SelectTokenEntityByToken(s.db, response.Token)
|
tokenInfo := SelectTokenEntityByToken(s.db, response.Token)
|
||||||
s.Require().Equal(tokenInfo.UserId, user.Id)
|
s.Require().Equal(tokenInfo.UserId, user.Id)
|
||||||
}
|
|
||||||
|
|
||||||
func (s *AuthTestSuite) initMockSudir() (*httptest.Server, string) {
|
time.Sleep(1 * time.Second) // wait for go SaveAuditAsync()
|
||||||
mux := http.NewServeMux()
|
|
||||||
mux.HandleFunc("/blitz/oauth/te", func(writer http.ResponseWriter, request *http.Request) {
|
|
||||||
res := entity.SudirTokenResponse{
|
|
||||||
SudirAuthError: nil,
|
|
||||||
IdToken: "1",
|
|
||||||
AccessToken: "token",
|
|
||||||
}
|
|
||||||
data, err := json.Marshal(res)
|
|
||||||
s.Require().NoError(err) //nolint:testifylint
|
|
||||||
_, err = writer.Write(data)
|
|
||||||
s.NoError(err)
|
|
||||||
})
|
|
||||||
mux.HandleFunc("/blitz/oauth/me", func(writer http.ResponseWriter, request *http.Request) {
|
|
||||||
res := entity.SudirUserResponse{
|
|
||||||
SudirAuthError: nil,
|
|
||||||
Email: "sudir@email.ru",
|
|
||||||
Groups: []string{"DIT-KKD-Admins"},
|
|
||||||
Sub: "sudirUser1",
|
|
||||||
GivenName: "name",
|
|
||||||
FamilyName: "surname",
|
|
||||||
}
|
|
||||||
data, err := json.Marshal(res)
|
|
||||||
s.Require().NoError(err) //nolint:testifylint
|
|
||||||
_, err = writer.Write(data)
|
|
||||||
s.NoError(err)
|
|
||||||
})
|
|
||||||
srv := httptest.NewServer(mux)
|
|
||||||
return srv, srv.URL
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *AuthTestSuite) Test_Logout_HappyPath() {
|
func (s *AuthTestSuite) Test_Logout_HappyPath() {
|
||||||
@@ -217,6 +201,8 @@ func (s *AuthTestSuite) Test_Logout_HappyPath() {
|
|||||||
|
|
||||||
tokenInfo := SelectTokenEntityByToken(s.db, "token-841297641213")
|
tokenInfo := SelectTokenEntityByToken(s.db, "token-841297641213")
|
||||||
s.Require().Equal(entity.TokenStatusRevoked, tokenInfo.Status)
|
s.Require().Equal(entity.TokenStatusRevoked, tokenInfo.Status)
|
||||||
|
|
||||||
|
time.Sleep(1 * time.Second) // wait for go SaveAuditAsync()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *AuthTestSuite) Test_Logout_NotFound() {
|
func (s *AuthTestSuite) Test_Logout_NotFound() {
|
||||||
@@ -227,10 +213,21 @@ func (s *AuthTestSuite) Test_Logout_NotFound() {
|
|||||||
|
|
||||||
time.Sleep(time.Second)
|
time.Sleep(time.Second)
|
||||||
audit := repository.NewAudit(s.db)
|
audit := repository.NewAudit(s.db)
|
||||||
auditList, err := audit.All(context.Background(), 10, 0)
|
auditList, err := audit.AllByRequest(context.Background(), domain.AuditPageRequest{
|
||||||
|
LimitOffestParams: domain.LimitOffestParams{
|
||||||
|
Limit: 10,
|
||||||
|
Offset: 0,
|
||||||
|
},
|
||||||
|
Order: &domain.OrderParams{
|
||||||
|
Field: "created_at",
|
||||||
|
Type: "desc",
|
||||||
|
},
|
||||||
|
})
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().Len(auditList, 1) //nolint:mnd
|
s.Require().Len(auditList, 1)
|
||||||
s.Require().Equal(entity.EventSuccessLogout, auditList[0].Event)
|
s.Require().Equal(entity.EventSuccessLogout, auditList[0].Event)
|
||||||
|
|
||||||
|
time.Sleep(1 * time.Second) // wait for go SaveAuditAsync()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *AuthTestSuite) Test_Logout_AlreadyRevoke() {
|
func (s *AuthTestSuite) Test_Logout_AlreadyRevoke() {
|
||||||
@@ -249,6 +246,8 @@ func (s *AuthTestSuite) Test_Logout_AlreadyRevoke() {
|
|||||||
|
|
||||||
tokenInfo := SelectTokenEntityByToken(s.db, "token-148623719462")
|
tokenInfo := SelectTokenEntityByToken(s.db, "token-148623719462")
|
||||||
s.Require().Equal(entity.TokenStatusRevoked, tokenInfo.Status)
|
s.Require().Equal(entity.TokenStatusRevoked, tokenInfo.Status)
|
||||||
|
|
||||||
|
time.Sleep(1 * time.Second) // wait for go SaveAuditAsync()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *AuthTestSuite) TestBruteForceLogin() {
|
func (s *AuthTestSuite) TestBruteForceLogin() {
|
||||||
@@ -295,4 +294,38 @@ func (s *AuthTestSuite) TestBruteForceLogin() {
|
|||||||
|
|
||||||
s.Require().EqualValues(97, tooManyRequestsErrorCount.Load())
|
s.Require().EqualValues(97, tooManyRequestsErrorCount.Load())
|
||||||
s.Require().EqualValues(3, unauthorizedErrorCount.Load())
|
s.Require().EqualValues(3, unauthorizedErrorCount.Load())
|
||||||
|
|
||||||
|
time.Sleep(2 * time.Second) // wait for go SaveAuditAsync()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *AuthTestSuite) initMockSudir() (*httptest.Server, string) {
|
||||||
|
mux := http.NewServeMux()
|
||||||
|
mux.HandleFunc("/blitz/oauth/te", func(writer http.ResponseWriter, request *http.Request) {
|
||||||
|
res := entity.SudirTokenResponse{
|
||||||
|
SudirAuthError: nil,
|
||||||
|
IdToken: "1",
|
||||||
|
AccessToken: "token",
|
||||||
|
}
|
||||||
|
data, err := json.Marshal(res)
|
||||||
|
s.Require().NoError(err) //nolint:testifylint
|
||||||
|
_, err = writer.Write(data)
|
||||||
|
s.NoError(err)
|
||||||
|
})
|
||||||
|
mux.HandleFunc("/blitz/oauth/me", func(writer http.ResponseWriter, request *http.Request) {
|
||||||
|
res := entity.SudirUserResponse{
|
||||||
|
SudirAuthError: nil,
|
||||||
|
Email: "sudir@email.ru",
|
||||||
|
Groups: []string{"DIT-KKD-Admins"},
|
||||||
|
Sub: "sudirUser1",
|
||||||
|
GivenName: "name",
|
||||||
|
FamilyName: "surname",
|
||||||
|
Name: "surname name patronymic",
|
||||||
|
}
|
||||||
|
data, err := json.Marshal(res)
|
||||||
|
s.Require().NoError(err) //nolint:testifylint
|
||||||
|
_, err = writer.Write(data)
|
||||||
|
s.NoError(err)
|
||||||
|
})
|
||||||
|
srv := httptest.NewServer(mux)
|
||||||
|
return srv, srv.URL
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,7 @@ package tests_test
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
"github.com/txix-open/isp-kit/dbx"
|
"github.com/txix-open/isp-kit/dbx"
|
||||||
@@ -21,6 +22,7 @@ func TestCustomizationTestSuite(t *testing.T) {
|
|||||||
|
|
||||||
type CustomizationTestSuite struct {
|
type CustomizationTestSuite struct {
|
||||||
suite.Suite
|
suite.Suite
|
||||||
|
|
||||||
test *test.Test
|
test *test.Test
|
||||||
db *dbt.TestDb
|
db *dbt.TestDb
|
||||||
grpcCli *client.Client
|
grpcCli *client.Client
|
||||||
@@ -39,7 +41,7 @@ func (s *CustomizationTestSuite) SetupTest() {
|
|||||||
ExpireSec: 0,
|
ExpireSec: 0,
|
||||||
}
|
}
|
||||||
cfg := assembly.NewLocator(testInstance.Logger(), nil, s.db).
|
cfg := assembly.NewLocator(testInstance.Logger(), nil, s.db).
|
||||||
Config(context.Background(), emptyLdap, remote)
|
Config(context.Background(), remote, time.Minute)
|
||||||
|
|
||||||
server, apiCli := grpct.TestServer(testInstance, cfg.Handler)
|
server, apiCli := grpct.TestServer(testInstance, cfg.Handler)
|
||||||
s.grpcCli = apiCli
|
s.grpcCli = apiCli
|
||||||
|
|||||||
@@ -1,31 +1,31 @@
|
|||||||
package tests_test
|
package tests_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"msp-admin-service/entity"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/txix-open/isp-kit/db/query"
|
"github.com/txix-open/isp-kit/db/query"
|
||||||
"github.com/txix-open/isp-kit/test/dbt"
|
"github.com/txix-open/isp-kit/test/dbt"
|
||||||
"golang.org/x/crypto/bcrypt"
|
"golang.org/x/crypto/bcrypt"
|
||||||
"msp-admin-service/entity"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
//nolint:gomnd
|
|
||||||
func InsertUser(db *dbt.TestDb, user entity.User) int64 {
|
func InsertUser(db *dbt.TestDb, user entity.User) int64 {
|
||||||
if user.Password != "" {
|
if user.Password != "" {
|
||||||
passwordBytes, _ := bcrypt.GenerateFromPassword([]byte(user.Password), 12)
|
passwordBytes, _ := bcrypt.GenerateFromPassword([]byte(user.Password), 12)
|
||||||
user.Password = string(passwordBytes)
|
user.Password = string(passwordBytes)
|
||||||
}
|
}
|
||||||
var id int64
|
var id int64
|
||||||
db.Must().SelectRow(&id, `insert into users (first_name, last_name, email, password, blocked)
|
db.Must().SelectRow(&id, `insert into users (first_name, last_name, full_name, email, password, blocked, last_active_at)
|
||||||
values($1,$2,$3,$4,$5) returning id`,
|
values($1,$2,$3,$4,$5,$6,$7) returning id`,
|
||||||
user.FirstName, user.LastName, user.Email, user.Password, user.Blocked)
|
user.FirstName, user.LastName, user.FullName, user.Email, user.Password, user.Blocked, user.LastActiveAt)
|
||||||
return id
|
return id
|
||||||
}
|
}
|
||||||
|
|
||||||
func InsertSudirUser(db *dbt.TestDb, user entity.SudirUser) int64 {
|
func InsertSudirUser(db *dbt.TestDb, user entity.SudirUser) int64 {
|
||||||
q, args, err := query.New().
|
q, args, err := query.New().
|
||||||
Insert("users").
|
Insert("users").
|
||||||
Columns("sudir_user_id", "first_name", "last_name", "email").
|
Columns("sudir_user_id", "first_name", "last_name", "full_name", "email").
|
||||||
Values(user.SudirUserId, user.FirstName, user.LastName, user.Email).
|
Values(user.SudirUserId, user.FirstName, user.LastName, user.FullName, user.Email).
|
||||||
Suffix("RETURNING id").
|
Suffix("RETURNING id").
|
||||||
ToSql()
|
ToSql()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
+29
-30
@@ -1,19 +1,21 @@
|
|||||||
package tests_test
|
package tests_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"msp-admin-service/domain"
|
||||||
|
"msp-admin-service/service/inactive_worker"
|
||||||
|
|
||||||
|
"msp-admin-service/assembly"
|
||||||
|
"msp-admin-service/conf"
|
||||||
|
"msp-admin-service/entity"
|
||||||
|
"msp-admin-service/repository"
|
||||||
|
|
||||||
"github.com/txix-open/isp-kit/bgjobx"
|
"github.com/txix-open/isp-kit/bgjobx"
|
||||||
"github.com/txix-open/isp-kit/dbx"
|
"github.com/txix-open/isp-kit/dbx"
|
||||||
"github.com/txix-open/isp-kit/test"
|
"github.com/txix-open/isp-kit/test"
|
||||||
"github.com/txix-open/isp-kit/test/dbt"
|
"github.com/txix-open/isp-kit/test/dbt"
|
||||||
"msp-admin-service/assembly"
|
|
||||||
"msp-admin-service/conf"
|
|
||||||
"msp-admin-service/entity"
|
|
||||||
"msp-admin-service/repository"
|
|
||||||
"msp-admin-service/service/inactive_worker"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestInactiveWorker(t *testing.T) {
|
func TestInactiveWorker(t *testing.T) {
|
||||||
@@ -22,44 +24,41 @@ func TestInactiveWorker(t *testing.T) {
|
|||||||
test, require := test.New(t)
|
test, require := test.New(t)
|
||||||
db := dbt.New(test, dbx.WithMigrationRunner("../migrations", test.Logger()))
|
db := dbt.New(test, dbx.WithMigrationRunner("../migrations", test.Logger()))
|
||||||
|
|
||||||
userId := InsertUser(db, entity.User{Email: "a@test"})
|
userId := InsertUser(db, entity.User{Email: "a@test", LastActiveAt: time.Now().UTC().Add(-5 * 24 * time.Hour)})
|
||||||
InsertUser(db, entity.User{Email: "b@test"})
|
InsertUser(db, entity.User{Email: "b@test", LastActiveAt: time.Now().UTC()})
|
||||||
InsertTokenEntity(db, entity.Token{
|
|
||||||
Id: 0,
|
|
||||||
Token: "123",
|
|
||||||
UserId: userId,
|
|
||||||
Status: entity.TokenStatusAllowed,
|
|
||||||
CreatedAt: time.Now().UTC().Add(-48 * time.Hour),
|
|
||||||
})
|
|
||||||
InsertTokenEntity(db, entity.Token{
|
|
||||||
Id: 0,
|
|
||||||
Token: "234",
|
|
||||||
UserId: userId,
|
|
||||||
Status: entity.TokenStatusAllowed,
|
|
||||||
CreatedAt: time.Now().UTC().Add(-5 * 24 * time.Hour),
|
|
||||||
})
|
|
||||||
|
|
||||||
config := assembly.NewLocator(test.Logger(), nil, db).
|
config := assembly.NewLocator(test.Logger(), nil, db).
|
||||||
Config(context.Background(), emptyLdap, conf.Remote{
|
Config(t.Context(), conf.Remote{
|
||||||
BlockInactiveWorker: conf.BlockInactiveWorker{
|
BlockInactiveWorker: conf.BlockInactiveWorker{
|
||||||
DaysThreshold: 1,
|
DaysThreshold: 1,
|
||||||
RunIntervalInMinutes: 60,
|
RunIntervalInMinutes: 1,
|
||||||
},
|
},
|
||||||
})
|
}, 500*time.Millisecond)
|
||||||
|
|
||||||
bgjobCli := bgjobx.NewClient(db, test.Logger())
|
bgjobCli := bgjobx.NewClient(db, test.Logger())
|
||||||
assembly.JobPollInterval = 300 * time.Millisecond
|
err := inactive_worker.EnqueueSeedJob(t.Context(), bgjobCli)
|
||||||
err := bgjobCli.Upgrade(context.Background(), config.BgJobCfg)
|
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
err = inactive_worker.EnqueueSeedJob(context.Background(), bgjobCli)
|
err = bgjobCli.Upgrade(t.Context(), config.BgJobCfg)
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
|
|
||||||
time.Sleep(5 * time.Second)
|
time.Sleep(5 * time.Second)
|
||||||
|
|
||||||
user, err := repository.NewUser(db).GetUserById(context.Background(), userId)
|
user, err := repository.NewUser(db).GetUserById(t.Context(), userId)
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
require.True(user.Blocked)
|
require.True(user.Blocked)
|
||||||
|
|
||||||
list, err := repository.NewAudit(db).All(context.Background(), 10, 0)
|
list, err := repository.NewAudit(db).AllByRequest(t.Context(), domain.AuditPageRequest{
|
||||||
|
LimitOffestParams: domain.LimitOffestParams{
|
||||||
|
Limit: 10,
|
||||||
|
Offset: 0,
|
||||||
|
},
|
||||||
|
Order: &domain.OrderParams{
|
||||||
|
Field: "created_at",
|
||||||
|
Type: "desc",
|
||||||
|
},
|
||||||
|
})
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
require.Len(list, 1)
|
require.Len(list, 1)
|
||||||
|
|
||||||
|
time.Sleep(1 * time.Second) // wait for go SaveAuditAsync()
|
||||||
}
|
}
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
package tests_test
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"msp-admin-service/conf"
|
|
||||||
"msp-admin-service/service/ldap"
|
|
||||||
)
|
|
||||||
|
|
||||||
type mockLdap struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m mockLdap) IsExist(ctx context.Context, dn string) (bool, error) {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m mockLdap) DnByUserPrincipalName(ctx context.Context, principalName string) (string, error) {
|
|
||||||
return principalName, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m mockLdap) ModifyMemberAttr(ctx context.Context, userDn string, groupDn string, operation string) error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m mockLdap) Close() error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
//nolint:gochecknoglobals
|
|
||||||
emptyLdap = ldap.RepoSupplier(func(config *conf.Ldap) (ldap.Repo, error) {
|
|
||||||
return mockLdap{}, nil
|
|
||||||
})
|
|
||||||
)
|
|
||||||
@@ -26,6 +26,7 @@ func TestSecureSuite(t *testing.T) {
|
|||||||
|
|
||||||
type SecureSuite struct {
|
type SecureSuite struct {
|
||||||
suite.Suite
|
suite.Suite
|
||||||
|
|
||||||
test *test.Test
|
test *test.Test
|
||||||
require *require.Assertions
|
require *require.Assertions
|
||||||
db *dbt.TestDb
|
db *dbt.TestDb
|
||||||
@@ -40,7 +41,7 @@ func (s *SecureSuite) SetupTest() {
|
|||||||
ExpireSec: 3600,
|
ExpireSec: 3600,
|
||||||
}
|
}
|
||||||
cfg := assembly.NewLocator(s.test.Logger(), httpCli, s.db).
|
cfg := assembly.NewLocator(s.test.Logger(), httpCli, s.db).
|
||||||
Config(context.Background(), emptyLdap, remote)
|
Config(context.Background(), remote, time.Minute)
|
||||||
|
|
||||||
server, apiCli := grpct.TestServer(s.test, cfg.Handler)
|
server, apiCli := grpct.TestServer(s.test, cfg.Handler)
|
||||||
s.test.T().Cleanup(func() {
|
s.test.T().Cleanup(func() {
|
||||||
|
|||||||
@@ -0,0 +1,276 @@
|
|||||||
|
package tests_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"strconv"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"msp-admin-service/assembly"
|
||||||
|
"msp-admin-service/conf"
|
||||||
|
"msp-admin-service/domain"
|
||||||
|
"msp-admin-service/entity"
|
||||||
|
"msp-admin-service/service/session_worker"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/suite"
|
||||||
|
"github.com/txix-open/isp-kit/bgjobx"
|
||||||
|
"github.com/txix-open/isp-kit/dbx"
|
||||||
|
"github.com/txix-open/isp-kit/grpc/client"
|
||||||
|
"github.com/txix-open/isp-kit/http/httpcli"
|
||||||
|
"github.com/txix-open/isp-kit/test"
|
||||||
|
"github.com/txix-open/isp-kit/test/dbt"
|
||||||
|
"github.com/txix-open/isp-kit/test/grpct"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestSessionSuite(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
suite.Run(t, &SessionSuite{})
|
||||||
|
}
|
||||||
|
|
||||||
|
type SessionSuite struct {
|
||||||
|
suite.Suite
|
||||||
|
|
||||||
|
test *test.Test
|
||||||
|
db *dbt.TestDb
|
||||||
|
config assembly.Config
|
||||||
|
grpcCli *client.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *SessionSuite) SetupTest() {
|
||||||
|
testInstance, _ := test.New(t.T())
|
||||||
|
t.test = testInstance
|
||||||
|
t.db = dbt.New(testInstance, dbx.WithMigrationRunner("../migrations", testInstance.Logger()))
|
||||||
|
|
||||||
|
remote := conf.Remote{
|
||||||
|
Audit: conf.Audit{
|
||||||
|
EventSettings: []conf.AuditEventSetting{
|
||||||
|
{
|
||||||
|
Event: entity.EventSuccessLogin,
|
||||||
|
Name: "успешный вход",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Event: entity.EventErrorLogin,
|
||||||
|
Name: "неуспешный вход",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Event: entity.EventSuccessLogout,
|
||||||
|
Name: "успешный выход",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Event: entity.EventRoleChanged,
|
||||||
|
Name: "изменение роли",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Event: entity.EventUserChanged,
|
||||||
|
Name: "изменение пользователя",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Event: entity.EventUserBlocked,
|
||||||
|
Name: "изменение статуса блокировки пользователя",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
AuditTTl: conf.AuditTTlSetting{},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
t.config = assembly.NewLocator(testInstance.Logger(), httpcli.New(), t.db).
|
||||||
|
Config(context.Background(), remote, 500*time.Millisecond)
|
||||||
|
|
||||||
|
server, apiCli := grpct.TestServer(testInstance, t.config.Handler)
|
||||||
|
t.grpcCli = apiCli
|
||||||
|
|
||||||
|
testInstance.T().Cleanup(func() {
|
||||||
|
server.Shutdown()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
//nolint:funlen
|
||||||
|
func (t *SessionSuite) Test_All_Session() {
|
||||||
|
userId := InsertUser(t.db, entity.User{Email: "test_1@aa.ru"})
|
||||||
|
timeNow := time.Now().UTC()
|
||||||
|
|
||||||
|
InsertTokenEntity(t.db, entity.Token{
|
||||||
|
Token: "test_token_1",
|
||||||
|
UserId: userId,
|
||||||
|
Status: entity.TokenStatusAllowed,
|
||||||
|
ExpiredAt: timeNow.Add(1 * time.Hour),
|
||||||
|
CreatedAt: timeNow.Add(-1 * time.Hour),
|
||||||
|
UpdatedAt: timeNow,
|
||||||
|
})
|
||||||
|
InsertTokenEntity(t.db, entity.Token{
|
||||||
|
Token: "test_token_2",
|
||||||
|
UserId: userId,
|
||||||
|
Status: entity.TokenStatusRevoked,
|
||||||
|
ExpiredAt: timeNow.Add(1 * time.Hour),
|
||||||
|
CreatedAt: timeNow.Add(-2 * time.Hour),
|
||||||
|
UpdatedAt: timeNow,
|
||||||
|
})
|
||||||
|
InsertTokenEntity(t.db, entity.Token{
|
||||||
|
Token: "test_token_3",
|
||||||
|
UserId: userId,
|
||||||
|
Status: entity.TokenStatusExpired,
|
||||||
|
ExpiredAt: timeNow.Add(-1 * time.Hour),
|
||||||
|
CreatedAt: timeNow.Add(-3 * time.Hour),
|
||||||
|
UpdatedAt: timeNow,
|
||||||
|
})
|
||||||
|
|
||||||
|
// Дефолт сортировка, лимит и оффсет
|
||||||
|
request := domain.SessionPageRequest{
|
||||||
|
LimitOffestParams: domain.LimitOffestParams{
|
||||||
|
Limit: 5,
|
||||||
|
Offset: 1,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
var response *domain.SessionResponse
|
||||||
|
err := t.grpcCli.
|
||||||
|
Invoke("admin/session/all").
|
||||||
|
JsonRequestBody(request).
|
||||||
|
JsonResponseBody(&response).
|
||||||
|
Do(context.Background())
|
||||||
|
t.Require().NoError(err)
|
||||||
|
|
||||||
|
t.Require().Len(response.Items, 2)
|
||||||
|
t.Require().EqualValues(3, response.TotalCount)
|
||||||
|
t.Require().EqualValues(2, response.Items[0].Id)
|
||||||
|
t.Require().EqualValues(3, response.Items[1].Id)
|
||||||
|
|
||||||
|
// Дефолт сортировка, поиск по expired_at
|
||||||
|
request.Offset = 0
|
||||||
|
request.Query = &domain.SessionQuery{
|
||||||
|
ExpiredAt: &domain.DateFromToParams{
|
||||||
|
From: timeNow,
|
||||||
|
To: timeNow.Add(24 * time.Hour),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
err = t.grpcCli.
|
||||||
|
Invoke("admin/session/all").
|
||||||
|
JsonRequestBody(request).
|
||||||
|
JsonResponseBody(&response).
|
||||||
|
Do(context.Background())
|
||||||
|
t.Require().NoError(err)
|
||||||
|
|
||||||
|
t.Require().Len(response.Items, 2)
|
||||||
|
t.Require().EqualValues(2, response.TotalCount)
|
||||||
|
t.Require().EqualValues(1, response.Items[0].Id)
|
||||||
|
t.Require().EqualValues(2, response.Items[1].Id)
|
||||||
|
|
||||||
|
// Сортировка по статусу, пустой запрос
|
||||||
|
request.Query = nil
|
||||||
|
request.Order = &domain.OrderParams{
|
||||||
|
Field: "status",
|
||||||
|
Type: "asc",
|
||||||
|
}
|
||||||
|
|
||||||
|
err = t.grpcCli.
|
||||||
|
Invoke("admin/session/all").
|
||||||
|
JsonRequestBody(request).
|
||||||
|
JsonResponseBody(&response).
|
||||||
|
Do(context.Background())
|
||||||
|
t.Require().NoError(err)
|
||||||
|
|
||||||
|
t.Require().Len(response.Items, 3)
|
||||||
|
t.Require().EqualValues(3, response.TotalCount)
|
||||||
|
t.Require().EqualValues(1, response.Items[0].Id)
|
||||||
|
t.Require().EqualValues(3, response.Items[1].Id)
|
||||||
|
t.Require().EqualValues(2, response.Items[2].Id)
|
||||||
|
|
||||||
|
// Сортировка по статусу, поиск по userId & status
|
||||||
|
resUserId := int(userId)
|
||||||
|
reqStatus := entity.TokenStatusExpired
|
||||||
|
request.Query = &domain.SessionQuery{
|
||||||
|
UserId: &resUserId,
|
||||||
|
Status: &reqStatus,
|
||||||
|
}
|
||||||
|
|
||||||
|
err = t.grpcCli.
|
||||||
|
Invoke("admin/session/all").
|
||||||
|
JsonRequestBody(request).
|
||||||
|
JsonResponseBody(&response).
|
||||||
|
Do(context.Background())
|
||||||
|
t.Require().NoError(err)
|
||||||
|
|
||||||
|
t.Require().Len(response.Items, 1)
|
||||||
|
t.Require().EqualValues(1, response.TotalCount)
|
||||||
|
t.Require().EqualValues(3, response.Items[0].Id)
|
||||||
|
|
||||||
|
// Сортировка по id, поиск по id
|
||||||
|
for i := range 20 {
|
||||||
|
userId = InsertUser(t.db, entity.User{Email: "test_11" + strconv.Itoa(i) + "@aa.ru"})
|
||||||
|
InsertTokenEntity(t.db, entity.Token{
|
||||||
|
Token: "test_token_1" + strconv.Itoa(i),
|
||||||
|
UserId: userId,
|
||||||
|
Status: entity.TokenStatusAllowed,
|
||||||
|
ExpiredAt: timeNow.Add(1 * time.Hour),
|
||||||
|
CreatedAt: timeNow,
|
||||||
|
UpdatedAt: timeNow,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
tokenId := 2
|
||||||
|
request = domain.SessionPageRequest{
|
||||||
|
LimitOffestParams: domain.LimitOffestParams{
|
||||||
|
Limit: 5,
|
||||||
|
Offset: 0,
|
||||||
|
},
|
||||||
|
Order: &domain.OrderParams{
|
||||||
|
Field: "id",
|
||||||
|
Type: "desc",
|
||||||
|
},
|
||||||
|
Query: &domain.SessionQuery{
|
||||||
|
Id: &tokenId,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
err = t.grpcCli.
|
||||||
|
Invoke("admin/session/all").
|
||||||
|
JsonRequestBody(request).
|
||||||
|
JsonResponseBody(&response).
|
||||||
|
Do(context.Background())
|
||||||
|
t.Require().NoError(err)
|
||||||
|
|
||||||
|
t.Require().Len(response.Items, 5)
|
||||||
|
t.Require().EqualValues(5, response.TotalCount)
|
||||||
|
t.Require().EqualValues(23, response.Items[0].Id)
|
||||||
|
t.Require().EqualValues(22, response.Items[1].Id)
|
||||||
|
t.Require().EqualValues(21, response.Items[2].Id)
|
||||||
|
t.Require().EqualValues(20, response.Items[3].Id)
|
||||||
|
t.Require().EqualValues(2, response.Items[4].Id)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *SessionSuite) Test_Session_Expired_Worker() {
|
||||||
|
userId := InsertUser(t.db, entity.User{Email: "a@test"})
|
||||||
|
|
||||||
|
InsertTokenEntity(t.db, entity.Token{
|
||||||
|
Token: "token_allowed",
|
||||||
|
UserId: userId,
|
||||||
|
Status: entity.TokenStatusAllowed,
|
||||||
|
ExpiredAt: time.Now().UTC().Add(24 * time.Hour)})
|
||||||
|
|
||||||
|
InsertTokenEntity(t.db, entity.Token{
|
||||||
|
Token: "token_expired",
|
||||||
|
UserId: userId,
|
||||||
|
Status: entity.TokenStatusAllowed,
|
||||||
|
ExpiredAt: time.Now().UTC().Add(-2 * time.Hour)})
|
||||||
|
|
||||||
|
InsertTokenEntity(t.db, entity.Token{
|
||||||
|
Token: "token_expired2",
|
||||||
|
UserId: userId,
|
||||||
|
Status: entity.TokenStatusAllowed,
|
||||||
|
ExpiredAt: time.Now().UTC().Add(-24 * time.Hour)})
|
||||||
|
|
||||||
|
bgjobCli := bgjobx.NewClient(t.db, t.test.Logger())
|
||||||
|
|
||||||
|
err := session_worker.EnqueueSeedJob(t.T().Context(), bgjobCli)
|
||||||
|
t.Require().NoError(err)
|
||||||
|
|
||||||
|
err = bgjobCli.Upgrade(t.T().Context(), t.config.BgJobCfg)
|
||||||
|
t.Require().NoError(err)
|
||||||
|
|
||||||
|
time.Sleep(2 * time.Second)
|
||||||
|
|
||||||
|
tokens := make([]entity.Token, 0)
|
||||||
|
t.db.Must().Select(&tokens, "SELECT * FROM tokens ORDER BY status ASC")
|
||||||
|
|
||||||
|
t.Require().EqualValues(entity.TokenStatusAllowed, tokens[0].Status)
|
||||||
|
t.Require().EqualValues(entity.TokenStatusExpired, tokens[1].Status)
|
||||||
|
t.Require().EqualValues(entity.TokenStatusExpired, tokens[2].Status)
|
||||||
|
}
|
||||||
+241
-21
@@ -2,12 +2,20 @@ package tests_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/txix-open/isp-kit/grpc/apierrors"
|
|
||||||
"golang.org/x/crypto/bcrypt"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/txix-open/isp-kit/grpc/apierrors"
|
||||||
|
"golang.org/x/crypto/bcrypt"
|
||||||
|
|
||||||
|
"msp-admin-service/assembly"
|
||||||
|
"msp-admin-service/conf"
|
||||||
|
"msp-admin-service/domain"
|
||||||
|
"msp-admin-service/entity"
|
||||||
|
"msp-admin-service/repository"
|
||||||
|
"msp-admin-service/service"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
"github.com/txix-open/isp-kit/dbx"
|
"github.com/txix-open/isp-kit/dbx"
|
||||||
@@ -18,12 +26,6 @@ import (
|
|||||||
"github.com/txix-open/isp-kit/test/grpct"
|
"github.com/txix-open/isp-kit/test/grpct"
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
"google.golang.org/grpc/status"
|
"google.golang.org/grpc/status"
|
||||||
"msp-admin-service/assembly"
|
|
||||||
"msp-admin-service/conf"
|
|
||||||
"msp-admin-service/domain"
|
|
||||||
"msp-admin-service/entity"
|
|
||||||
"msp-admin-service/repository"
|
|
||||||
"msp-admin-service/service"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type tokenService interface {
|
type tokenService interface {
|
||||||
@@ -37,6 +39,7 @@ func TestUserTestSuite(t *testing.T) {
|
|||||||
|
|
||||||
type UserTestSuite struct {
|
type UserTestSuite struct {
|
||||||
suite.Suite
|
suite.Suite
|
||||||
|
|
||||||
test *test.Test
|
test *test.Test
|
||||||
db *dbt.TestDb
|
db *dbt.TestDb
|
||||||
grpcCli *client.Client
|
grpcCli *client.Client
|
||||||
@@ -54,7 +57,7 @@ func (s *UserTestSuite) SetupTest() {
|
|||||||
ExpireSec: 0,
|
ExpireSec: 0,
|
||||||
}
|
}
|
||||||
cfg := assembly.NewLocator(testInstance.Logger(), s.httpCli, s.db).
|
cfg := assembly.NewLocator(testInstance.Logger(), s.httpCli, s.db).
|
||||||
Config(context.Background(), emptyLdap, remote)
|
Config(context.Background(), remote, time.Minute)
|
||||||
|
|
||||||
server, apiCli := grpct.TestServer(testInstance, cfg.Handler)
|
server, apiCli := grpct.TestServer(testInstance, cfg.Handler)
|
||||||
s.grpcCli = apiCli
|
s.grpcCli = apiCli
|
||||||
@@ -71,6 +74,7 @@ func (s *UserTestSuite) TestGetProfileHappyPath() {
|
|||||||
id := InsertUser(s.db, entity.User{
|
id := InsertUser(s.db, entity.User{
|
||||||
FirstName: "name",
|
FirstName: "name",
|
||||||
LastName: "surname",
|
LastName: "surname",
|
||||||
|
FullName: "surname name",
|
||||||
Email: "a@a.ru",
|
Email: "a@a.ru",
|
||||||
Password: "password",
|
Password: "password",
|
||||||
})
|
})
|
||||||
@@ -93,9 +97,11 @@ func (s *UserTestSuite) TestGetProfileHappyPath() {
|
|||||||
expected := domain.AdminUserShort{
|
expected := domain.AdminUserShort{
|
||||||
FirstName: "name",
|
FirstName: "name",
|
||||||
LastName: "surname",
|
LastName: "surname",
|
||||||
|
FullName: "surname name",
|
||||||
Email: "a@a.ru",
|
Email: "a@a.ru",
|
||||||
Role: "admin",
|
Role: "admin",
|
||||||
Roles: []int{1},
|
Roles: []int{1},
|
||||||
|
RoleNames: []string{"admin"},
|
||||||
Permissions: []string{},
|
Permissions: []string{},
|
||||||
}
|
}
|
||||||
s.Require().Equal(expected, response)
|
s.Require().Equal(expected, response)
|
||||||
@@ -105,6 +111,7 @@ func (s *UserTestSuite) TestGetProfileNotFound() {
|
|||||||
id := InsertUser(s.db, entity.User{
|
id := InsertUser(s.db, entity.User{
|
||||||
FirstName: "name",
|
FirstName: "name",
|
||||||
LastName: "surname",
|
LastName: "surname",
|
||||||
|
FullName: "surname name",
|
||||||
Email: "a@b.ru",
|
Email: "a@b.ru",
|
||||||
Password: "password",
|
Password: "password",
|
||||||
})
|
})
|
||||||
@@ -123,6 +130,7 @@ func (s *UserTestSuite) TestGetProfileSudir() {
|
|||||||
SudirUserId: "sudirUser1",
|
SudirUserId: "sudirUser1",
|
||||||
FirstName: "name",
|
FirstName: "name",
|
||||||
LastName: "surname",
|
LastName: "surname",
|
||||||
|
FullName: "surname name",
|
||||||
Email: "a@b.ru",
|
Email: "a@b.ru",
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -145,9 +153,11 @@ func (s *UserTestSuite) TestGetProfileSudir() {
|
|||||||
expected := domain.AdminUserShort{
|
expected := domain.AdminUserShort{
|
||||||
FirstName: "name",
|
FirstName: "name",
|
||||||
LastName: "surname",
|
LastName: "surname",
|
||||||
|
FullName: "surname name",
|
||||||
Email: "a@b.ru",
|
Email: "a@b.ru",
|
||||||
Role: "admin",
|
Role: "admin",
|
||||||
Roles: []int{1},
|
Roles: []int{1},
|
||||||
|
RoleNames: []string{"admin"},
|
||||||
Permissions: []string{},
|
Permissions: []string{},
|
||||||
}
|
}
|
||||||
s.Require().Equal(expected, response)
|
s.Require().Equal(expected, response)
|
||||||
@@ -156,23 +166,170 @@ func (s *UserTestSuite) TestGetProfileSudir() {
|
|||||||
func (s *UserTestSuite) TestGetUsers() {
|
func (s *UserTestSuite) TestGetUsers() {
|
||||||
InsertUser(s.db, entity.User{Email: "a1@a.ru"})
|
InsertUser(s.db, entity.User{Email: "a1@a.ru"})
|
||||||
InsertUser(s.db, entity.User{Email: "b1@a.ru"})
|
InsertUser(s.db, entity.User{Email: "b1@a.ru"})
|
||||||
InsertUser(s.db, entity.User{Email: "a1@b.ru"})
|
userId1 := InsertUser(s.db, entity.User{Email: "a1@b.ru"})
|
||||||
InsertUser(s.db, entity.User{Email: "a1@c.ru"})
|
userId2 := InsertUser(s.db, entity.User{Email: "a1@c.ru"})
|
||||||
|
userId3 := InsertUser(s.db, entity.User{Email: "a1@d.ru"})
|
||||||
|
|
||||||
|
roleId1 := InsertRole(s.db, entity.Role{Name: "test_role_1"})
|
||||||
|
roleId2 := InsertRole(s.db, entity.Role{Name: "test_role_2"})
|
||||||
|
|
||||||
|
InsertUserRole(s.db, entity.UserRole{RoleId: int(roleId1), UserId: int(userId1)})
|
||||||
|
InsertUserRole(s.db, entity.UserRole{RoleId: int(roleId1), UserId: int(userId2)})
|
||||||
|
InsertUserRole(s.db, entity.UserRole{RoleId: int(roleId1), UserId: int(userId3)})
|
||||||
|
|
||||||
|
InsertUserRole(s.db, entity.UserRole{RoleId: int(roleId2), UserId: int(userId1)})
|
||||||
|
InsertUserRole(s.db, entity.UserRole{RoleId: int(roleId2), UserId: int(userId2)})
|
||||||
|
|
||||||
|
email := "a1@"
|
||||||
|
|
||||||
response := domain.UsersResponse{}
|
response := domain.UsersResponse{}
|
||||||
err := s.grpcCli.Invoke("admin/user/get_users").
|
err := s.grpcCli.Invoke("admin/user/get_users").
|
||||||
JsonRequestBody(domain.UsersRequest{
|
JsonRequestBody(domain.UsersPageRequest{
|
||||||
Ids: []int64{3, 4, 5, 6},
|
LimitOffestParams: domain.LimitOffestParams{
|
||||||
Offset: 1,
|
Limit: 5,
|
||||||
Limit: 1,
|
Offset: 1,
|
||||||
Email: "a1@",
|
},
|
||||||
|
Order: &domain.OrderParams{
|
||||||
|
Field: "email",
|
||||||
|
Type: "asc",
|
||||||
|
},
|
||||||
|
Query: &domain.UserQuery{
|
||||||
|
Email: &email,
|
||||||
|
Roles: []int{int(roleId2)},
|
||||||
|
},
|
||||||
}).
|
}).
|
||||||
JsonResponseBody(&response).
|
JsonResponseBody(&response).
|
||||||
Do(context.Background())
|
Do(context.Background())
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
s.Require().Len(response.Items, 1) //nolint:mnd
|
roles := []int{int(roleId1), int(roleId2)}
|
||||||
s.Require().Equal(int64(5), response.Items[0].Id)
|
|
||||||
|
s.Require().Len(response.Items, 2)
|
||||||
|
s.Require().EqualValues("a1@b.ru", response.Items[0].Email)
|
||||||
|
s.Require().EqualValues(roles, response.Items[0].Roles)
|
||||||
|
s.Require().EqualValues("a1@c.ru", response.Items[1].Email)
|
||||||
|
s.Require().EqualValues(roles, response.Items[1].Roles)
|
||||||
|
|
||||||
|
id := int(userId2)
|
||||||
|
email = "test@mail.ru"
|
||||||
|
err = s.grpcCli.Invoke("admin/user/get_users").
|
||||||
|
JsonRequestBody(domain.UsersPageRequest{
|
||||||
|
LimitOffestParams: domain.LimitOffestParams{
|
||||||
|
Limit: 10,
|
||||||
|
Offset: 0,
|
||||||
|
},
|
||||||
|
Order: &domain.OrderParams{
|
||||||
|
Field: "id",
|
||||||
|
Type: "asc",
|
||||||
|
},
|
||||||
|
Query: &domain.UserQuery{
|
||||||
|
Id: &id,
|
||||||
|
Email: &email,
|
||||||
|
},
|
||||||
|
}).
|
||||||
|
JsonResponseBody(&response).
|
||||||
|
Do(context.Background())
|
||||||
|
s.Require().NoError(err)
|
||||||
|
s.Require().Empty(response.Items)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *UserTestSuite) TestGetUsersFilterByLastActiveAt() {
|
||||||
|
userId1 := InsertUser(s.db, entity.User{Email: "test1@a.ru"})
|
||||||
|
userId2 := InsertUser(s.db, entity.User{Email: "test2@a.ru"})
|
||||||
|
userId3 := InsertUser(s.db, entity.User{Email: "test3@a.ru"})
|
||||||
|
|
||||||
|
userTime1, err := time.Parse("2006-01-02T15:04:05Z", "2018-01-01T00:00:00Z")
|
||||||
|
s.Require().NoError(err)
|
||||||
|
|
||||||
|
userTime2, err := time.Parse("2006-01-02T15:04:05Z", "2020-01-01T00:00:00Z")
|
||||||
|
s.Require().NoError(err)
|
||||||
|
|
||||||
|
InsertTokenEntity(s.db, entity.Token{
|
||||||
|
Token: "test_token1",
|
||||||
|
UserId: userId1,
|
||||||
|
Status: entity.TokenStatusAllowed,
|
||||||
|
ExpiredAt: userTime1.Add(1 * time.Hour),
|
||||||
|
CreatedAt: userTime1,
|
||||||
|
UpdatedAt: userTime1,
|
||||||
|
})
|
||||||
|
|
||||||
|
InsertTokenEntity(s.db, entity.Token{
|
||||||
|
Token: "test_token2",
|
||||||
|
UserId: userId2,
|
||||||
|
Status: entity.TokenStatusAllowed,
|
||||||
|
ExpiredAt: userTime1.Add(25 * time.Hour),
|
||||||
|
CreatedAt: userTime1.Add(24 * time.Hour),
|
||||||
|
UpdatedAt: userTime1.Add(24 * time.Hour),
|
||||||
|
})
|
||||||
|
|
||||||
|
InsertTokenEntity(s.db, entity.Token{
|
||||||
|
Token: "test_token3",
|
||||||
|
UserId: userId3,
|
||||||
|
Status: entity.TokenStatusAllowed,
|
||||||
|
ExpiredAt: userTime2.Add(1 * time.Hour),
|
||||||
|
CreatedAt: userTime2,
|
||||||
|
UpdatedAt: userTime2,
|
||||||
|
})
|
||||||
|
|
||||||
|
response := domain.UsersResponse{}
|
||||||
|
err = s.grpcCli.Invoke("admin/user/get_users").
|
||||||
|
JsonRequestBody(domain.UsersPageRequest{
|
||||||
|
LimitOffestParams: domain.LimitOffestParams{
|
||||||
|
Limit: 5,
|
||||||
|
Offset: 0,
|
||||||
|
},
|
||||||
|
Order: &domain.OrderParams{
|
||||||
|
Field: "lastSessionCreatedAt",
|
||||||
|
Type: "desc",
|
||||||
|
},
|
||||||
|
Query: &domain.UserQuery{
|
||||||
|
LastSessionCreatedAt: &domain.DateFromToParams{
|
||||||
|
From: userTime1.Add(-48 * time.Hour),
|
||||||
|
To: userTime1.Add(48 * time.Hour),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}).
|
||||||
|
JsonResponseBody(&response).
|
||||||
|
Do(context.Background())
|
||||||
|
s.Require().NoError(err)
|
||||||
|
|
||||||
|
s.Require().Len(response.Items, 2)
|
||||||
|
s.Require().EqualValues(userId2, response.Items[0].Id)
|
||||||
|
s.Require().EqualValues(userId1, response.Items[1].Id)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *UserTestSuite) TestGetUsersSortByName() {
|
||||||
|
userIdViser1 := InsertUser(s.db, entity.User{Email: "a1@a.ru",
|
||||||
|
FirstName: "admin_viser", LastName: "admin_viser", FullName: "admin_viser admin_viser"})
|
||||||
|
userIdViser2 := InsertUser(s.db, entity.User{Email: "a1@b.ru",
|
||||||
|
FirstName: "admin_viser", LastName: "admin_viser2", FullName: "admin_viser2 admin_viser"})
|
||||||
|
userIdScripts := InsertUser(s.db, entity.User{Email: "a1@c.ru",
|
||||||
|
FirstName: "admin_scripts", LastName: "admin_scripts", FullName: "admin_scripts admin_scripts"})
|
||||||
|
userIdAL := InsertUser(s.db, entity.User{Email: "a1@d.ru", FirstName: "А", LastName: "Л", FullName: "Л А"})
|
||||||
|
|
||||||
|
response := domain.UsersResponse{}
|
||||||
|
err := s.grpcCli.Invoke("admin/user/get_users").
|
||||||
|
JsonRequestBody(domain.UsersPageRequest{
|
||||||
|
LimitOffestParams: domain.LimitOffestParams{
|
||||||
|
Limit: 10,
|
||||||
|
Offset: 0,
|
||||||
|
},
|
||||||
|
Order: &domain.OrderParams{
|
||||||
|
Field: "userId",
|
||||||
|
Type: "asc",
|
||||||
|
},
|
||||||
|
}).
|
||||||
|
JsonResponseBody(&response).
|
||||||
|
Do(context.Background())
|
||||||
|
s.Require().NoError(err)
|
||||||
|
|
||||||
|
s.Require().Len(response.Items, 6)
|
||||||
|
s.Require().EqualValues(1, response.Items[0].Id)
|
||||||
|
s.Require().EqualValues(userIdScripts, response.Items[1].Id)
|
||||||
|
s.Require().EqualValues(2, response.Items[2].Id)
|
||||||
|
s.Require().EqualValues(userIdViser1, response.Items[3].Id)
|
||||||
|
s.Require().EqualValues(userIdViser2, response.Items[4].Id)
|
||||||
|
s.Require().EqualValues(userIdAL, response.Items[5].Id)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *UserTestSuite) TestCreateUserHappyPath() {
|
func (s *UserTestSuite) TestCreateUserHappyPath() {
|
||||||
@@ -199,6 +356,35 @@ func (s *UserTestSuite) TestCreateUserHappyPath() {
|
|||||||
s.db.Must().SelectRow(&postCount, "select count(*) from users")
|
s.db.Must().SelectRow(&postCount, "select count(*) from users")
|
||||||
|
|
||||||
s.Require().Equal(preCount+1, postCount)
|
s.Require().Equal(preCount+1, postCount)
|
||||||
|
time.Sleep(1 * time.Second) // wait for go SaveAuditAsync()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *UserTestSuite) TestCreateUserWithSameEmailSudirHappyPath() {
|
||||||
|
firstSudirId := "user_a"
|
||||||
|
admin := InsertSudirUser(s.db, entity.SudirUser{SudirUserId: firstSudirId, Email: "a2@a.ru"})
|
||||||
|
|
||||||
|
preCount := 0
|
||||||
|
s.db.Must().SelectRow(&preCount, "select count(*) from users")
|
||||||
|
|
||||||
|
response := entity.User{}
|
||||||
|
err := s.grpcCli.
|
||||||
|
Invoke("admin/user/create_user").
|
||||||
|
AppendMetadata(domain.AdminAuthIdHeader, strconv.Itoa(int(admin))).
|
||||||
|
JsonRequestBody(domain.CreateUserRequest{
|
||||||
|
FirstName: "name",
|
||||||
|
LastName: "surname",
|
||||||
|
Email: "a2@a.ru",
|
||||||
|
Password: "password",
|
||||||
|
}).
|
||||||
|
JsonResponseBody(&response).
|
||||||
|
Do(context.Background())
|
||||||
|
s.Require().NoError(err)
|
||||||
|
|
||||||
|
postCount := 0
|
||||||
|
s.db.Must().SelectRow(&postCount, "select count(*) from users")
|
||||||
|
|
||||||
|
s.Require().Equal(preCount+1, postCount)
|
||||||
|
time.Sleep(1 * time.Second) // wait for go SaveAuditAsync()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *UserTestSuite) TestCreateUserAlreadyExist() {
|
func (s *UserTestSuite) TestCreateUserAlreadyExist() {
|
||||||
@@ -243,14 +429,16 @@ func (s *AuthTestSuite) TestUpdateUserHappyPath() {
|
|||||||
Email: response.Email,
|
Email: response.Email,
|
||||||
}
|
}
|
||||||
s.Require().Equal(expected, req)
|
s.Require().Equal(expected, req)
|
||||||
|
|
||||||
|
time.Sleep(1 * time.Second) // wait for go SaveAuditAsync()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *AuthTestSuite) TestUpdateSudirUserHappyPath() {
|
func (s *AuthTestSuite) TestUpdateSudirUserHappyPath() {
|
||||||
id := InsertSudirUser(s.db, entity.SudirUser{Email: "sudir@a.ru"})
|
id := InsertSudirUser(s.db, entity.SudirUser{SudirUserId: "123", Email: "sudir@a.ru", FullName: "surname name patronymic"})
|
||||||
req := domain.UpdateUserRequest{
|
req := domain.UpdateUserRequest{
|
||||||
Id: id,
|
Id: id,
|
||||||
FirstName: "name",
|
FirstName: "nameUpd",
|
||||||
LastName: "surname",
|
LastName: "surnameUpd",
|
||||||
Email: "sudir@a.ru",
|
Email: "sudir@a.ru",
|
||||||
}
|
}
|
||||||
response := domain.User{}
|
response := domain.User{}
|
||||||
@@ -268,6 +456,9 @@ func (s *AuthTestSuite) TestUpdateSudirUserHappyPath() {
|
|||||||
Email: response.Email,
|
Email: response.Email,
|
||||||
}
|
}
|
||||||
s.Require().Equal(expected, req)
|
s.Require().Equal(expected, req)
|
||||||
|
s.Require().Equal("surnameUpd nameUpd", response.FullName)
|
||||||
|
|
||||||
|
time.Sleep(1 * time.Second) // wait for go SaveAuditAsync()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *AuthTestSuite) TestUpdateUserAlreadyExist() {
|
func (s *AuthTestSuite) TestUpdateUserAlreadyExist() {
|
||||||
@@ -290,6 +481,29 @@ func (s *AuthTestSuite) TestUpdateUserAlreadyExist() {
|
|||||||
s.Require().Equal(codes.AlreadyExists, st.Code())
|
s.Require().Equal(codes.AlreadyExists, st.Code())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *AuthTestSuite) TestUpdateUserWithSudirAlreadyExist() {
|
||||||
|
firstSudirId := "user_a"
|
||||||
|
secondSudirId := "user_b"
|
||||||
|
|
||||||
|
admin := InsertSudirUser(s.db, entity.SudirUser{SudirUserId: firstSudirId, Email: "a_exists@a.ru"})
|
||||||
|
id := InsertSudirUser(s.db, entity.SudirUser{SudirUserId: secondSudirId, Email: "b_exists@b.ru"})
|
||||||
|
req := domain.UpdateUserRequest{
|
||||||
|
Id: id,
|
||||||
|
FirstName: "name",
|
||||||
|
LastName: "surname",
|
||||||
|
Email: "a_exists@a.ru",
|
||||||
|
}
|
||||||
|
err := s.grpcCli.
|
||||||
|
Invoke("admin/user/update_user").
|
||||||
|
AppendMetadata(domain.AdminAuthIdHeader, strconv.Itoa(int(admin))).
|
||||||
|
JsonRequestBody(req).
|
||||||
|
Do(context.Background())
|
||||||
|
s.Require().Error(err)
|
||||||
|
st, ok := status.FromError(err)
|
||||||
|
s.Require().True(ok)
|
||||||
|
s.Require().Equal(codes.AlreadyExists, st.Code())
|
||||||
|
}
|
||||||
|
|
||||||
func (s *UserTestSuite) TestDeleteUsers() {
|
func (s *UserTestSuite) TestDeleteUsers() {
|
||||||
admin := InsertUser(s.db, entity.User{Email: "a_del@a.ru"})
|
admin := InsertUser(s.db, entity.User{Email: "a_del@a.ru"})
|
||||||
InsertUser(s.db, entity.User{Email: "b_del@a.ru"})
|
InsertUser(s.db, entity.User{Email: "b_del@a.ru"})
|
||||||
@@ -306,6 +520,8 @@ func (s *UserTestSuite) TestDeleteUsers() {
|
|||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
s.Require().Equal(2, response.Deleted)
|
s.Require().Equal(2, response.Deleted)
|
||||||
|
|
||||||
|
time.Sleep(1 * time.Second) // wait for go SaveAuditAsync()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *UserTestSuite) TestBlockUser() {
|
func (s *UserTestSuite) TestBlockUser() {
|
||||||
@@ -339,6 +555,8 @@ func (s *UserTestSuite) TestBlockUser() {
|
|||||||
t, err := repository.NewToken(s.db).Get(context.Background(), token)
|
t, err := repository.NewToken(s.db).Get(context.Background(), token)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.EqualValues(entity.TokenStatusRevoked, t.Status)
|
s.EqualValues(entity.TokenStatusRevoked, t.Status)
|
||||||
|
|
||||||
|
time.Sleep(1 * time.Second) // wait for go SaveAuditAsync()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *UserTestSuite) TestChangePasswordUser() {
|
func (s *UserTestSuite) TestChangePasswordUser() {
|
||||||
@@ -380,4 +598,6 @@ func (s *UserTestSuite) TestChangePasswordUser() {
|
|||||||
|
|
||||||
tokenInfo := SelectTokenEntityByToken(s.db, "token-841297641213")
|
tokenInfo := SelectTokenEntityByToken(s.db, "token-841297641213")
|
||||||
s.Require().Equal(entity.TokenStatusRevoked, tokenInfo.Status)
|
s.Require().Equal(entity.TokenStatusRevoked, tokenInfo.Status)
|
||||||
|
|
||||||
|
time.Sleep(1 * time.Second) // wait for go SaveAuditAsync()
|
||||||
}
|
}
|
||||||
+14
-1
@@ -3,9 +3,11 @@ package transaction
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/txix-open/isp-kit/db"
|
|
||||||
"msp-admin-service/repository"
|
"msp-admin-service/repository"
|
||||||
"msp-admin-service/service"
|
"msp-admin-service/service"
|
||||||
|
"msp-admin-service/service/session_worker"
|
||||||
|
|
||||||
|
"github.com/txix-open/isp-kit/db"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Manager struct {
|
type Manager struct {
|
||||||
@@ -25,6 +27,10 @@ type userTx struct {
|
|||||||
repository.Token
|
repository.Token
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type tokenTx struct {
|
||||||
|
repository.Token
|
||||||
|
}
|
||||||
|
|
||||||
func (m Manager) UserTransaction(ctx context.Context, msgTx func(ctx context.Context, tx service.UserTransaction) error) error {
|
func (m Manager) UserTransaction(ctx context.Context, msgTx func(ctx context.Context, tx service.UserTransaction) error) error {
|
||||||
return m.db.RunInTransaction(ctx, func(ctx context.Context, tx *db.Tx) error {
|
return m.db.RunInTransaction(ctx, func(ctx context.Context, tx *db.Tx) error {
|
||||||
user := repository.NewUser(tx)
|
user := repository.NewUser(tx)
|
||||||
@@ -44,3 +50,10 @@ func (m Manager) AuthTransaction(ctx context.Context, msgTx func(ctx context.Con
|
|||||||
return msgTx(ctx, userTx{user, role, userRole, token})
|
return msgTx(ctx, userTx{user, role, userRole, token})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m Manager) TokenTransaction(ctx context.Context, msgTx func(ctx context.Context, tx session_worker.TokenTransaction) error) error {
|
||||||
|
return m.db.RunInTransaction(ctx, func(ctx context.Context, tx *db.Tx) error {
|
||||||
|
token := repository.NewToken(tx)
|
||||||
|
return msgTx(ctx, tokenTx{token})
|
||||||
|
})
|
||||||
|
}
|
||||||
Reference in new issue
Block a user