Compare commits

...
2 Commits
Author SHA1 Message Date
txix 71a841fee0 2025-10-27 15:14:18: merge [main:187e1f07a0e8912d7c10f6568ea8ee6489639912];
Create and publish a Docker image / build-and-push-image (push) Canceled after 0s
2025-10-27 15:14:18 +03:00
txix 3029e084ce 2025-09-16 17:00:10: merge [main:20f3fb7b5e4ca72a712c054d9a33187b91a5ed70];
Create and publish a Docker image / build-and-push-image (push) Canceled after 0s
2025-09-16 17:00:10 +03:00
24 changed files with 386 additions and 140 deletions

No files matched your search

+1
View File
@@ -17,6 +17,7 @@ linters:
- tagalign # не всегда имеет смысл
- varnamelen # очень индивидуально (db)
- wsl # расставление пробелов очень индивидуально
- wsl_v5 # расставление пробелов очень индивидуально
settings:
cyclop:
max-complexity: 15 # по умолчанию 10 мало
+1 -1
View File
@@ -1 +1 @@
6.4.0
6.6.0
+7 -1
View File
@@ -1,5 +1,11 @@
### 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/*`
+1 -1
View File
@@ -1,4 +1,4 @@
FROM golang:1.24-alpine as builder
FROM golang:1.25-alpine as builder
WORKDIR /build
ARG version
ENV version_env=$version
+4
View File
@@ -20,6 +20,10 @@
{
"event": "user_changed",
"name": "Изменение пользователя"
},
{
"event": "user_blocked",
"name": "Изменение статуса блокировки пользователя"
}
],
"auditTTl": {
+28 -2
View File
@@ -16,7 +16,7 @@ import (
type authService interface {
Login(ctx context.Context, request domain.LoginRequest) (*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 {
@@ -48,7 +48,33 @@ func (a Auth) Logout(ctx context.Context, authData grpc.AuthData) error {
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 {
return errors.WithMessage(err, "logout")
}
+38
View File
@@ -174,6 +174,11 @@ definitions:
required:
- authCode
type: object
domain.LogoutRequest:
properties:
reason:
type: string
type: object
domain.PageRequest:
properties:
limit:
@@ -448,6 +453,39 @@ paths:
summary: Выход из авторизованной сессии
tags:
- 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:
post:
consumes:
+4
View File
@@ -6,6 +6,10 @@ const (
AdminAuthIdHeader = "x-admin-id"
)
type LogoutRequest struct {
Reason string
}
type LoginRequest struct {
Email string `validate:"required"`
Password string ` validate:"required"`
+1
View File
@@ -8,6 +8,7 @@ const (
EventUserChanged = "user_changed"
EventUserPasswordChanged = "success_change_password"
EventErrorPasswordChange = "error_change_password"
EventUserBlocked = "user_blocked"
)
type AuditEvent struct {
+30 -29
View File
@@ -1,18 +1,18 @@
module msp-admin-service
go 1.24
go 1.25
require (
github.com/Masterminds/squirrel v1.5.4
github.com/google/uuid v1.6.0
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.10.0
github.com/stretchr/testify v1.11.1
github.com/txix-open/bgjob v1.5.0
github.com/txix-open/isp-kit v1.54.1
github.com/txix-open/isp-kit v1.59.1
github.com/txix-open/jsonschema v1.3.0
golang.org/x/crypto v0.41.0
golang.org/x/sync v0.16.0
google.golang.org/grpc v1.74.2
golang.org/x/crypto v0.42.0
golang.org/x/sync v0.17.0
google.golang.org/grpc v1.75.1
)
require (
@@ -21,19 +21,19 @@ require (
github.com/buger/jsonparser v1.1.1 // indirect
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/coder/websocket v1.8.13 // indirect
github.com/coder/websocket v1.8.14 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/gabriel-vasile/mimetype v1.4.9 // indirect
github.com/getsentry/sentry-go v0.35.1 // indirect
github.com/gabriel-vasile/mimetype v1.4.10 // indirect
github.com/getsentry/sentry-go v0.35.2 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.1 // 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/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/pgx/v5 v5.7.5 // indirect
github.com/jackc/pgx/v5 v5.7.6 // indirect
github.com/jackc/puddle/v2 v2.2.2 // indirect
github.com/jmoiron/sqlx v1.4.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
@@ -47,10 +47,10 @@ require (
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/pressly/goose/v3 v3.24.3 // indirect
github.com/prometheus/client_golang v1.23.0 // indirect
github.com/pressly/goose/v3 v3.25.0 // indirect
github.com/prometheus/client_golang v1.23.2 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.65.0 // indirect
github.com/prometheus/common v0.66.1 // indirect
github.com/prometheus/procfs v0.17.0 // indirect
github.com/sethvargo/go-retry v0.3.0 // indirect
github.com/txix-open/bellows v1.2.0 // indirect
@@ -60,23 +60,24 @@ require (
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.62.0 // indirect
go.opentelemetry.io/otel v1.37.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.37.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.37.0 // indirect
go.opentelemetry.io/otel/metric v1.37.0 // indirect
go.opentelemetry.io/otel/sdk v1.37.0 // indirect
go.opentelemetry.io/otel/trace v1.37.0 // indirect
go.opentelemetry.io/proto/otlp v1.7.1 // indirect
go.opentelemetry.io/auto/sdk v1.2.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.63.0 // indirect
go.opentelemetry.io/otel v1.38.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.38.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.38.0 // indirect
go.opentelemetry.io/otel/metric v1.38.0 // indirect
go.opentelemetry.io/otel/sdk v1.38.0 // 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/zap v1.27.0 // indirect
golang.org/x/net v0.43.0 // indirect
golang.org/x/sys v0.35.0 // indirect
golang.org/x/text v0.28.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250811230008-5f3141c8851a // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250811230008-5f3141c8851a // indirect
google.golang.org/protobuf v1.36.7 // indirect
go.yaml.in/yaml/v2 v2.4.3 // indirect
golang.org/x/net v0.44.0 // indirect
golang.org/x/sys v0.36.0 // indirect
golang.org/x/text v0.29.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250908214217-97024824d090 // 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/yaml.v3 v3.0.1 // indirect
)
+74 -70
View File
@@ -16,8 +16,8 @@ github.com/cenkalti/backoff/v5 v5.0.3 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1x
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/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/coder/websocket v1.8.13 h1:f3QZdXy7uGVz+4uCJy2nTZyM0yTBj8yANEHhqlXZ9FE=
github.com/coder/websocket v1.8.13/go.mod h1:LNVeNrXQZfe5qhS9ALED3uA+l5pPqvwXg3CKoDBB2gs=
github.com/coder/websocket v1.8.14 h1:9L0p0iKiNOibykf283eHkKUHHrpG7f65OE3BhhO7v9g=
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.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -25,10 +25,10 @@ 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/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/gabriel-vasile/mimetype v1.4.9 h1:5k+WDwEsD9eTLL8Tz3L0VnmVh9QxGjRmjBvAG7U/oYY=
github.com/gabriel-vasile/mimetype v1.4.9/go.mod h1:WnSQhFKJuBlRyLiKohA/2DtIlPFAbguNaG7QCHcyGok=
github.com/getsentry/sentry-go v0.35.1 h1:iopow6UVLE2aXu46xKVIs8Z9D/YZkJrHkgozrxa+tOQ=
github.com/getsentry/sentry-go v0.35.1/go.mod h1:C55omcY9ChRQIUcVcGcs+Zdy4ZpQGvNJ7JYHIoSWOtE=
github.com/gabriel-vasile/mimetype v1.4.10 h1:zyueNbySn/z8mJZHLt6IPw0KoZsiQNszIpU+bX4+ZK0=
github.com/gabriel-vasile/mimetype v1.4.10/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=
github.com/getsentry/sentry-go v0.35.2 h1:jKuujpRwa8FFRYMIwwZpu83Xh0voll9bmvyc6310WBM=
github.com/getsentry/sentry-go v0.35.2/go.mod h1:mdL49ixwT2yi57k5eh7mpnDyPybixPzlzEJFu0Z76QA=
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-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
@@ -45,8 +45,8 @@ github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91
github.com/go-resty/resty/v2 v2.16.5 h1:hBKqmWrr7uRc3euHVqmh1HTHcKn99Smr7o5spptdhTM=
github.com/go-resty/resty/v2 v2.16.5/go.mod h1:hkJtXbA2iKHzJheXYvQ8snQES5ZLGKMwQ07xAwp/fiA=
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
github.com/go-sql-driver/mysql v1.9.2 h1:4cNKDYQ1I84SXslGddlsrMhc8k4LeDVj6Ad6WRjiHuU=
github.com/go-sql-driver/mysql v1.9.2/go.mod h1:qn46aNg1333BRMNU69Lq93t8du/dwxI64Gl8i5p1WMU=
github.com/go-sql-driver/mysql v1.9.3 h1:U/N249h2WzJ3Ukj8SowVFjdtZKfu9vlLZxjPXV1aweo=
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=
@@ -54,16 +54,16 @@ github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX
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/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.1 h1:X5VWvz21y3gzm9Nw/kaUeku/1+uBhcekkmy4IkffJww=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.1/go.mod h1:Zanoh4+gvIgluNqcfMVTJueD4wSS5hT7zTt4Mrutd90=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2 h1:8Tjv8EJ+pM1xP8mK6egEbD1OgnVTyacbefKhmbLhIhU=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2/go.mod h1:pkJQ2tZHJ0aFOVEEot6oZmaVEZcRme73eIFmhiVuRWs=
github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
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/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/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
github.com/jackc/pgx/v5 v5.7.5 h1:JHGfMnQY+IEtGM63d+NGMjoRpysB2JBwDr5fsngwmJs=
github.com/jackc/pgx/v5 v5.7.5/go.mod h1:aruU7o91Tc2q2cFp5h4uP3f6ztExVpyVv88Xl/8Vl8M=
github.com/jackc/pgx/v5 v5.7.6 h1:rWQc5FwZSPX58r1OQmkuaNicxdmExaEz5A2DO2hUuTk=
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/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
github.com/jmoiron/sqlx v1.4.0 h1:1PLqN7S1UYp5t4SrVVnt4nUVNemrDAtxlulVe+Qgm3o=
@@ -113,14 +113,14 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
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/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pressly/goose/v3 v3.24.3 h1:DSWWNwwggVUsYZ0X2VitiAa9sKuqtBfe+Jr9zFGwWlM=
github.com/pressly/goose/v3 v3.24.3/go.mod h1:v9zYL4xdViLHCUUJh/mhjnm6JrK7Eul8AS93IxiZM4E=
github.com/prometheus/client_golang v1.23.0 h1:ust4zpdl9r4trLY/gSjlm07PuiBq2ynaXXlptpfy8Uc=
github.com/prometheus/client_golang v1.23.0/go.mod h1:i/o0R9ByOnHX0McrTMTyhYvKE4haaf2mW08I+jGAjEE=
github.com/pressly/goose/v3 v3.25.0 h1:6WeYhMWGRCzpyd89SpODFnCBCKz41KrVbRT58nVjGng=
github.com/pressly/goose/v3 v3.25.0/go.mod h1:4hC1KrritdCxtuFsqgs1R4AU5bWtTAf+cnWvfhf2DNY=
github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h0RJWRi/o0o=
github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg=
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
github.com/prometheus/common v0.65.0 h1:QDwzd+G1twt//Kwj/Ww6E9FQq1iVMmODnILtW1t2VzE=
github.com/prometheus/common v0.65.0/go.mod h1:0gZns+BLRQ3V6NdaerOhMbwwRbNh9hkGINtQAsP5GS8=
github.com/prometheus/common v0.66.1 h1:h5E0h5/Y8niHc5DlaLlWLArTQI7tMrsfQjHV+d9ZoGs=
github.com/prometheus/common v0.66.1/go.mod h1:gcaUsgf3KfRSwHY4dIMXLPV0K/Wg1oZ8+SbZk/HH/dA=
github.com/prometheus/procfs v0.17.0 h1:FuLQ+05u4ZI+SS/w9+BWEM2TXiHKsUQ9TADiRH7DuK0=
github.com/prometheus/procfs v0.17.0/go.mod h1:oPQLaDAMRbA+u8H5Pbfq+dl3VDAvHxMUOVhe0wYB2zw=
github.com/rabbitmq/amqp091-go v1.10.0 h1:STpn5XsHlHGcecLmMFCtg7mqq0RnD+zFr4uzukfVhBw=
@@ -142,8 +142,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.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/go.mod h1:qbKCy+RTgD30Qpw1fyb3y3jp5Y9mGhLLxgae1l0W92o=
github.com/txix-open/bgjob v1.5.0 h1:/ZbHzb3EZDZSzaUxA7xfuYt9CS/hmXC33mJ4Z4Lvkhc=
@@ -152,8 +152,8 @@ github.com/txix-open/etp/v4 v4.0.1 h1:5VSYgGsvnMz0tvUHsjVWFETI0qWBTCF1O3ARCHaCIg
github.com/txix-open/etp/v4 v4.0.1/go.mod h1:FIu7TUDdwcgmtmF6tFTV1bGA2fRY/iVaPQdsGzvqYc8=
github.com/txix-open/grmq v1.9.0 h1:ArDbJJcFX9zXKEcPf49rp9nYiRyGMJxGKJAxdbSsfaM=
github.com/txix-open/grmq v1.9.0/go.mod h1:EyFOP17KrwEFOUjR+PH8iH3LCtiN9TSQ8t0ysyk62po=
github.com/txix-open/isp-kit v1.54.1 h1:OY4dQgvhHpRicwpemnoHxs+w2/rMkc19Jf0Nj8QPIeI=
github.com/txix-open/isp-kit v1.54.1/go.mod h1:sVUjen989u4yz5SYAZ4LRCQzRfwlU/uJ5ogiU31zmks=
github.com/txix-open/isp-kit v1.59.1 h1:a5kdpJQ5C9o9AwONejH5DEhz5wRW+XATSzyHDw7bnF4=
github.com/txix-open/isp-kit v1.59.1/go.mod h1:Mbprn7ExedjRg4yUPa9xShYx1oMJIU+a19x6ksVubaw=
github.com/txix-open/jsonschema v1.3.0 h1:XGuOTg22G7PdqfKypjajM20/i5FyGfFYsJKmheebKi4=
github.com/txix-open/jsonschema v1.3.0/go.mod h1:l8YDZ1nvJrw6uxWowSVOxCV/ebiMJyapffW87ZEqH00=
github.com/txix-open/validator/v10 v10.0.0-20250506161033-f8ce404fffdb h1:UJgT4u/QMv5QHKOQeJ7igShHa36c2/vIRqJiRLdDlf0=
@@ -167,54 +167,58 @@ 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/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.62.0 h1:wCeciVlAfb5DC8MQl/DlmAv/FVPNpQgFvI/71+hatuc=
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.62.0/go.mod h1:WfEApdZDMlLUAev/0QQpr8EJ/z0VWDKYZ5tF5RH5T1U=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.62.0 h1:Hf9xI/XLML9ElpiHVDNwvqI0hIFlzV8dgIr35kV1kRU=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.62.0/go.mod h1:NfchwuyNoMcZ5MLHwPrODwUF1HWCXWrL31s8gSAdIKY=
go.opentelemetry.io/otel v1.37.0 h1:9zhNfelUvx0KBfu/gb+ZgeAfAgtWrfHJZcAqFC228wQ=
go.opentelemetry.io/otel v1.37.0/go.mod h1:ehE/umFRLnuLa/vSccNq9oS1ErUlkkK71gMcN34UG8I=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.37.0 h1:Ahq7pZmv87yiyn3jeFz/LekZmPLLdKejuO3NcK9MssM=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.37.0/go.mod h1:MJTqhM0im3mRLw1i8uGHnCvUEeS7VwRyxlLC78PA18M=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.37.0 h1:bDMKF3RUSxshZ5OjOTi8rsHGaPKsAt76FaqgvIUySLc=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.37.0/go.mod h1:dDT67G/IkA46Mr2l9Uj7HsQVwsjASyV9SjGofsiUZDA=
go.opentelemetry.io/otel/metric v1.37.0 h1:mvwbQS5m0tbmqML4NqK+e3aDiO02vsf/WgbsdpcPoZE=
go.opentelemetry.io/otel/metric v1.37.0/go.mod h1:04wGrZurHYKOc+RKeye86GwKiTb9FKm1WHtO+4EVr2E=
go.opentelemetry.io/otel/sdk v1.37.0 h1:ItB0QUqnjesGRvNcmAcU0LyvkVyGJ2xftD29bWdDvKI=
go.opentelemetry.io/otel/sdk v1.37.0/go.mod h1:VredYzxUvuo2q3WRcDnKDjbdvmO0sCzOvVAiY+yUkAg=
go.opentelemetry.io/otel/sdk/metric v1.37.0 h1:90lI228XrB9jCMuSdA0673aubgRobVZFhbjxHHspCPc=
go.opentelemetry.io/otel/sdk/metric v1.37.0/go.mod h1:cNen4ZWfiD37l5NhS+Keb5RXVWZWpRE+9WyVCpbo5ps=
go.opentelemetry.io/otel/trace v1.37.0 h1:HLdcFNbRQBE2imdSEgm/kwqmQj1Or1l/7bW6mxVK7z4=
go.opentelemetry.io/otel/trace v1.37.0/go.mod h1:TlgrlQ+PtQO5XFerSPUYG0JSgGyryXewPGyayAWSBS0=
go.opentelemetry.io/proto/otlp v1.7.1 h1:gTOMpGDb0WTBOP8JaO72iL3auEZhVmAQg4ipjOVAtj4=
go.opentelemetry.io/proto/otlp v1.7.1/go.mod h1:b2rVh6rfI/s2pHWNlB7ILJcRALpcNDzKhACevjI+ZnE=
go.opentelemetry.io/auto/sdk v1.2.0 h1:YpRtUFjvhSymycLS2T81lT6IGhcUP+LUPtv0iv1N8bM=
go.opentelemetry.io/auto/sdk v1.2.0/go.mod h1:1deq2zL7rwjwC8mR7XgY2N+tlIl6pjmEUoLDENMEzwk=
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.63.0 h1:2pn7OzMewmYRiNtv1doZnLo3gONcnMHlFnmOR8Vgt+8=
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.63.0 h1:RbKq8BG0FI8OiXhBfcRtqqHcZcka+gU3cskNuf05R18=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.63.0/go.mod h1:h06DGIukJOevXaj/xrNjhi/2098RZzcLTbc0jDAUbsg=
go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8=
go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.38.0 h1:GqRJVj7UmLjCVyVJ3ZFLdPRmhDUp2zFmQe3RHIOsw24=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.38.0/go.mod h1:ri3aaHSmCTVYu2AWv44YMauwAQc0aqI9gHKIcSbI1pU=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.38.0 h1:aTL7F04bJHUlztTsNGJ2l+6he8c+y/b//eR0jjjemT4=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.38.0/go.mod h1:kldtb7jDTeol0l3ewcmd8SDvx3EmIE7lyvqbasU3QC4=
go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA=
go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI=
go.opentelemetry.io/otel/sdk v1.38.0 h1:l48sr5YbNf2hpCUj/FoGhW9yDkl+Ma+LrVl8qaM5b+E=
go.opentelemetry.io/otel/sdk v1.38.0/go.mod h1:ghmNdGlVemJI3+ZB5iDEuk4bWA3GkTpW+DOoZMYBVVg=
go.opentelemetry.io/otel/sdk/metric v1.38.0 h1:aSH66iL0aZqo//xXzQLYozmWrXxyFkBJ6qT5wthqPoM=
go.opentelemetry.io/otel/sdk/metric v1.38.0/go.mod h1:dg9PBnW9XdQ1Hd6ZnRz689CbtrUp0wMMs9iPcgT9EZA=
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/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
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/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
golang.org/x/crypto v0.41.0 h1:WKYxWedPGCTVVl5+WHSSrOBT0O8lx32+zxmHxijgXp4=
golang.org/x/crypto v0.41.0/go.mod h1:pO5AFd7FA68rFak7rOAGVuygIISepHftHnr8dr6+sUc=
golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6 h1:y5zboxd6LQAqYIhHnB48p0ByQ/GnQx2BE33L8BOHQkI=
golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6/go.mod h1:U6Lno4MTRCDY+Ba7aCcauB9T60gsv5s4ralQzP72ZoQ=
golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE=
golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg=
golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng=
golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU=
google.golang.org/genproto/googleapis/api v0.0.0-20250811230008-5f3141c8851a h1:DMCgtIAIQGZqJXMVzJF4MV8BlWoJh2ZuFiRdAleyr58=
google.golang.org/genproto/googleapis/api v0.0.0-20250811230008-5f3141c8851a/go.mod h1:y2yVLIE/CSMCPXaHnSKXxu1spLPnglFLegmgdY23uuE=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250811230008-5f3141c8851a h1:tPE/Kp+x9dMSwUm/uM0JKK0IfdiJkwAbSMSeZBXXJXc=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250811230008-5f3141c8851a/go.mod h1:gw1tLEfykwDz2ET4a12jcXt4couGAm7IwsVaTy0Sflo=
google.golang.org/grpc v1.74.2 h1:WoosgB65DlWVC9FqI82dGsZhWFNBSLjQ84bjROOpMu4=
google.golang.org/grpc v1.74.2/go.mod h1:CtQ+BGjaAIXHs/5YS3i473GqwBBa1zGQNevxdeBEXrM=
google.golang.org/protobuf v1.36.7 h1:IgrO7UwFQGJdRNXH/sQux4R1Dj1WAKcLElzeeRaXV2A=
google.golang.org/protobuf v1.36.7/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
go.yaml.in/yaml/v2 v2.4.3 h1:6gvOSjQoTB3vt1l+CU+tSyi/HOjfOjRLJ4YwYZGwRO0=
go.yaml.in/yaml/v2 v2.4.3/go.mod h1:zSxWcmIDjOzPXpjlTTbAsKokqkDNAVtZO0WOMiT90s8=
golang.org/x/crypto v0.42.0 h1:chiH31gIWm57EkTXpwnqf8qeuMUi0yekh6mT2AvFlqI=
golang.org/x/crypto v0.42.0/go.mod h1:4+rDnOTJhQCx2q7/j6rAN5XDw8kPjeaXEUR2eL94ix8=
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b h1:M2rDM6z3Fhozi9O7NWsxAkg/yqS/lQJ6PmkyIV3YP+o=
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b/go.mod h1:3//PLf8L/X+8b4vuAfHzxeRUl04Adcb341+IGKfnqS8=
golang.org/x/net v0.44.0 h1:evd8IRDyfNBMBTTY5XRF1vaZlD+EmWx6x8PkhR04H/I=
golang.org/x/net v0.44.0/go.mod h1:ECOoLqd5U3Lhyeyo/QDCEVQ4sNgYsqvCZ722XogGieY=
golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug=
golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk=
golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4=
gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk=
gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E=
google.golang.org/genproto/googleapis/api v0.0.0-20250908214217-97024824d090 h1:d8Nakh1G+ur7+P3GcMjpRDEkoLUcLW2iU92XVqR+XMQ=
google.golang.org/genproto/googleapis/api v0.0.0-20250908214217-97024824d090/go.mod h1:U8EXRNSd8sUYyDfs/It7KVWodQr+Hf9xtxyxWudSwEw=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250908214217-97024824d090 h1:/OQuEa4YWtDt7uQWHd3q3sUMb+QOLQUg1xa8CEsRv5w=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250908214217-97024824d090/go.mod h1:GmFNa4BdJZ2a8G+wCe9Bg3wwThLrJun751XstdJt5Og=
google.golang.org/grpc v1.75.1 h1:/ODCNEuf9VghjgO3rqLcfg8fiOP0nSluljWFlDxELLI=
google.golang.org/grpc v1.75.1/go.mod h1:JtPAzKiq4v1xcAB2hydNlWI2RnF85XXcV0mhKXr2ecQ=
google.golang.org/protobuf v1.36.9 h1:w2gp2mA27hUeUzj9Ex9FBjsBm40zfaDtEWow293U7Iw=
google.golang.org/protobuf v1.36.9/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU=
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/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
@@ -223,11 +227,11 @@ gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYs
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/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
modernc.org/libc v1.65.0 h1:e183gLDnAp9VJh6gWKdTy0CThL9Pt7MfcR/0bgb7Y1Y=
modernc.org/libc v1.65.0/go.mod h1:7m9VzGq7APssBTydds2zBcxGREwvIGpuUBaKTXdm2Qs=
modernc.org/libc v1.66.3 h1:cfCbjTUcdsKyyZZfEUKfoHcP3S0Wkvz3jgSzByEWVCQ=
modernc.org/libc v1.66.3/go.mod h1:XD9zO8kt59cANKvHPXpx7yS2ELPheAey0vjIuZOhOU8=
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
modernc.org/memory v1.10.0 h1:fzumd51yQ1DxcOxSO+S6X7+QTuVU+n8/Aj7swYjFfC4=
modernc.org/memory v1.10.0/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw=
modernc.org/sqlite v1.37.0 h1:s1TMe7T3Q3ovQiK2Ouz4Jwh7dw4ZDqbebSDTlSJdfjI=
modernc.org/sqlite v1.37.0/go.mod h1:5YiWv+YviqGMuGw4V+PNplcyaJ5v+vQd7TQOgkACoJM=
modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI=
modernc.org/memory v1.11.0/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw=
modernc.org/sqlite v1.38.2 h1:Aclu7+tgjgcQVShZqim41Bbw9Cho0y/7WzYptXqkEek=
modernc.org/sqlite v1.38.2/go.mod h1:cPTJYSlgg3Sfg046yBShXENNtPrWrDX8bsbAQBzgQ5E=
@@ -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';
+58 -2
View File
@@ -5,13 +5,14 @@ import (
"database/sql"
"time"
"msp-admin-service/domain"
"msp-admin-service/entity"
"github.com/Masterminds/squirrel"
"github.com/pkg/errors"
"github.com/txix-open/isp-kit/db"
"github.com/txix-open/isp-kit/db/query"
"github.com/txix-open/isp-kit/metrics/sql_metrics"
"msp-admin-service/domain"
"msp-admin-service/entity"
)
type User struct {
@@ -72,6 +73,36 @@ func (u User) GetUserById(ctx context.Context, identity int64) (*entity.User, er
}
}
func (u User) GetUserByEmailAndSudirId(ctx context.Context, email string, sudir_user_id string) (*entity.User, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "User.GetUserByEmail")
equalClause := squirrel.Eq{"email": email, "sudir_user_id": nil}
if sudir_user_id != "" {
equalClause["sudir_user_id"] = sudir_user_id
}
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) {
ctx = sql_metrics.OperationLabelToContext(ctx, "User.UpsertBySudirUserId")
@@ -134,6 +165,31 @@ func (u User) GetUsers(ctx context.Context, ids []int64, offset, limit int, emai
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) {
ctx = sql_metrics.OperationLabelToContext(ctx, "User.Insert")
+5
View File
@@ -49,6 +49,11 @@ func endpointDescriptors(c Controllers) []cluster.EndpointDescriptor {
Inner: true,
Handler: c.Auth.Logout,
},
{
Path: "admin/auth/logout_with_reason",
Inner: true,
Handler: c.Auth.LogoutWithReason,
},
{
Path: "admin/user/get_profile",
Inner: true,
+5 -3
View File
@@ -4,12 +4,13 @@ import (
"context"
"time"
"github.com/pkg/errors"
"github.com/txix-open/isp-kit/log"
"golang.org/x/sync/errgroup"
"msp-admin-service/conf"
"msp-admin-service/domain"
"msp-admin-service/entity"
"github.com/pkg/errors"
"github.com/txix-open/isp-kit/log"
"golang.org/x/sync/errgroup"
)
type AuditRepository interface {
@@ -45,6 +46,7 @@ func NewAudit(
entity.EventSuccessLogout: true,
entity.EventRoleChanged: true,
entity.EventUserChanged: true,
entity.EventUserBlocked: true,
}
eventName := make(map[string]conf.AuditEventSetting)
+6 -1
View File
@@ -213,7 +213,7 @@ func (a Auth) LoginWithSudir(ctx context.Context, request domain.LoginSudirReque
}, 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.txRunner.AuthTransaction(ctx, func(ctx context.Context, tx AuthTransaction) error {
err := a.tokenService.RevokeAllByUserId(ctx, adminId)
if err != nil {
@@ -226,6 +226,11 @@ func (a Auth) Logout(ctx context.Context, adminId int64) error {
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
})
+24 -11
View File
@@ -8,11 +8,12 @@ import (
"strings"
"time"
"msp-admin-service/domain"
"msp-admin-service/entity"
"github.com/pkg/errors"
"github.com/txix-open/isp-kit/log"
"golang.org/x/crypto/bcrypt"
"msp-admin-service/domain"
"msp-admin-service/entity"
)
type UserTransaction interface {
@@ -28,7 +29,8 @@ type UserTransactionRunner interface {
type UserRepo interface {
GetUserById(ctx context.Context, identity int64) (*entity.User, error)
GetUsers(ctx context.Context, ids []int64, offset, limit int, email string) ([]entity.User, error)
GetUserByEmail(ctx context.Context, email string) (*entity.User, error)
GetUserByEmailAndSudirId(ctx context.Context, email string, sudir_user_id 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)
DeleteUser(ctx context.Context, ids []int64) (int, error)
Insert(ctx context.Context, user entity.User) (int, error)
@@ -168,7 +170,7 @@ func (u User) CreateUser(ctx context.Context, req domain.CreateUserRequest, admi
var usr entity.User
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 {
case errors.Is(err, domain.ErrNotFound):
break
@@ -234,6 +236,7 @@ func (u User) CreateUser(ctx context.Context, req domain.CreateUserRequest, admi
return &result, nil
}
//nolint:cyclop,funlen
func (u User) UpdateUser(ctx context.Context, req domain.UpdateUserRequest, adminId int64) (*domain.User, error) {
var (
user *entity.User
@@ -244,7 +247,7 @@ func (u User) UpdateUser(ctx context.Context, req domain.UpdateUserRequest, admi
return nil, errors.WithMessage(err, "get user roles")
}
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 {
case errors.Is(err, domain.ErrNotFound):
return err // nolint:wrapcheck
@@ -252,14 +255,24 @@ func (u User) UpdateUser(ctx context.Context, req domain.UpdateUserRequest, admi
return errors.WithMessage(err, "get user by id")
}
user, err = tx.GetUserByEmail(ctx, req.Email)
users, err := tx.GetUsersByEmail(ctx, req.Email)
switch {
case errors.Is(err, domain.ErrNotFound):
break
case err != nil:
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{
@@ -384,7 +397,7 @@ func (u User) Block(ctx context.Context, adminId int64, userId int) error {
u.auditService.SaveAuditAsync(ctx, adminId,
fmt.Sprintf("Пользователь. %s пользователя ID %d.", userBlocked, userId),
entity.EventUserChanged,
entity.EventUserBlocked,
)
return nil
@@ -445,7 +458,8 @@ func (u User) ChangePassword(ctx context.Context, adminId int64, oldPassword str
return errors.WithMessage(err, "user.service.ChangePassword: get user by id")
}
if err = bcrypt.CompareHashAndPassword([]byte(admin.Password), []byte(oldPassword)); err != nil {
err = bcrypt.CompareHashAndPassword([]byte(admin.Password), []byte(oldPassword))
if err != nil {
u.auditService.SaveAuditAsync(ctx, adminId, "Указан неверный старый пароль", entity.EventErrorPasswordChange)
return domain.ErrInvalidPassword
}
@@ -482,7 +496,6 @@ func (u User) ChangePassword(ctx context.Context, adminId int64, oldPassword str
return nil
}
//nolint:gomnd
func (u User) cryptPassword(password string) (string, error) {
passwordBytes, err := bcrypt.GenerateFromPassword([]byte(password), 12) //nolint:mnd
if err != nil {
+15 -6
View File
@@ -5,6 +5,12 @@ import (
"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/txix-open/isp-kit/dbx"
"github.com/txix-open/isp-kit/grpc/client"
@@ -14,11 +20,6 @@ import (
"github.com/txix-open/isp-kit/test/grpct"
"google.golang.org/grpc/codes"
"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) {
@@ -28,6 +29,7 @@ func TestAuditSuite(t *testing.T) {
type AuditSuite struct {
suite.Suite
test *test.Test
db *dbt.TestDb
grpcCli *client.Client
@@ -61,6 +63,10 @@ func (t *AuditSuite) SetupTest() {
Event: entity.EventUserChanged,
Name: "изменение пользователя",
},
{
Event: entity.EventUserBlocked,
Name: "изменение статуса блокировки пользователя",
},
},
AuditTTl: conf.AuditTTlSetting{},
},
@@ -90,6 +96,7 @@ func (t *AuditSuite) Test_Events_DefaultEvents() {
entity.EventSuccessLogout: "успешный выход",
entity.EventRoleChanged: "изменение роли",
entity.EventUserChanged: "изменение пользователя",
entity.EventUserBlocked: "изменение статуса блокировки пользователя",
}
for _, event := range response {
name, found := expectedEventList[event.Event]
@@ -109,6 +116,7 @@ func (t *AuditSuite) Test_Events_SortEvents() {
{Event: entity.EventSuccessLogout, Enable: true},
{Event: entity.EventRoleChanged, Enable: false},
{Event: entity.EventUserChanged, Enable: true},
{Event: entity.EventUserBlocked, Enable: true},
{Event: "новый#2", Enable: false},
})
t.Require().NoError(err)
@@ -121,7 +129,7 @@ func (t *AuditSuite) Test_Events_SortEvents() {
t.Require().NoError(err)
expectedSort := []bool{
true, true, true, false, false, false, false,
true, true, true, true, false, false, false, false,
}
t.Require().Equal(len(expectedSort), len(response)) // nolint:testifylint
for i, event := range response {
@@ -145,6 +153,7 @@ func (t *AuditSuite) Test_SetEvents_HappyPath() {
entity.EventSuccessLogout: true,
entity.EventRoleChanged: false,
entity.EventUserChanged: true,
entity.EventUserBlocked: true,
}
eventRep := repository.NewAuditEvent(t.db)
eventList, err := eventRep.All(context.Background())
+4 -2
View File
@@ -11,14 +11,15 @@ import (
"testing"
"time"
"github.com/pkg/errors"
"golang.org/x/sync/errgroup"
"msp-admin-service/assembly"
"msp-admin-service/conf"
"msp-admin-service/domain"
"msp-admin-service/entity"
"msp-admin-service/repository"
"github.com/pkg/errors"
"golang.org/x/sync/errgroup"
"github.com/stretchr/testify/suite"
"github.com/txix-open/isp-kit/dbx"
"github.com/txix-open/isp-kit/grpc/client"
@@ -38,6 +39,7 @@ func TestAuthTestSuite(t *testing.T) {
type AuthTestSuite struct {
suite.Suite
test *test.Test
db *dbt.TestDb
grpcCli *client.Client
+1
View File
@@ -22,6 +22,7 @@ func TestCustomizationTestSuite(t *testing.T) {
type CustomizationTestSuite struct {
suite.Suite
test *test.Test
db *dbt.TestDb
grpcCli *client.Client
+2 -2
View File
@@ -1,14 +1,14 @@
package tests_test
import (
"msp-admin-service/entity"
"github.com/pkg/errors"
"github.com/txix-open/isp-kit/db/query"
"github.com/txix-open/isp-kit/test/dbt"
"golang.org/x/crypto/bcrypt"
"msp-admin-service/entity"
)
//nolint:gomnd
func InsertUser(db *dbt.TestDb, user entity.User) int64 {
if user.Password != "" {
passwordBytes, _ := bcrypt.GenerateFromPassword([]byte(user.Password), 12)
+1
View File
@@ -26,6 +26,7 @@ func TestSecureSuite(t *testing.T) {
type SecureSuite struct {
suite.Suite
test *test.Test
require *require.Assertions
db *dbt.TestDb
+62 -9
View File
@@ -2,12 +2,20 @@ package tests_test
import (
"context"
"github.com/txix-open/isp-kit/grpc/apierrors"
"golang.org/x/crypto/bcrypt"
"strconv"
"testing"
"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/stretchr/testify/suite"
"github.com/txix-open/isp-kit/dbx"
@@ -18,12 +26,6 @@ import (
"github.com/txix-open/isp-kit/test/grpct"
"google.golang.org/grpc/codes"
"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 {
@@ -37,6 +39,7 @@ func TestUserTestSuite(t *testing.T) {
type UserTestSuite struct {
suite.Suite
test *test.Test
db *dbt.TestDb
grpcCli *client.Client
@@ -201,6 +204,33 @@ func (s *UserTestSuite) TestCreateUserHappyPath() {
s.Require().Equal(preCount+1, postCount)
}
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)
}
func (s *UserTestSuite) TestCreateUserAlreadyExist() {
id := InsertUser(s.db, entity.User{Email: "exists@a.ru"})
@@ -246,7 +276,7 @@ func (s *AuthTestSuite) TestUpdateUserHappyPath() {
}
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"})
req := domain.UpdateUserRequest{
Id: id,
FirstName: "name",
@@ -290,6 +320,29 @@ func (s *AuthTestSuite) TestUpdateUserAlreadyExist() {
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() {
admin := InsertUser(s.db, entity.User{Email: "a_del@a.ru"})
InsertUser(s.db, entity.User{Email: "b_del@a.ru"})