server

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2020 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Prefix       = "internal.server"
	UnmarshalKey = "server"
)

Variables

View Source
var (
	ErrNotExists = errors.New("object not exists")
	ErrExists    = errors.New("object already exists")
	ErrDenied    = errors.New("access denied")
)
View Source
var (
	WireSet = wire.NewSet(
		Provider,
		Cfg,
	)
	WireTestSet = wire.NewSet(
		Provider,
		CfgTest,
	)
)

Functions

func MakeABAC

func MakeABAC(obj interface{}) (string, error)

Types

type AbacAttrList

type AbacAttrList struct {
	V0  string
	V1  string
	V2  string
	V3  string
	V4  string
	V5  string
	V6  string
	V7  string
	V8  string
	V9  string
	V10 string
	// contains filtered or unexported fields
}

type CasbinMicro

type CasbinMicro struct {
	provider.LMT
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, set provider.AwareSet, srv *micro.Micro, cfg *Config, globalCfg *glbConfig.Config) *CasbinMicro

New

func Provider

func Provider(ctx context.Context, set provider.AwareSet, srv *micro.Micro, cfg *Config, globalCfg *glbConfig.Config) (*CasbinMicro, func(), error)

Provider

func (*CasbinMicro) ListenAndServe

func (c *CasbinMicro) ListenAndServe() (err error)

ListenAndServe

type Config

type Config struct {
	Debug   bool `fallback:"shared.debug"`
	WorkDir string
	// contains filtered or unexported fields
}

Config

func Cfg

func Cfg(cfg config.Configurator) (*Config, func(), error)

Cfg

func CfgTest

func CfgTest() (*Config, func(), error)

CfgTest

func (*Config) OnReload

func (c *Config) OnReload(callback func(ctx context.Context))

OnReload

func (*Config) Reload

func (c *Config) Reload(ctx context.Context)

Reload

type Server

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

func NewServer

func NewServer(m model.Model, a persist.Adapter) (*Server, error)

func (*Server) AddGroupingPolicy

func (s *Server) AddGroupingPolicy(ctx context.Context, req *casbinpb.PolicyRequest, rsp *casbinpb.Empty) error

AddGroupingPolicy adds a role inheritance rule to the current policy. If the rule already exists, the function returns false and the rule will not be added. Otherwise the function returns true by adding the new rule.

func (*Server) AddNamedGroupingPolicy

func (s *Server) AddNamedGroupingPolicy(ctx context.Context, req *casbinpb.PolicyRequest, rsp *casbinpb.Empty) error

AddNamedGroupingPolicy adds a named role inheritance rule to the current policy. If the rule already exists, the function returns false and the rule will not be added. Otherwise the function returns true by adding the new rule.

func (*Server) AddNamedPolicy

func (s *Server) AddNamedPolicy(ctx context.Context, req *casbinpb.PolicyRequest, rsp *casbinpb.Empty) error

func (*Server) AddPermissionForUser

func (s *Server) AddPermissionForUser(ctx context.Context, req *casbinpb.PermissionRequest, rsp *casbinpb.Empty) error

AddPermissionForUser adds a permission for a user or role. Returns false if the user or role already has the permission (aka not affected).

func (*Server) AddPolicy

func (s *Server) AddPolicy(ctx context.Context, req *casbinpb.PolicyRequest, rsp *casbinpb.Empty) error

func (*Server) AddRoleForUser

func (s *Server) AddRoleForUser(ctx context.Context, req *casbinpb.UserRoleRequest, rsp *casbinpb.Empty) error

AddRoleForUser adds a role for a user. Returns false if the user already has the role (aka not affected).

func (*Server) DeletePermission

func (s *Server) DeletePermission(ctx context.Context, req *casbinpb.PermissionRequest, rsp *casbinpb.Empty) error

DeletePermission deletes a permission. Returns false if the permission does not exist (aka not affected).

func (*Server) DeletePermissionForUser

