unkey

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: MIT Imports: 9 Imported by: 1

README

Unkey

GitHub Workflow Status go.dev reference built with nix

Authenticate API keys using Unkey.

[!WARNING] Project is under development. Backwards compatibility is not guaranteed.

Development

For an optimal developer experience, it is recommended to install Nix and direnv.

Run tests:

go test -race -v ./...

Run linter:

golangci-lint run

To test changes made in registry-auth:

Make sure registry-auth is checked out in the same directory:

cd ..
git clone git@github.com:portward/registry-auth.git
cd unkey

Set up a Go workspace:

go work init
go work use .
go work use ../registry-auth
go work sync

License

The project is licensed under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authenticator

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

Authenticator uses Unkey to authenticate API keys.

func NewAuthenticator

func NewAuthenticator(apiID string, rootKey string, u *url.URL) Authenticator

NewAuthenticator returns a new Authenticator.

func (Authenticator) AuthenticatePassword

func (a Authenticator) AuthenticatePassword(ctx context.Context, username string, password string) (auth.Subject, error)

AuthenticatePassword implements the auth.PasswordAuthenticator interface.

func (Authenticator) GetSubjectByID

func (a Authenticator) GetSubjectByID(ctx context.Context, id auth.SubjectID) (auth.Subject, error)

type Config

type Config struct {
	APIID   string `mapstructure:"apiId"`
	RootKey string `mapstructure:"rootKey"`
	URL     string `mapstructure:"url"`
}

Config implements the PasswordAuthenticatorFactory interface defined by Portward.

func (Config) New

New returns a new Authenticator from the configuration.

func (Config) Validate

func (c Config) Validate() error

Validate validates the configuration.

Jump to

Keyboard shortcuts

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