authrpc

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

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

func (c *Client) LookupActor(ctx context.Context, sid string) (uuid.UUID, error)

LookupActor implements auth.QueryClient.

func (*Client) LookupRole

func (c *Client) LookupRole(ctx context.Context, name string) (uuid.UUID, error)

LookupRole implements auth.QueryClient.

func (*Client) Permissions

func (c *Client) Permissions(ctx context.Context, actorID uuid.UUID) (auth.PermissionsDTO, error)

Permissions implements auth.QueryClient.

func (*Client) RevokeFromActor

func (c *Client) RevokeFromActor(ctx context.Context, actorID uuid.UUID, ref aggregate.Ref, actions ...string) error

RevokeFromActor implements auth.CommandClient.

func (*Client) RevokeFromRole

func (c *Client) RevokeFromRole(ctx context.Context, roleID uuid.UUID, ref aggregate.Ref, actions ...string) error

RevokeFromRole implements auth.CommandClient.

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) Allows

func (s *Server) Allows(ctx context.Context, req *authpb.AllowsReq) (*authpb.AllowsResp, error)

Allows implements authpb.AuthServiceServer.

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

func (s *Server) LookupRole(ctx context.Context, req *authpb.LookupRoleReq) (*commonpb.UUID, error)

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.

Jump to

Keyboard shortcuts

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