func (s *Server) DeletePermissionForUser(ctx context.Context, req *casbinpb.PermissionRequest, rsp *casbinpb.Empty) error

DeletePermissionForUser deletes a permission for a user or role. Returns false if the user or role does not have the permission (aka not affected).

func (*Server) DeletePermissionsForUser

func (s *Server) DeletePermissionsForUser(ctx context.Context, req *casbinpb.PermissionRequest, rsp *casbinpb.Empty) error

DeletePermissionsForUser deletes permissions for a user or role. Returns false if the user or role does not have any permissions (aka not affected).

func (*Server) DeleteRole

func (s *Server) DeleteRole(ctx context.Context, req *casbinpb.UserRoleRequest, rsp *casbinpb.Empty) error

DeleteRole deletes a role.

func (*Server) DeleteRoleForUser

func (s *Server) DeleteRoleForUser(ctx context.Context, req *casbinpb.UserRoleRequest, rsp *casbinpb.Empty) error

DeleteRoleForUser deletes a role for a user. Returns false if the user does not have the role (aka not affected).

func (*Server) DeleteRolesForUser

func (s *Server) DeleteRolesForUser(ctx context.Context, req *casbinpb.UserRoleRequest, rsp *casbinpb.Empty) error

DeleteRolesForUser deletes all roles for a user. Returns false if the user does not have any roles (aka not affected).

func (*Server) DeleteUser

func (s *Server) DeleteUser(ctx context.Context, req *casbinpb.UserRoleRequest, rsp *casbinpb.Empty) error

DeleteUser deletes a user. Returns false if the user does not exist (aka not affected).

func (*Server) Enforce

func (s *Server) Enforce(ctx context.Context, req *casbinpb.EnforceRequest, rsp *casbinpb.Empty) error

func (*Server) GetAllActions

func (s *Server) GetAllActions(ctx context.Context, req *casbinpb.Empty, rsp *casbinpb.ArrayReply) error

GetAllActions gets the list of actions that show up in the current policy.

func (*Server) GetAllNamedActions

func (s *Server) GetAllNamedActions(ctx context.Context, req *casbinpb.SimpleGetRequest, rsp *casbinpb.ArrayReply) error

GetAllNamedActions gets the list of actions that show up in the current named policy.

func (*Server) GetAllNamedObjects

func (s *Server) GetAllNamedObjects(ctx context.Context, req *casbinpb.SimpleGetRequest, rsp *casbinpb.ArrayReply) error

GetAllNamedObjects gets the list of objects that show up in the current named policy.

func (*Server) GetAllNamedRoles

func (s *Server) GetAllNamedRoles(ctx context.Context, req *casbinpb.SimpleGetRequest, rsp *casbinpb.ArrayReply) error

GetAllNamedRoles gets the list of roles that show up in the current named policy.

func (*Server) GetAllNamedSubjects

func (s *Server) GetAllNamedSubjects(ctx context.Context, req *casbinpb.SimpleGetRequest, rsp *casbinpb.ArrayReply) error

GetAllNamedSubjects gets the list of subjects that show up in the current named policy.

func (*Server) GetAllObjects

func (s *Server) GetAllObjects(ctx context.Context, req *casbinpb.Empty, rsp *casbinpb.ArrayReply) error

GetAllObjects gets the list of objects that show up in the current policy.

func (*Server) GetAllRoles

func (s *Server) GetAllRoles(ctx context.Context, req *casbinpb.Empty, rsp *casbinpb.ArrayReply) error

GetAllRoles gets the list of roles that show up in the current policy.

func (*Server) GetAllSubjects

func (s *Server) GetAllSubjects(ctx context.Context, req *casbinpb.Empty, rsp *casbinpb.ArrayReply) error

GetAllSubjects gets the list of subjects that show up in the current policy.

func (*Server) GetFilteredGroupingPolicy

func (s *Server) GetFilteredGroupingPolicy(ctx context.Context, req *casbinpb.FilteredPolicyRequest, rsp *casbinpb.Array2DReply) error

