auth

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package auth provides connection authentication for the CSMS.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnauthorized = errors.New("auth: unauthorized")

ErrUnauthorized indicates authentication failure.

Functions

This section is empty.

Types

type AuthMethod

type AuthMethod string

AuthMethod identifies how a connection authenticated.

const (
	AuthMethodNone  AuthMethod = "none"
	AuthMethodBasic AuthMethod = "basic"
	AuthMethodMTLS  AuthMethod = "mtls"
	AuthMethodToken AuthMethod = "token"
)

type Authenticator

type Authenticator interface {
	Authenticate(r *http.Request, cpID string) (Identity, error)
}

Authenticator authenticates a charge point at WebSocket upgrade time. cpID is the charge point identifier parsed from the HTTP request path by the CSMS server.

func BasicAuth

func BasicAuth(verify VerifyBasic) Authenticator

BasicAuth authenticates using HTTP Basic credentials (OCPP Security Profile 1/2). The verifier receives the charge point id parsed from the request path. If the returned identity leaves Credential empty, it is set to the HTTP Basic username.

func MTLSFromClientCert

func MTLSFromClientCert(verify VerifyMTLS) Authenticator

MTLSFromClientCert authenticates using the presented TLS client certificate (OCPP Security Profile 3). The HTTP server must be configured with tls.RequireAndVerifyClientCert.

type Identity

type Identity struct {
	CPID       string
	Method     AuthMethod
	Credential string
	Metadata   map[string]string
}

Identity is the authenticated identity of a charge point connection.

type None

type None struct{}

None accepts every connection (development only).

func (None) Authenticate

func (None) Authenticate(r *http.Request, cpID string) (Identity, error)

Authenticate always succeeds.

type VerifyBasic

type VerifyBasic func(cpID, password string) (Identity, error)

VerifyBasic checks the parsed charge point id and password, returning the identity.

type VerifyMTLS

type VerifyMTLS func(cpID string, cert *x509.Certificate) (Identity, error)

VerifyMTLS checks a client certificate and returns the identity.

Jump to

Keyboard shortcuts

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