Documentation
¶
Index ¶
- func RunAPIKeyCmd(rt mdk.Runtime, args []string) error
- type APIKey
- type APIKeyInfo
- type GeneratedAPIKey
- type Module
- func (m *Module) APIKeyMiddleware(next http.Handler) http.Handler
- func (m *Module) CreateAPIKey(ctx context.Context, actorID string, name string, expiresAt *time.Time) (*APIKey, error)
- func (m *Module) CreateAPIKeyResolver(ctx context.Context, name string, expiresAt *time.Time) (*GeneratedAPIKey, error)
- func (m *Module) FieldResolvers() map[string]any
- func (m *Module) GetActorByAPIKey(ctx context.Context, key string) (mdk.Actor, error)
- func (m *Module) ID() string
- func (m *Module) Init(ctx context.Context, rt mdk.Runtime) error
- func (m *Module) ListAPIKeys(ctx context.Context, actorID string) ([]*APIKey, error)
- func (m *Module) ListAPIKeysResolver(ctx context.Context) ([]*APIKeyInfo, error)
- func (m *Module) Middlewares() []func(http.Handler) http.Handler
- func (m *Module) Models() []any
- func (m *Module) Mutations() map[string]any
- func (m *Module) Queries() map[string]any
- func (m *Module) RevokeAPIKey(ctx context.Context, actorID string, keyID string) (bool, error)
- func (m *Module) RevokeAPIKeyResolver(ctx context.Context, id string) (bool, error)
- func (m *Module) Routes() []mdk.Route
- func (m *Module) Shutdown(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type APIKey ¶
type APIKey struct {
ID string `gorm:"primaryKey" json:"id"`
Name string `gorm:"default:'';not null" json:"name"`
Key string `gorm:"uniqueIndex;not null" json:"key"`
ActorID string `gorm:"not null" json:"actor_id"`
Actor auth.Actor `gorm:"foreignKey:ActorID" json:"actor"`
ExpiresAt *time.Time `json:"expires_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}
APIKey represents a secret key used for authentication.
type APIKeyInfo ¶
type GeneratedAPIKey ¶
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
func (*Module) APIKeyMiddleware ¶ added in v0.4.0
func (*Module) CreateAPIKey ¶
func (m *Module) CreateAPIKey(ctx context.Context, actorID string, name string, expiresAt *time.Time) (*APIKey, error)
CreateAPIKey generates a new secure API key for the given actor.
func (*Module) CreateAPIKeyResolver ¶
func (*Module) FieldResolvers ¶
func (*Module) GetActorByAPIKey ¶
GetActorByAPIKey retrieves an actor associated with a given API key.
func (*Module) ListAPIKeys ¶
ListAPIKeys lists all active API keys for the given actor.
func (*Module) ListAPIKeysResolver ¶
func (m *Module) ListAPIKeysResolver(ctx context.Context) ([]*APIKeyInfo, error)
func (*Module) Middlewares ¶ added in v0.4.0
Middlewares implements mdk.MiddlewareProvider interface.
func (*Module) RevokeAPIKey ¶
RevokeAPIKey deletes/revokes an API key.
func (*Module) RevokeAPIKeyResolver ¶
Click to show internal directories.
Click to hide internal directories.