auth

package
v0.0.0-...-297abb6 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2022 License: BSD-2-Clause Imports: 2 Imported by: 0

README

auth

Contains a basic Auth provider that can be used for simple user management and topic restrictions.

func main() {
	a := auth.NewBasicAuth()
	a.ToggleGuestAccess(true)
	a.RegisterUser("roan", "roan", "brand")
	a.AllowSubscription("testtopic/#", "roan")
	a.AllowPublish("testtopic", "roan")

	s := gobroke.Server{Auther: a}
	err := s.Run()
	if err != nil {
		panic(err)
	}
}

Extending

  • The Auther interface can be used to easily implement wrappers for external auth systems. See interface.go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBasicAuth

func NewBasicAuth() *basicAuth

Types

type Auther

type Auther interface {
	// Authenticate a user (client) trying to connect to the server.
	// username and password is optional and can be nil.
	AuthUser(clientId string, username, password []byte) error

	// Authorizes a client for publishing to a Topic Name.
	AuthPublish(clientId string, topicName []byte) error

	// Authorizes a client for subscribing to a Topic Filter.
	AuthSubscription(clientId string, topicFilter []byte) error
}

Provider of Authentication and Authorization for the Server. Callers must return non-nil errors if Auth fails.

Jump to

Keyboard shortcuts

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