Documentation
¶
Index ¶
- Constants
- Variables
- func AdminKeyFromContext(ctx context.Context) (value string, found bool)
- func BaseType(elem any) reflect.Type
- func Collection[T any]() string
- func CompositeMiddleware(middleware ...mux.MiddlewareFunc) mux.MiddlewareFunc
- func ConfigFromEnv[T proto.Message](defaultConf T) T
- func ContextWithAdminKey(parent context.Context, key string) context.Context
- func ContextWithDirectives(parent context.Context, directives []string) context.Context
- func ContextWithSession(parent context.Context, session *authv1.Session) context.Context
- func DirectivesFromContext(ctx context.Context) (directives []string, found bool)
- func DoubleQuote(s string) string
- func Enforce[T proto.Message](ctx context.Context, enforcer casbin.IEnforcer, subjectFn SubjectFn[T], ...) (subject T, authorized bool)
- func Enforcer(conf, policy string) func() (*casbin.Enforcer, error)
- func ExposeNodes(nodes ...any) exposedNodes
- func GraphqlMiddleware(next http.Handler) http.Handler
- func ID[T any](key string) string
- func JSONName(f reflect.StructField) string
- func Map[T any](size int, fn func(int) T) (result []T)
- func Must[T any](v T, err error) T
- func Mutation[Arg, Out proto.Message](fn func(context.Context, Arg) (Out, error)) mutation
- func NewConnection(ctx context.Context, conf *configv1.Connection) (*connection, error)
- func NewDbFileStorage(access Access) *dbFileStorage
- func NewFilesystemStorage(config *configv1.FilesystemStorage) *filesystemStorage
- func NewGraph() *graph
- func NewObserver[T comparable]() *observer[T]
- func OTPMailSubscriber(ctx context.Context, config *configv1.Mail, message OTPMailTemplate) (Topic, Processor[Topic])
- func ProtoMarshal(v any, out proto.Message) error
- func Provide[T any](val any) fx.Option
- func Pure[T any](v T) (result T)
- func Query[Arg, Out proto.Message](fn func(context.Context, Arg) (Out, error)) query
- func QueryJoin(parts ...string) string
- func Quote(s string) string
- func ReadRequestBody(r *http.Request) ([]byte, error)
- func RegexpMiddleware(re *regexp.Regexp, mw mux.MiddlewareFunc) mux.MiddlewareFunc
- func RegisterAdmin(ctx context.Context, access Access, req *dashboardv1.CreateAccountRequest) (err error)
- func ResourceID(resource, key string) string
- func Select(v string) selector
- func SessionFromContext(ctx context.Context) (session *authv1.Session, found bool)
- func Should[T any](v T, _ error) T
- func Slice[T any](v ...T) []T
- func Subject[T proto.Message](ctx context.Context, subject SubjectFn[T]) (val T, err error)
- func ToMap(v any) (result map[string]any)
- func Vars() bindVars
- func VarsFor[T proto.Message](elem T) bindVars
- type Access
- type AdminHandler
- func (h *AdminHandler) CreateAccount(ctx context.Context, req *dashboardv1.CreateAccountRequest) (*emptypb.Empty, error)
- func (h *AdminHandler) CreateResource(ctx context.Context, req *dashboardv1.CreateResourceRequest) (*dashboardv1.CreateResourceResponse, error)
- func (h *AdminHandler) DeleteResource(ctx context.Context, req *dashboardv1.DeleteResourceRequest) (*emptypb.Empty, error)
- func (h *AdminHandler) FilesDownloadHandler(w http.ResponseWriter, r *http.Request, pathParams map[string]string)
- func (h *AdminHandler) FilesUploadHandler(w http.ResponseWriter, r *http.Request, _ map[string]string)
- func (h *AdminHandler) GetAccount(ctx context.Context, req *emptypb.Empty) (*dashboardv1.GetAccountResponse, error)
- func (h *AdminHandler) GetResource(ctx context.Context, req *dashboardv1.GetResourceRequest) (*dashboardv1.GetResourceResponse, error)
- func (h *AdminHandler) GetResourceRelation(ctx context.Context, req *dashboardv1.GetResourceRelationRequest) (*dashboardv1.GetResourceRelationResponse, error)
- func (h *AdminHandler) GetSchema(ctx context.Context, req *emptypb.Empty) (*dashboardv1.GetSchemaResponse, error)
- func (h *AdminHandler) Handler(ctx context.Context) http.Handler
- func (h *AdminHandler) ListResources(ctx context.Context, req *dashboardv1.ListResourcesRequest) (*dashboardv1.ListResourcesResponse, error)
- func (h *AdminHandler) Login(ctx context.Context, req *dashboardv1.LoginRequest) (*dashboardv1.LoginResponse, error)
- func (h *AdminHandler) UpdateResource(ctx context.Context, req *dashboardv1.UpdateResourceRequest) (*dashboardv1.UpdateResourceResponse, error)
- type AdminHandlerParams
- type ArangoAccess
- func (e *ArangoAccess) AutoMigrate(ctx context.Context, graph Graph) error
- func (e *ArangoAccess) Collection(ctx context.Context, elem any, callbacks ...CollectionCallback) (col driver.Collection, err error)
- func (e *ArangoAccess) Create(ctx context.Context, val any) ([]string, error)
- func (e *ArangoAccess) Delete(ctx context.Context, item any) error
- func (e *ArangoAccess) Fetch(ctx context.Context, query string, bindVars map[string]any, out any) error
- func (e *ArangoAccess) Find(ctx context.Context, bindVars BindVars, out any) error
- func (e *ArangoAccess) List(ctx context.Context, bindVars BindVars, out any) (int64, error)
- func (e *ArangoAccess) Query(ctx context.Context, query string, bindVars map[string]any, out any) error
- func (e *ArangoAccess) Relations(ctx context.Context, id string, bindVars BindVars, direction Direction, ...) (int64, error)
- func (e *ArangoAccess) Replace(ctx context.Context, key string, item any) error
- func (e *ArangoAccess) Update(ctx context.Context, key string, item any) error
- type AuthHandler
- func (h *AuthHandler) Handler(ctx context.Context) http.Handler
- func (h *AuthHandler) Middleware(next http.Handler) http.Handler
- func (h *AuthHandler) ParseClaims(tokenString string) (*jwt.RegisteredClaims, error)
- func (h *AuthHandler) RefreshToken(ctx context.Context, req *emptypb.Empty) (*authv1.RefreshTokenResponse, error)
- func (h *AuthHandler) RequestOTP(ctx context.Context, req *authv1.RequestOTPRequest) (*argumentv1.Success, error)
- func (h *AuthHandler) ValidateSSOToken(ctx context.Context, req *emptypb.Empty) (*authv1.ValidateSSOTokenResponse, error)
- func (h *AuthHandler) VerifyOTP(ctx context.Context, req *authv1.VerifyOTPRequest) (*authv1.VerifyOTPResponse, error)
- type AuthHandlerParams
- type BindVars
- type CasbinAdapter
- func (a *CasbinAdapter[T]) AddPolicy(sec string, ptype string, rule []string) error
- func (a *CasbinAdapter[T]) Fields() (result []protoreflect.FieldDescriptor)
- func (a *CasbinAdapter[T]) LoadPolicy(model model.Model) error
- func (a *CasbinAdapter[T]) Marshal(el T) (sec string, ptype string, rule []string)
- func (a *CasbinAdapter[T]) RemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) error
- func (a *CasbinAdapter[T]) RemovePolicy(sec string, ptype string, rule []string) error
- func (a *CasbinAdapter[T]) SavePolicy(model model.Model) error
- func (a *CasbinAdapter[T]) Unmarshal(sec string, ptype string, rule []string) (out T, err error)
- type CollectionCallback
- type Connection
- type Direction
- type EnforceFn
- type Event
- type FileStorage
- type Graph
- type GraphqlHandler
- type OTPMailTemplate
- type Observer
- type Processor
- type Relation
- type Rule
- type Rules
- type SourceID
- type SubjectFn
- type Topic
Constants ¶
const ( // MaxBodySize limits the amount of data read from the request body to prevent memory exhaustion MaxBodySize = 2 * 1024 * 1024 // 2 MB )
Variables ¶
var (
OTPRequestedTopic = Topic("auth.otp.requested")
)
Functions ¶
func AdminKeyFromContext ¶ added in v0.6.7
func Collection ¶ added in v0.0.19
Collection returns the name of the collection for the given element
func CompositeMiddleware ¶ added in v0.8.9
func CompositeMiddleware(middleware ...mux.MiddlewareFunc) mux.MiddlewareFunc
CompositeMiddleware composes multiple mux.MiddlewareFunc into a single one, applying them in the order provided (first to last).
func ConfigFromEnv ¶ added in v0.8.6
func ContextWithAdminKey ¶ added in v0.6.7
func ContextWithDirectives ¶ added in v0.8.9
func ContextWithSession ¶ added in v0.8.0
func DirectivesFromContext ¶ added in v0.8.9
func Enforce ¶ added in v0.8.0
func Enforce[T proto.Message](ctx context.Context, enforcer casbin.IEnforcer, subjectFn SubjectFn[T], enforceFn EnforceFn[T]) (subject T, authorized bool)
Enforce is a helper function to enforce a policy
func JSONName ¶ added in v0.7.11
func JSONName(f reflect.StructField) string
JSONName returns the name of the field in the JSON tag
func NewConnection ¶
func NewConnection(ctx context.Context, conf *configv1.Connection) (*connection, error)
NewConnection ...
func NewDbFileStorage ¶ added in v0.4.33
func NewDbFileStorage(access Access) *dbFileStorage
NewDbFileStorage ...
func NewFilesystemStorage ¶ added in v0.0.6
func NewFilesystemStorage(config *configv1.FilesystemStorage) *filesystemStorage
NewFilesystemStorage ...
func OTPMailSubscriber ¶ added in v0.8.10
func OTPMailSubscriber(ctx context.Context, config *configv1.Mail, message OTPMailTemplate) (Topic, Processor[Topic])
OTPMailSubscriber is a function that sends an email to the user with the OTP code
func Pure ¶ added in v0.4.6
func Pure[T any](v T) (result T)
Pure converts a value to a pure JSON value
func ReadRequestBody ¶ added in v0.8.9
ReadRequestBody reads and returns the full body of the request without consuming it permanently. It restores the body so it can be read again later. Returns an error if reading fails or body exceeds MaxBodySize.
func RegexpMiddleware ¶ added in v0.8.9
func RegexpMiddleware(re *regexp.Regexp, mw mux.MiddlewareFunc) mux.MiddlewareFunc
RegexpMiddleware applies a single mux.MiddlewareFunc only if the request path matches the given regexp.
func RegisterAdmin ¶ added in v0.4.36
func RegisterAdmin(ctx context.Context, access Access, req *dashboardv1.CreateAccountRequest) (err error)
func ResourceID ¶ added in v0.8.0
func SessionFromContext ¶ added in v0.8.0
Types ¶
type Access ¶ added in v0.4.43
type Access interface {
// AutoMigrate ...
AutoMigrate(ctx context.Context, graph Graph) error
// Collection ...
Collection(ctx context.Context, elem any, callbacks ...CollectionCallback) (driver.Collection, error)
// Query returns a list of elements
Query(ctx context.Context, query string, bindVars map[string]any, out any) error
// Fetch returns a single element
Fetch(ctx context.Context, query string, bindVars map[string]any, out any) error
// List ...
List(ctx context.Context, bindVars BindVars, out any) (int64, error)
// Find ...
Find(ctx context.Context, bindVars BindVars, out any) error
// Create ...
Create(ctx context.Context, val any) ([]string, error)
// Update ...
Update(ctx context.Context, key string, item any) error
// Replace ...
Replace(ctx context.Context, key string, item any) error
// Delete ...
Delete(ctx context.Context, item any) error
// Relations ...
Relations(ctx context.Context, id string, bindVars BindVars, direction Direction, out any) (int64, error)
}
Access ...
type AdminHandler ¶ added in v0.4.3
type AdminHandler struct {
dashboardv1.UnimplementedAuthenticationServiceServer
dashboardv1.UnimplementedResourceServiceServer
dashboardv1.UnimplementedSchemaServiceServer
// contains filtered or unexported fields
}
AdminHandler ...
func NewAdminHandler ¶ added in v0.4.3
func NewAdminHandler(ctx context.Context, config *configv1.Dashboard, params AdminHandlerParams) (*AdminHandler, error)
NewAdminHandler ...
func (*AdminHandler) CreateAccount ¶ added in v0.4.6
func (h *AdminHandler) CreateAccount(ctx context.Context, req *dashboardv1.CreateAccountRequest) (*emptypb.Empty, error)
func (*AdminHandler) CreateResource ¶ added in v0.4.6
func (h *AdminHandler) CreateResource(ctx context.Context, req *dashboardv1.CreateResourceRequest) (*dashboardv1.CreateResourceResponse, error)
func (*AdminHandler) DeleteResource ¶ added in v0.4.6
func (h *AdminHandler) DeleteResource(ctx context.Context, req *dashboardv1.DeleteResourceRequest) (*emptypb.Empty, error)
func (*AdminHandler) FilesDownloadHandler ¶ added in v0.4.6
func (h *AdminHandler) FilesDownloadHandler(w http.ResponseWriter, r *http.Request, pathParams map[string]string)
func (*AdminHandler) FilesUploadHandler ¶ added in v0.4.6
func (h *AdminHandler) FilesUploadHandler(w http.ResponseWriter, r *http.Request, _ map[string]string)
func (*AdminHandler) GetAccount ¶ added in v0.4.6
func (h *AdminHandler) GetAccount(ctx context.Context, req *emptypb.Empty) (*dashboardv1.GetAccountResponse, error)
func (*AdminHandler) GetResource ¶ added in v0.4.6
func (h *AdminHandler) GetResource(ctx context.Context, req *dashboardv1.GetResourceRequest) (*dashboardv1.GetResourceResponse, error)
func (*AdminHandler) GetResourceRelation ¶ added in v0.4.6
func (h *AdminHandler) GetResourceRelation(ctx context.Context, req *dashboardv1.GetResourceRelationRequest) (*dashboardv1.GetResourceRelationResponse, error)
func (*AdminHandler) GetSchema ¶ added in v0.4.6
func (h *AdminHandler) GetSchema(ctx context.Context, req *emptypb.Empty) (*dashboardv1.GetSchemaResponse, error)
func (*AdminHandler) Handler ¶ added in v0.4.3
func (h *AdminHandler) Handler(ctx context.Context) http.Handler
func (*AdminHandler) ListResources ¶ added in v0.4.6
func (h *AdminHandler) ListResources(ctx context.Context, req *dashboardv1.ListResourcesRequest) (*dashboardv1.ListResourcesResponse, error)
func (*AdminHandler) Login ¶ added in v0.4.6
func (h *AdminHandler) Login(ctx context.Context, req *dashboardv1.LoginRequest) (*dashboardv1.LoginResponse, error)
func (*AdminHandler) UpdateResource ¶ added in v0.4.6
func (h *AdminHandler) UpdateResource(ctx context.Context, req *dashboardv1.UpdateResourceRequest) (*dashboardv1.UpdateResourceResponse, error)
type AdminHandlerParams ¶ added in v0.4.3
type AdminHandlerParams struct {
fx.In
Access Access
Graph Graph
Storage FileStorage
Observer Observer[Topic]
}
AdminHandlerParams ...
type ArangoAccess ¶ added in v0.4.3
type ArangoAccess struct {
// contains filtered or unexported fields
}
func NewArangoAccess ¶ added in v0.4.3
func NewArangoAccess(conn Connection, observer Observer[Topic]) (*ArangoAccess, error)
func (*ArangoAccess) AutoMigrate ¶ added in v0.4.3
func (e *ArangoAccess) AutoMigrate(ctx context.Context, graph Graph) error
AutoMigrate ...
func (*ArangoAccess) Collection ¶ added in v0.4.3
func (e *ArangoAccess) Collection(ctx context.Context, elem any, callbacks ...CollectionCallback) (col driver.Collection, err error)
Collection ...
func (*ArangoAccess) Delete ¶ added in v0.4.3
func (e *ArangoAccess) Delete(ctx context.Context, item any) error
Delete ...
func (*ArangoAccess) Fetch ¶ added in v0.4.43
func (e *ArangoAccess) Fetch(ctx context.Context, query string, bindVars map[string]any, out any) error
Fetch ...
func (*ArangoAccess) Query ¶ added in v0.4.43
func (e *ArangoAccess) Query(ctx context.Context, query string, bindVars map[string]any, out any) error
Query ...
func (*ArangoAccess) Relations ¶ added in v0.4.3
func (e *ArangoAccess) Relations(ctx context.Context, id string, bindVars BindVars, direction Direction, out any) (int64, error)
Relations ...
type AuthHandler ¶ added in v0.8.0
type AuthHandler struct {
authv1.UnsafeAuthenticationServiceServer
// contains filtered or unexported fields
}
func NewAuthHandler ¶ added in v0.8.0
func NewAuthHandler(ctx context.Context, config *configv1.Auth, params AuthHandlerParams) (*AuthHandler, error)
func (*AuthHandler) Handler ¶ added in v0.8.0
func (h *AuthHandler) Handler(ctx context.Context) http.Handler
func (*AuthHandler) Middleware ¶ added in v0.8.0
func (h *AuthHandler) Middleware(next http.Handler) http.Handler
func (*AuthHandler) ParseClaims ¶ added in v0.8.0
func (h *AuthHandler) ParseClaims(tokenString string) (*jwt.RegisteredClaims, error)
func (*AuthHandler) RefreshToken ¶ added in v0.8.0
func (h *AuthHandler) RefreshToken(ctx context.Context, req *emptypb.Empty) (*authv1.RefreshTokenResponse, error)
func (*AuthHandler) RequestOTP ¶ added in v0.8.0
func (h *AuthHandler) RequestOTP(ctx context.Context, req *authv1.RequestOTPRequest) (*argumentv1.Success, error)
func (*AuthHandler) ValidateSSOToken ¶ added in v0.8.0
func (h *AuthHandler) ValidateSSOToken(ctx context.Context, req *emptypb.Empty) (*authv1.ValidateSSOTokenResponse, error)
func (*AuthHandler) VerifyOTP ¶ added in v0.8.0
func (h *AuthHandler) VerifyOTP(ctx context.Context, req *authv1.VerifyOTPRequest) (*authv1.VerifyOTPResponse, error)
type AuthHandlerParams ¶ added in v0.8.0
type BindVars ¶ added in v0.8.0
type BindVars interface {
// LimitString ...
LimitString() string
// FiltersString ...
FiltersString() string
// Values ...
Values() map[string]interface{}
}
BindVars ...
type CasbinAdapter ¶ added in v0.8.0
CasbinAdapter ...
func NewCasbinAdapter ¶ added in v0.8.0
func NewCasbinAdapter[T proto.Message](ctx context.Context, access Access) (*CasbinAdapter[T], error)
NewCasbinAdapter ...
func (*CasbinAdapter[T]) AddPolicy ¶ added in v0.8.0
func (a *CasbinAdapter[T]) AddPolicy(sec string, ptype string, rule []string) error
AddPolicy implements persist.Adapter.
func (*CasbinAdapter[T]) Fields ¶ added in v0.8.0
func (a *CasbinAdapter[T]) Fields() (result []protoreflect.FieldDescriptor)
func (*CasbinAdapter[T]) LoadPolicy ¶ added in v0.8.0
func (a *CasbinAdapter[T]) LoadPolicy(model model.Model) error
LoadPolicy implements persist.Adapter.
func (*CasbinAdapter[T]) Marshal ¶ added in v0.8.0
func (a *CasbinAdapter[T]) Marshal(el T) (sec string, ptype string, rule []string)
func (*CasbinAdapter[T]) RemoveFilteredPolicy ¶ added in v0.8.0
func (a *CasbinAdapter[T]) RemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) error
RemoveFilteredPolicy implements persist.Adapter.
func (*CasbinAdapter[T]) RemovePolicy ¶ added in v0.8.0
func (a *CasbinAdapter[T]) RemovePolicy(sec string, ptype string, rule []string) error
RemovePolicy implements persist.Adapter.
func (*CasbinAdapter[T]) SavePolicy ¶ added in v0.8.0
func (a *CasbinAdapter[T]) SavePolicy(model model.Model) error
SavePolicy implements persist.Adapter.
type CollectionCallback ¶ added in v0.4.3
type CollectionCallback func(context.Context, driver.Collection)
CollectionCallback ...
type Connection ¶ added in v0.4.43
type Connection interface {
// Database ...
Database(ctx context.Context) (driver.Database, error)
// Collection ...
Collection(ctx context.Context, elem any) (driver.Collection, error)
// Reflect ...
Reflect(ctx context.Context, elem reflect.Type) (driver.Collection, error)
}
Connection ...
type Event ¶
type Event[T comparable] struct { // Topic ... Topic T // Payload ... Payload protoreflect.ProtoMessage // Timestamp ... Timestamp time.Time }
Event ...
type FileStorage ¶ added in v0.4.43
type FileStorage interface {
// StoreFile ...
StoreFile(name string, file []byte) (err error)
// StoreByHash ...
StoreByHash(file []byte) (hash string, err error)
// ReadFile ...
ReadFile(name string) (fileContent []byte, errr error)
// MaxMemory ...
MaxMemory() int64
}
FileStorage ...
type Graph ¶ added in v0.4.3
type Graph interface {
// Node ...
Node(node any)
// Edge ...
Edge(from, to, edge any)
// Nodes ...
Nodes() []reflect.Type
// Edges ...
Edges() []reflect.Type
// Relation ...
Relation(edge reflect.Type) *Relation
// CollectionFor ...
CollectionFor(elem reflect.Type) string
// TypeOf ...
TypeOf(name string) reflect.Type
}
Graph ...
type GraphqlHandler ¶ added in v0.4.3
type GraphqlHandler struct {
// contains filtered or unexported fields
}
GraphqlHandler ...
func NewGraphqlHandler ¶ added in v0.4.3
func NewGraphqlHandler(access Access, graph Graph) (*GraphqlHandler, error)
NewGraphqlHandler ...
type OTPMailTemplate ¶ added in v0.8.10
OTPMailTemplate is a function that returns the message to send to the user
type Observer ¶
type Observer[T comparable] interface { // Subscribe ... Subscribe(t T, p Processor[T]) SourceID // Unsubscribe ... Unsubscribe(s SourceID) // Emit ... Emit(e *Event[T]) error }
Observer ...
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
library
command
|
|
|
internal
|
|
|
pkg
|
|
|
auth/domain/auth/v1
Package authv1 is a reverse proxy.
|
Package authv1 is a reverse proxy. |
|
dashboard/domain/dashboard/v1
Package dashboardv1 is a reverse proxy.
|
Package dashboardv1 is a reverse proxy. |