v1

package
v0.0.0-...-cf98a52 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	WithAssertion2FA               = api.WithMetadataItem("assertion_2fa", admin.Assertion2FA{})
	WithAssertionSuperAdmin        = api.WithMetadataItem("assertion_sa", admin.AssertionSuperAdmin{})
	WithAssertionSuperAdminOrOwner = api.WithMetadataItem("assertion_sa_owner", admin.AssertionSuperAdminOrOwner{})
	WithSecurity                   = api.WithSecurity(Security)
	WithNoSecurity                 = func(op *huma.Operation) {
		op.Security = nil
		if op.Metadata == nil {
			return
		}
		for _, v := range op.Metadata {
			switch v := v.(type) {
			case *rbac.Target:
				v.Assertions = nil
			}
		}
	}
	WithNoAssertions = func(op *huma.Operation) {
		if op.Metadata == nil {
			return
		}
		metadata := make(map[string]any)
		for k, v := range op.Metadata {
			switch v := v.(type) {
			case *rbac.Target:
				v.Assertions = nil
				metadata[k] = v
			case rbac.Assertion, []rbac.Assertion:
			default:
				metadata[k] = v
			}
		}
		op.Metadata = metadata
	}
)
View Source
var Info = api.CRUDInfo{Area: "admin", Version: "v1"}
View Source
var Security = []map[string][]string{
	{"basic": {}},
	{"bearer": {}},
}

Functions

This section is empty.

Types

type Admin

type Admin struct {
	api.List[model.Admin]
	api.Read[model.Admin, int64]
	api.Create[CreateAdminBody, model.Admin, int64]
	api.Update[UpdateAdminBody, model.Admin, int64]
	// contains filtered or unexported fields
}

func NewAdmin

func NewAdmin(r repository.Admin, refreshRepo repository.RefreshToken, errorTransformer api.ErrorTransformerFunc) Admin

func (Admin) Area

func (Admin) Area() string

func (Admin) Register

func (r Admin) Register(e *echo.Echo, humaAPI huma.API)

func (Admin) Version

func (Admin) Version() string

type Auth

type Auth struct {
	// contains filtered or unexported fields
}

func NewAuth

func NewAuth(service admin.AuthService, logger *zap.Logger) Auth

func (Auth) Area

func (Auth) Area() string

func (Auth) Register

func (r Auth) Register(_ *echo.Echo, humaAPI huma.API)

func (Auth) Version

func (Auth) Version() string

type AvatarInput

type AvatarInput struct {
	Male int `query:"male,omitempty" required:"false"`
}

type CreateAdminBody

type CreateAdminBody struct {
	Avatar   string         `json:"avatar,omitempty" yaml:"avatar,omitempty" required:"true"`
	Email    string         `json:"email,omitempty" yaml:"email,omitempty" required:"true" format:"email" maxLength:"254"`
	Username string         `json:"username,omitempty" yaml:"username,omitempty" required:"true" minLength:"3" maxLength:"100"`
	Password string         `json:"password,omitempty" yaml:"password,omitempty" required:"true" minLength:"8" maxLength:"64"`
	IsActive bool           `json:"isActive,omitempty" yaml:"isActive,omitempty" required:"false"`
	Roles    []string       `json:"roles,omitempty" yaml:"roles,omitempty" required:"true" uniqueItems:"true"`
	Metadata map[string]any `json:"metadata,omitempty" yaml:"metadata,omitempty" required:"false"`
}

func (CreateAdminBody) Decode

func (dto CreateAdminBody) Decode(_ context.Context, m *model.Admin) error

type IssuerInput

type IssuerInput struct {
	Issuer string `query:"issuer,omitempty" required:"true"`
}

type OTP

type OTP struct {
	Body struct {
		Password string `json:"password,omitempty" required:"true" minLength:"6" maxLength:"6" pattern:"[0-9]+"`
	}
}

type RefreshToken

type RefreshToken struct {
	Body struct {
		RefreshToken string `json:"refreshToken,omitempty" required:"true"`
	}
}

type SignIn

type SignIn struct {
	Body struct {
		Username string `json:"username,omitempty" required:"true" minLength:"3" maxLength:"100"`
		Password string `json:"password,omitempty" required:"true" minLength:"8" maxLength:"64"`
	}
}

type UpdateAdminBody

type UpdateAdminBody struct {
	Avatar   *string         `json:"avatar,omitempty" yaml:"avatar,omitempty" required:"false"`
	Email    *string         `json:"email,omitempty" yaml:"email,omitempty" required:"false" format:"email" maxLength:"254"`
	Username *string         `json:"username,omitempty" yaml:"username,omitempty" required:"false" minLength:"3" maxLength:"100"`
	Password *string         `json:"password,omitempty" yaml:"password,omitempty" required:"false" minLength:"8" maxLength:"64"`
	Metadata *map[string]any `json:"metadata,omitempty" yaml:"metadata,omitempty" required:"false"`
}

func (UpdateAdminBody) Decode

func (dto UpdateAdminBody) Decode(_ context.Context, m *model.Admin) error

type UpdateRolesBody

type UpdateRolesBody struct {
	Roles []string `json:"roles,omitempty" yaml:"roles,omitempty" required:"true" uniqueItems:"true"`
}

func (UpdateRolesBody) Decode

func (dto UpdateRolesBody) Decode(_ context.Context, m *model.Admin) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL