auth

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package auth aims to provide authentication primitives against applications and services of the Axone network.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthenticatedHandler

type AuthenticatedHandler func(*Identity, http.ResponseWriter, *http.Request)

AuthenticatedHandler is a handler that requires an authenticated user.

It is intended to be used in combination with a middleware handler that verifies the user's identity, for example with the jwt middleware:

jwtFactory.VerifyHTTPMiddleware(func(id *auth.Identity, w http.ResponseWriter, r *http.Request) {
  // Your handler logic here
})

type Identity

type Identity struct {
	DID               string
	AuthorizedActions []string
}

Identity denotes an identity that has been authenticated, which may contain some resolved authorizations.

func (Identity) Can

func (i Identity) Can(action string) bool

Can check if the identity is authorized to perform a specific action.

type Proxy

type Proxy interface {
	// Authenticate verifies the authenticity and integrity of the provided credential before resolving on-chain
	// authorized actions with the proxied service by querying the service's governance.
	Authenticate(ctx context.Context, credential []byte) (*Identity, error)
}

Proxy acts as the entrypoint of a service and is responsible for authenticating any identity willing to conduct some actions against the underlying service. It authenticates Decentralized Identities based on a provided Verifiable Credential and resolving allowed authorized actions for this identity based on on-chain rules. It is not responsible or aware of the communication protocol, which means it only returns information on the identity if authentic and won't for example issue a JWT token, this is out of its scope.

func NewProxy

func NewProxy(govAddr, serviceID string,
	dvClient dataverse.QueryClient,
	authParser credential.Parser[*credential.AuthClaim],
) Proxy

NewProxy creates a new Proxy instance using the given service identifier and on-chain governance address (i.e. the law-stone smart contract instance carrying its rules).

Directories

Path Synopsis
Package jwt brings a mean to manage JWT tokens on top of Axone network authentication mechanisms.
Package jwt brings a mean to manage JWT tokens on top of Axone network authentication mechanisms.

Jump to

Keyboard shortcuts

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