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 CreateDashboardAdmin(ctx context.Context, access Access, req *dashboardv1.CreateAccountRequest) (err error)
- func DirectivesFromContext(ctx context.Context) (directives []string, found bool)
- func Dot(parts ...string) string
- 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 Expose[T proto.Message]() exposed
- func GraphqlMiddleware(next http.Handler) http.Handler
- func HandleDownloadFile[T FileStorage](fs T) runtime.HandlerFunc
- func HandleUploadFile[T FileStorage](fs T) runtime.HandlerFunc
- func HashFile(file []byte) (string, error)
- func HttpHandler(hf grpc_runtime.HandlerFunc) http.HandlerFunc
- func ID[T any](key string) string
- func JSONName(f reflect.StructField) string
- func Join(parts ...string) string
- func Map[T any](size int, fn func(int) T) (result []T)
- func Match(re *regexp.Regexp, mw ...mux.MiddlewareFunc) mux.MiddlewareFunc
- 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, error)
- 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 ResourceID(resource, key string) string
- func RuntimeHandler(hf http.HandlerFunc) grpc_runtime.HandlerFunc
- func Select[T any](v T) selector[T]
- func SessionFromContext(ctx context.Context) (session *authv1.Session, found bool)
- func Should[T any](v T, _ error) 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 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) 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 DashboardHandler
- func (h *DashboardHandler) CreateAccount(ctx context.Context, req *dashboardv1.CreateAccountRequest) (*emptypb.Empty, error)
- func (h *DashboardHandler) CreateResource(ctx context.Context, req *dashboardv1.CreateResourceRequest) (*dashboardv1.CreateResourceResponse, error)
- func (h *DashboardHandler) DeleteResource(ctx context.Context, req *dashboardv1.DeleteResourceRequest) (*emptypb.Empty, error)
- func (h *DashboardHandler) GetAccount(ctx context.Context, req *emptypb.Empty) (*dashboardv1.GetAccountResponse, error)
- func (h *DashboardHandler) GetResource(ctx context.Context, req *dashboardv1.GetResourceRequest) (*dashboardv1.GetResourceResponse, error)
- func (h *DashboardHandler) GetResourceRelation(ctx context.Context, req *dashboardv1.GetResourceRelationRequest) (*dashboardv1.GetResourceRelationResponse, error)
- func (h *DashboardHandler) GetSchema(ctx context.Context, req *emptypb.Empty) (*dashboardv1.GetSchemaResponse, error)
- func (h *DashboardHandler) Handler(ctx context.Context) http.Handler
- func (h *DashboardHandler) ListResources(ctx context.Context, req *dashboardv1.ListResourcesRequest) (*dashboardv1.ListResourcesResponse, error)
- func (h *DashboardHandler) Login(ctx context.Context, req *dashboardv1.LoginRequest) (*dashboardv1.LoginResponse, error)
- func (h *DashboardHandler) UpdateResource(ctx context.Context, req *dashboardv1.UpdateResourceRequest) (*dashboardv1.UpdateResourceResponse, error)
- type DashboardParams
- 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 Set
- type SourceID
- type SubjectFn
- type Topic
Constants ¶
const ( // RequestMaxBodySize limits the amount of data read from the request body to prevent memory exhaustion RequestMaxBodySize = 2 * 1024 * 1024 // 2 MB )
Variables ¶
var (
OTPRequestedTopic = Topic("auth.otp.requested")
)
Functions ¶
func Collection ¶
Collection returns the name of the collection for the given element
func CompositeMiddleware ¶
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 ¶
func ContextWithAdminKey ¶
func ContextWithDirectives ¶
func ContextWithSession ¶
func CreateDashboardAdmin ¶ added in v0.9.7
func CreateDashboardAdmin(ctx context.Context, access Access, req *dashboardv1.CreateAccountRequest) (err error)
func DirectivesFromContext ¶
func Enforce ¶
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 GraphqlMiddleware ¶
GraphqlMiddleware injects the directives into the context
func HandleDownloadFile ¶ added in v0.9.7
func HandleDownloadFile[T FileStorage](fs T) runtime.HandlerFunc
func HandleUploadFile ¶ added in v0.9.7
func HandleUploadFile[T FileStorage](fs T) runtime.HandlerFunc
func HttpHandler ¶ added in v0.9.7
func HttpHandler(hf grpc_runtime.HandlerFunc) http.HandlerFunc
HttpHandler converts a runtime.HandlerFunc to a http.HandlerFunc
func JSONName ¶
func JSONName(f reflect.StructField) string
JSONName returns the name of the field in the JSON tag
func Match ¶ added in v0.9.7
func Match(re *regexp.Regexp, mw ...mux.MiddlewareFunc) mux.MiddlewareFunc
Match applies a single mux.MiddlewareFunc only if the request path matches the given regexp.
func NewConnection ¶
func NewConnection(ctx context.Context, conf *configv1.Connection) (*connection, error)
NewConnection ...
func NewDbFileStorage ¶
NewDbFileStorage ...
func NewFilesystemStorage ¶
func NewFilesystemStorage(config *configv1.FilesystemStorage) *filesystemStorage
NewFilesystemStorage ...
func OTPMailSubscriber ¶
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 ReadRequestBody ¶
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 ResourceID ¶
func RuntimeHandler ¶ added in v0.9.7
func RuntimeHandler(hf http.HandlerFunc) grpc_runtime.HandlerFunc
RuntimeHandler converts a http.HandlerFunc to a runtime.HandlerFunc
func Select ¶
func Select[T any](v T) selector[T]
Select returns a new selector with the given value
func SessionFromContext ¶
Types ¶
type Access ¶
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 ArangoAccess ¶
type ArangoAccess struct {
// contains filtered or unexported fields
}
func NewArangoAccess ¶
func NewArangoAccess(conn Connection, observer Observer[Topic]) (*ArangoAccess, error)
func (*ArangoAccess) AutoMigrate ¶
func (e *ArangoAccess) AutoMigrate(ctx context.Context, graph Graph) error
AutoMigrate ...
func (*ArangoAccess) Collection ¶
func (e *ArangoAccess) Collection(ctx context.Context, elem any, callbacks ...CollectionCallback) (col driver.Collection, err error)
Collection ...
func (*ArangoAccess) Delete ¶
func (e *ArangoAccess) Delete(ctx context.Context, item any) error
Delete ...
func (*ArangoAccess) Fetch ¶
func (e *ArangoAccess) Fetch(ctx context.Context, query string, bindVars map[string]any, out any) error
Fetch ...
func (*ArangoAccess) Query ¶
func (e *ArangoAccess) Query(ctx context.Context, query string, bindVars map[string]any, out any) error
Query ...
func (*ArangoAccess) Relations ¶
func (e *ArangoAccess) Relations(ctx context.Context, id string, bindVars BindVars, direction Direction, out any) (int64, error)
Relations ...
type AuthHandler ¶
type AuthHandler struct { authv1.UnsafeAuthenticationServiceServer // contains filtered or unexported fields }
func NewAuthHandler ¶
func NewAuthHandler(ctx context.Context, config *configv1.Auth, params AuthHandlerParams) (*AuthHandler, error)
func (*AuthHandler) Middleware ¶
func (h *AuthHandler) Middleware(next http.Handler) http.Handler
func (*AuthHandler) RefreshToken ¶
func (h *AuthHandler) RefreshToken(ctx context.Context, req *emptypb.Empty) (*authv1.RefreshTokenResponse, error)
func (*AuthHandler) RequestOTP ¶
func (h *AuthHandler) RequestOTP(ctx context.Context, req *authv1.RequestOTPRequest) (*argumentv1.Success, error)
func (*AuthHandler) ValidateSSOToken ¶
func (h *AuthHandler) ValidateSSOToken(ctx context.Context, req *emptypb.Empty) (*authv1.ValidateSSOTokenResponse, error)
func (*AuthHandler) VerifyOTP ¶
func (h *AuthHandler) VerifyOTP(ctx context.Context, req *authv1.VerifyOTPRequest) (*authv1.VerifyOTPResponse, error)
type AuthHandlerParams ¶
type BindVars ¶
type BindVars interface { // LimitString ... LimitString() string // FiltersFor ... FiltersFor(doc string) string // Values ... Values() map[string]interface{} }
BindVars ...
type CasbinAdapter ¶
CasbinAdapter ...
func Unsafe_NewCasbinAdapter ¶ added in v0.9.6
func Unsafe_NewCasbinAdapter[T proto.Message](ctx context.Context, access Access) (*CasbinAdapter[T], error)
Unsafe_NewCasbinAdapter ... TODO: finish this
func (*CasbinAdapter[T]) AddPolicy ¶
func (a *CasbinAdapter[T]) AddPolicy(sec string, ptype string, rule []string) error
AddPolicy implements persist.Adapter.
func (*CasbinAdapter[T]) Fields ¶
func (a *CasbinAdapter[T]) Fields() (result []protoreflect.FieldDescriptor)
func (*CasbinAdapter[T]) LoadPolicy ¶
func (a *CasbinAdapter[T]) LoadPolicy(model model.Model) error
LoadPolicy implements persist.Adapter.
func (*CasbinAdapter[T]) Marshal ¶
func (a *CasbinAdapter[T]) Marshal(el T) (sec string, ptype string, rule []string)
func (*CasbinAdapter[T]) RemoveFilteredPolicy ¶
func (a *CasbinAdapter[T]) RemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) error
RemoveFilteredPolicy implements persist.Adapter.
func (*CasbinAdapter[T]) RemovePolicy ¶
func (a *CasbinAdapter[T]) RemovePolicy(sec string, ptype string, rule []string) error
RemovePolicy implements persist.Adapter.
func (*CasbinAdapter[T]) SavePolicy ¶
func (a *CasbinAdapter[T]) SavePolicy(model model.Model) error
SavePolicy implements persist.Adapter.
type CollectionCallback ¶
CollectionCallback ...
type Connection ¶
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 DashboardHandler ¶ added in v0.9.7
type DashboardHandler struct { dashboardv1.UnimplementedAuthenticationServiceServer dashboardv1.UnimplementedResourceServiceServer dashboardv1.UnimplementedSchemaServiceServer // contains filtered or unexported fields }
DashboardHandler ...
func NewDashboard ¶ added in v0.9.7
func NewDashboard(ctx context.Context, config *configv1.Dashboard, params DashboardParams) (*DashboardHandler, error)
NewDashboard ...
func (*DashboardHandler) CreateAccount ¶ added in v0.9.7
func (h *DashboardHandler) CreateAccount(ctx context.Context, req *dashboardv1.CreateAccountRequest) (*emptypb.Empty, error)
func (*DashboardHandler) CreateResource ¶ added in v0.9.7
func (h *DashboardHandler) CreateResource(ctx context.Context, req *dashboardv1.CreateResourceRequest) (*dashboardv1.CreateResourceResponse, error)
func (*DashboardHandler) DeleteResource ¶ added in v0.9.7
func (h *DashboardHandler) DeleteResource(ctx context.Context, req *dashboardv1.DeleteResourceRequest) (*emptypb.Empty, error)
func (*DashboardHandler) GetAccount ¶ added in v0.9.7
func (h *DashboardHandler) GetAccount(ctx context.Context, req *emptypb.Empty) (*dashboardv1.GetAccountResponse, error)
func (*DashboardHandler) GetResource ¶ added in v0.9.7
func (h *DashboardHandler) GetResource(ctx context.Context, req *dashboardv1.GetResourceRequest) (*dashboardv1.GetResourceResponse, error)
func (*DashboardHandler) GetResourceRelation ¶ added in v0.9.7
func (h *DashboardHandler) GetResourceRelation(ctx context.Context, req *dashboardv1.GetResourceRelationRequest) (*dashboardv1.GetResourceRelationResponse, error)
func (*DashboardHandler) GetSchema ¶ added in v0.9.7
func (h *DashboardHandler) GetSchema(ctx context.Context, req *emptypb.Empty) (*dashboardv1.GetSchemaResponse, error)
func (*DashboardHandler) Handler ¶ added in v0.9.7
func (h *DashboardHandler) Handler(ctx context.Context) http.Handler
func (*DashboardHandler) ListResources ¶ added in v0.9.7
func (h *DashboardHandler) ListResources(ctx context.Context, req *dashboardv1.ListResourcesRequest) (*dashboardv1.ListResourcesResponse, error)
func (*DashboardHandler) Login ¶ added in v0.9.7
func (h *DashboardHandler) Login(ctx context.Context, req *dashboardv1.LoginRequest) (*dashboardv1.LoginResponse, error)
func (*DashboardHandler) UpdateResource ¶ added in v0.9.7
func (h *DashboardHandler) UpdateResource(ctx context.Context, req *dashboardv1.UpdateResourceRequest) (*dashboardv1.UpdateResourceResponse, error)
type DashboardParams ¶ added in v0.9.7
type DashboardParams struct { fx.In Access Access Graph Graph Storage FileStorage Observer Observer[Topic] }
DashboardParams ...
type Event ¶
type Event[T comparable] struct { // Topic ... Topic T // Payload ... Payload protoreflect.ProtoMessage // Timestamp ... Timestamp time.Time }
Event ...
type FileStorage ¶
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 ¶
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 ¶
type GraphqlHandler struct {
// contains filtered or unexported fields
}
GraphqlHandler ...
func NewGraphqlHandler ¶
func NewGraphqlHandler(access Access, graph Graph) (*GraphqlHandler, error)
NewGraphqlHandler ...
type OTPMailTemplate ¶
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 ...
type Set ¶ added in v0.9.13
type Set[T comparable] struct { // contains filtered or unexported fields }
Set is a collection of unique items
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
examples
|
|
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. |