GetFilteredGroupingPolicy gets all the role inheritance rules in the policy, field filters can be specified.

func (*Server) GetFilteredNamedGroupingPolicy

func (s *Server) GetFilteredNamedGroupingPolicy(ctx context.Context, req *casbinpb.FilteredPolicyRequest, rsp *casbinpb.Array2DReply) error

GetFilteredNamedGroupingPolicy gets all the role inheritance rules in the policy, field filters can be specified.

func (*Server) GetFilteredNamedPolicy

func (s *Server) GetFilteredNamedPolicy(ctx context.Context, req *casbinpb.FilteredPolicyRequest, rsp *casbinpb.Array2DReply) error

GetFilteredNamedPolicy gets all the authorization rules in the named policy, field filters can be specified.

func (*Server) GetFilteredPolicy

func (s *Server) GetFilteredPolicy(ctx context.Context, req *casbinpb.FilteredPolicyRequest, rsp *casbinpb.Array2DReply) error

GetFilteredPolicy gets all the authorization rules in the policy, field filters can be specified.

func (*Server) GetGroupingPolicy

func (s *Server) GetGroupingPolicy(ctx context.Context, req *casbinpb.Empty, rsp *casbinpb.Array2DReply) error

GetGroupingPolicy gets all the role inheritance rules in the policy.

func (*Server) GetImplicitPermissionsForUser

func (s *Server) GetImplicitPermissionsForUser(ctx context.Context, req *casbinpb.PermissionRequest, rsp *casbinpb.Array2DReply) error

GetImplicitPermissionsForUser gets implicit permissions for a user or role

func (*Server) GetImplicitRolesForUser

func (s *Server) GetImplicitRolesForUser(ctx context.Context, req *casbinpb.UserRoleRequest, rsp *casbinpb.ArrayReply) error

GetImplicitRolesForUser gets implicit roles for user

func (*Server) GetNamedGroupingPolicy

func (s *Server) GetNamedGroupingPolicy(ctx context.Context, req *casbinpb.PolicyRequest, rsp *casbinpb.Array2DReply) error

GetNamedGroupingPolicy gets all the role inheritance rules in the policy.

func (*Server) GetNamedPolicy

func (s *Server) GetNamedPolicy(ctx context.Context, req *casbinpb.PolicyRequest, rsp *casbinpb.Array2DReply) error

GetNamedPolicy gets all the authorization rules in the named policy.

func (*Server) GetPermissionsForUser

func (s *Server) GetPermissionsForUser(ctx context.Context, req *casbinpb.PermissionRequest, rsp *casbinpb.Array2DReply) error

GetPermissionsForUser gets permissions for a user or role.

func (*Server) GetPolicy

func (s *Server) GetPolicy(ctx context.Context, req *casbinpb.Empty, rsp *casbinpb.Array2DReply) error

GetPolicy gets all the authorization rules in the policy.

func (*Server) GetRolesForUser

func (s *Server) GetRolesForUser(ctx context.Context, req *casbinpb.UserRoleRequest, rsp *casbinpb.ArrayReply) error

GetRolesForUser gets the roles that a user has.

func (*Server) GetUsersForRole

func (s *Server) GetUsersForRole(ctx context.Context, req *casbinpb.UserRoleRequest, rsp *casbinpb.ArrayReply) error

GetUsersForRole gets the users that has a role.

func (*Server) HasGroupingPolicy

func (s *Server) HasGroupingPolicy(ctx context.Context, req *casbinpb.PolicyRequest, rsp *casbinpb.Empty) error

HasGroupingPolicy determines whether a role inheritance rule exists.

func (*Server) HasNamedGroupingPolicy

func (s *Server) HasNamedGroupingPolicy(ctx context.Context, req *casbinpb.PolicyRequest, rsp *casbinpb.Empty) error

HasNamedGroupingPolicy determines whether a named role inheritance rule exists.

func (*Server) HasNamedPolicy

func (s *Server) HasNamedPolicy(ctx context.Context, req *casbinpb.PolicyRequest, rsp *casbinpb.Empty) error

HasNamedPolicy determines whether a named authorization rule exists.

func (*Server) HasPermissionForUser

func (s *Server) HasPermissionForUser(ctx context.Context, req *casbinpb.PermissionRequest, rsp *casbinpb.Empty) error

HasPermissionForUser determines whether a user has a permission.

func (*Server) HasPolicy

func (s *Server) HasPolicy(ctx context.Context, req *casbinpb.PolicyRequest, rsp *casbinpb.Empty) error

HasPolicy determines whether an authorization rule exists.

func (*Server) HasRoleForUser

func (s *Server) HasRoleForUser(ctx context.Context, req *casbinpb.UserRoleRequest, rsp *casbinpb.Empty) error

HasRoleForUser determines whether a user has a role.

func (*Server) ImportPolicy

func (s *Server) ImportPolicy(ctx context.Context, req *casbinpb.ImportPolicyRequest, rsp *casbinpb.Empty) error

func (*Server) LoadPolicy

func (s *Server) LoadPolicy(ctx context.Context, req *casbinpb.Empty, rsp *casbinpb.Empty) error

func (*Server) LoadPolicyFile

func (s *Server) LoadPolicyFile(path string) error

func (*Server) LoadPolicyReader

func (s *Server) LoadPolicyReader(r io.Reader) error

func (*Server) RemoveFilteredGroupingPolicy

func (s *Server) RemoveFilteredGroupingPolicy(ctx context.Context, req *casbinpb.FilteredPolicyRequest, rsp *casbinpb.Empty) error

RemoveFilteredGroupingPolicy removes a role inheritance rule from the current policy, field filters can be specified.

func (*Server) RemoveFilteredNamedGroupingPolicy

func (s *Server) RemoveFilteredNamedGroupingPolicy(ctx context.Context, req *casbinpb.FilteredPolicyRequest, rsp *casbinpb.Empty) error

RemoveFilteredNamedGroupingPolicy removes a role inheritance rule from the current named policy, field filters can be specified.

func (*Server) RemoveFilteredNamedPolicy

func (s *Server) RemoveFilteredNamedPolicy(ctx context.Context, req *casbinpb.FilteredPolicyRequest, rsp *casbinpb.Empty) error

RemoveFilteredNamedPolicy removes an authorization rule from the current named policy, field filters can be specified.

func (*Server) RemoveFilteredPolicy

func (s *Server) RemoveFilteredPolicy(ctx context.Context, req *casbinpb.FilteredPolicyRequest, rsp *casbinpb.Empty) error

RemoveFilteredPolicy removes an authorization rule from the current policy, field filters can be specified.

func (*Server) RemoveGroupingPolicy

func (s *Server) RemoveGroupingPolicy(ctx context.Context, req *casbinpb.PolicyRequest, rsp *casbinpb.Empty) error

RemoveGroupingPolicy removes a role inheritance rule from the current policy.

func (*Server) RemoveNamedGroupingPolicy

func (s *Server) RemoveNamedGroupingPolicy(ctx context.Context, req *casbinpb.PolicyRequest, rsp *casbinpb.Empty) error

RemoveNamedGroupingPolicy removes a role inheritance rule from the current named policy.

func (*Server) RemoveNamedPolicy

func (s *Server) RemoveNamedPolicy(ctx context.Context, req *casbinpb.PolicyRequest, rsp *casbinpb.Empty) error

func (*Server) RemovePolicy

func (s *Server) RemovePolicy(ctx context.Context, req *casbinpb.PolicyRequest, rsp *casbinpb.Empty) error

func (*Server) SavePolicy

func (s *Server) SavePolicy(ctx context.Context, req *casbinpb.Empty, rsp *casbinpb.Empty) error

Jump to

Keyboard shortcuts

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