auth

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authenticator

type Authenticator interface {
	Verify(ctx context.Context, m proto.Message, auth *commonpb.Auth) error
}

Authenticator authenticates a message with the provided auth.

It is not usually sufficient to rely purely on authentication for permissions, as a lookup must be completed. However, if a message is not authentic, we can short circuit authorization.

In general, users should use an Authorizer, and Authorizer's should use an Authenticator.

func NewKeyPairAuthenticator

func NewKeyPairAuthenticator() Authenticator

NewKeyPairAuthenticator authenticates pub key based auth.

type Authorizer

type Authorizer interface {
	Authorize(ctx context.Context, m proto.Message, authField **commonpb.Auth) (*commonpb.UserId, error)
}

Authorizer authorizes an action for a UserId with the given auth.

If the auth is authorized, it is also authenticated. Authorization is more expensive than authentication as lookups must be performed.

type Messaging

type Messaging interface {
	CanStreamMessages(ctx context.Context, chatID *commonpb.ChatId, userID *commonpb.UserId) (bool, string, error)

	CanGetMessage(ctx context.Context, chatID *commonpb.ChatId, userID *commonpb.UserId) (bool, string, error)

	CanGetMessages(ctx context.Context, chatID *commonpb.ChatId, userID *commonpb.UserId) (bool, string, error)

	CanSendMessage(ctx context.Context, chatID *commonpb.ChatId, userID *commonpb.UserId, content *messagingpb.Content, paymentIntent *commonpb.IntentId) (bool, string, error)

	CanAdvancePointer(ctx context.Context, chatID *commonpb.ChatId, userID *commonpb.UserId) (bool, string, error)

	CanNotifyIsTyping(ctx context.Context, chatID *commonpb.ChatId, userID *commonpb.UserId) (bool, string, error)
}

type StaticAuthorizer

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

func NewStaticAuthorizer

func NewStaticAuthorizer() *StaticAuthorizer

func (*StaticAuthorizer) Add

func (a *StaticAuthorizer) Add(userID *commonpb.UserId, pair model.KeyPair)

func (*StaticAuthorizer) Authorize

func (a *StaticAuthorizer) Authorize(ctx context.Context, m proto.Message, authField **commonpb.Auth) (*commonpb.UserId, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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