2024-03-25 16:24:48: merge [main:72a62d1996eb71f9a1ab21643bf294148b87ae99];

This commit is contained in:
txix committed 2024-03-25 16:24:48 +03:00
1 parent 0669c6ec0a
commit ed8a4eef5d
85 files changed
+7671 -93

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
package domain
import (
"time"
)
type Audit struct {
Id int
UserId int
Message string
CreatedAt time.Time
}
type AuditResponse struct {
TotalCount int
Items []Audit
}
type PageRequest struct {
Limit int `valid:"required"`
Offset int
}
type SetAuditEvent struct {
Event string
Enabled bool
}
type AuditEvent struct {
Event string
Name string
Enabled bool
}
+29
View File
@@ -0,0 +1,29 @@
package domain
import (
"fmt"
"github.com/pkg/errors"
)
var (
ErrNotFound = errors.New("not found")
ErrUnauthenticated = errors.New("authentication failure")
ErrSudirAuthorization = errors.New("User is authorized only with SUDIR")
ErrSudirAuthIsMissed = errors.New("SUDIR authorization is not configured on the server")
ErrInvalid = errors.New("entity is invalid")
ErrAlreadyExists = errors.New("already exists")
ErrTokenExpired = errors.New("token expired")
ErrTokenNotFound = errors.New("token not found")
ErrTooManyLoginRequests = errors.New("too many login requests")
ErrUserIsBlocked = errors.New("user is blocked")
ErrNoActionRequired = errors.New("no action required")
)
type UnknownAuditEventError struct {
Event string
}
func (e UnknownAuditEventError) Error() string {
return fmt.Sprintf("unknown audit event: %s", e.Event)
}
+7
View File
@@ -0,0 +1,7 @@
package domain
type GrpcError struct {
ErrorMessage string `json:"errorMessage"`
ErrorCode string `json:"errorCode"`
Details []interface{} `json:"details"`
}
+22
View File
@@ -0,0 +1,22 @@
// nolint:tagliatelle
package domain
const (
AdminAuthHeaderName = "x-auth-admin"
AdminAuthIdHeader = "x-admin-id"
)
type LoginRequest struct {
Email string `valid:"required"`
Password string ` valid:"required"`
}
type LoginSudirRequest struct {
AuthCode string `valid:"required"`
}
type LoginResponse struct {
Token string
Expired string `json:",omitempty"`
HeaderName string
}
+6
View File
@@ -0,0 +1,6 @@
package domain
type Permission struct {
Key string
Name string
}
+36
View File
@@ -0,0 +1,36 @@
package domain
import (
"time"
)
type Role struct {
Id int
Name string
ExternalGroup string
ChangeMessage string
Permissions []string
Immutable bool
Exclusive bool
CreatedAt time.Time
UpdatedAt time.Time
}
type CreateRoleRequest struct {
Name string
ExternalGroup string
ChangeMessage string
Permissions []string
}
type UpdateRoleRequest struct {
Id int
Name string
ExternalGroup string
ChangeMessage string
Permissions []string
}
type DeleteRoleRequest struct {
Id int
}
+20
View File
@@ -0,0 +1,20 @@
package domain
type SecureAuthRequest struct {
Token string
}
type SecureAuthResponse struct {
Authenticated bool
ErrorReason string
AdminId int64
}
type SecureAuthzRequest struct {
AdminId int
Permission string
}
type SecureAuthzResponse struct {
Authorized bool
}
+27
View File
@@ -0,0 +1,27 @@
package domain
import (
"time"
)
type Session struct {
Id int
UserId int
Status string
ExpiredAt time.Time
CreatedAt time.Time
}
type SessionResponse struct {
TotalCount int
Items []Session
}
type SessionRequest struct {
Limit int
Offset int
}
type RevokeRequest struct {
Id int `valid:"required"`
}
+70
View File
@@ -0,0 +1,70 @@
package domain
import (
"time"
)
type User struct {
Id int64
Roles []int
FirstName string
LastName string
Email string
Description string
Blocked bool
LastSessionCreatedAt *time.Time
UpdatedAt time.Time
CreatedAt time.Time
}
type UsersResponse struct {
Items []User
}
type UsersRequest struct {
Ids []int64
Offset int
Limit int
Email string
}
type AdminUserShort struct {
FirstName string
LastName string
Email string `valid:"required"`
Role string
Roles []int
Permissions []string
IdleTimeoutMs int
}
type CreateUserRequest struct {
Roles []int
FirstName string
LastName string
Email string `valid:"required"`
Password string `valid:"required"`
Description string
}
type UpdateUserRequest struct {
Id int64 `valid:"required"`
Roles []int
FirstName string
LastName string
Email string
Description string
Blocked bool
}
type DeleteResponse struct {
Deleted int
}
type IdentitiesRequest struct {
Ids []int64 `valid:"required"`
}
type IdRequest struct {
UserId int `valid:"required"`
}