Documentation ¶
Index ¶
- type Client
- func (c *Client) Allows(ctx context.Context, actorID uuid.UUID, ref aggregate.Ref, action string) (bool, error)
- func (c *Client) GrantToActor(ctx context.Context, actorID uuid.UUID, ref aggregate.Ref, actions ...string) error
- func (c *Client) GrantToRole(ctx context.Context, roleID uuid.UUID, ref aggregate.Ref, actions ...string) error
- func (c *Client) LookupActor(ctx context.Context, sid string) (uuid.UUID, error)
- func (c *Client) LookupRole(ctx context.Context, name string) (uuid.UUID, error)
- func (c *Client) Permissions(ctx context.Context, actorID uuid.UUID) (auth.PermissionsDTO, error)
- func (c *Client) RevokeFromActor(ctx context.Context, actorID uuid.UUID, ref aggregate.Ref, actions ...string) error
- func (c *Client) RevokeFromRole(ctx context.Context, roleID uuid.UUID, ref aggregate.Ref, actions ...string) error
- type Server
- func (s *Server) Allows(ctx context.Context, req *authpb.AllowsReq) (*authpb.AllowsResp, error)
- func (s *Server) GetPermissions(ctx context.Context, req *commonpb.UUID) (*authpb.Permissions, error)
- func (s *Server) GrantToActor(ctx context.Context, req *authpb.GrantRevokeReq) (*emptypb.Empty, error)
- func (s *Server) GrantToRole(ctx context.Context, req *authpb.GrantRevokeReq) (*emptypb.Empty, error)
- func (s *Server) LookupActor(ctx context.Context, req *authpb.LookupActorReq) (*commonpb.UUID, error)
- func (s *Server) LookupRole(ctx context.Context, req *authpb.LookupRoleReq) (*commonpb.UUID, error)
- func (s *Server) RevokeFromActor(ctx context.Context, req *authpb.GrantRevokeReq) (*emptypb.Empty, error)
- func (s *Server) RevokeFromRole(ctx context.Context, req *authpb.GrantRevokeReq) (*emptypb.Empty, error)
- type ServerOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client implements auth.QueryClient.
func NewClient ¶
func NewClient(conn grpc.ClientConnInterface) *Client
NewClient returns the gRPC client for the authorization module.
func (*Client) Allows ¶
func (c *Client) Allows(ctx context.Context, actorID uuid.UUID, ref aggregate.Ref, action string) (bool, error)
Allows implements auth.QueryClient.
func (*Client) GrantToActor ¶
func (c *Client) GrantToActor(ctx context.Context, actorID uuid.UUID, ref aggregate.Ref, actions ...string) error
GrantToActor implements auth.CommandClient.
func (*Client) GrantToRole ¶
func (c *Client) GrantToRole(ctx context.Context, roleID uuid.UUID, ref aggregate.Ref, actions ...string) error
GrantToRole implements auth.CommandClient.
func (*Client) LookupActor ¶
LookupActor implements auth.QueryClient.
func (*Client) LookupRole ¶
LookupRole implements auth.QueryClient.
func (*Client) Permissions ¶
Permissions implements auth.QueryClient.
type Server ¶
type Server struct { authpb.UnimplementedAuthServiceServer // contains filtered or unexported fields }
Server implements a gRPC server for the authorization module.
func NewServer ¶
func NewServer(perms auth.PermissionRepository, lookup auth.Lookup, opts ...ServerOption) *Server
NewServer returns a new gRPC server for the authorization module.
func (*Server) GetPermissions ¶
func (s *Server) GetPermissions(ctx context.Context, req *commonpb.UUID) (*authpb.Permissions, error)
GetPermissions implements authpb.AuthServiceServer.
func (*Server) GrantToActor ¶
func (s *Server) GrantToActor(ctx context.Context, req *authpb.GrantRevokeReq) (*emptypb.Empty, error)
GrantToActor implements authpb.AuthServiceServer.
func (*Server) GrantToRole ¶
func (s *Server) GrantToRole(ctx context.Context, req *authpb.GrantRevokeReq) (*emptypb.Empty, error)
GrantToRole implements authpb.AuthServiceServer.
func (*Server) LookupActor ¶
func (s *Server) LookupActor(ctx context.Context, req *authpb.LookupActorReq) (*commonpb.UUID, error)
LookupActor implements authpb.AuthServiceServer.
func (*Server) LookupRole ¶
LookupRole implements authpb.AuthServiceServer.
func (*Server) RevokeFromActor ¶
func (s *Server) RevokeFromActor(ctx context.Context, req *authpb.GrantRevokeReq) (*emptypb.Empty, error)
RevokeFromActor implements authpb.AuthServiceServer.
func (*Server) RevokeFromRole ¶
func (s *Server) RevokeFromRole(ctx context.Context, req *authpb.GrantRevokeReq) (*emptypb.Empty, error)
RevokeFromRole implements authpb.AuthServiceServer.
type ServerOption ¶
type ServerOption func(*Server)
ServerOption is an option for the *Server.
func HandleCommands ¶
func HandleCommands(actors auth.ActorRepositories, roles auth.RoleRepository) ServerOption
HandleCommands returns a ServerOption that enables command handling. Specifically, the following methods are enabled:
- GrantToActor()
- GrantToRole()
- RevokeFromRole()
- RevokeFromActor()
When trying to call these methods on a server that doesn't handle commands, the server will return an error. HandleCommands panics if the provided actor or role repository is nil.