model

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2020 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const CADirURL = "https://acme-v02.api.letsencrypt.org/directory"
View Source
const DefaultRenewAt = 30

DefaultRenewAt is the number of days before expiration a cert should be renewed at.

Variables

View Source
var ErrInvalidDomains = errors.New("invalid domains")
View Source
var ErrInvalidEmail = errors.New("email required")

Functions

func ValidDomains

func ValidDomains(domains []string) bool

ValidDomains is used to validate that the passed domains set includes only valid domains (ie example.com or *.example.com). Returns bool designating whether or not they are ALL valid domains.

Types

type Certificate

type Certificate struct {
	ID     string
	Secret string

	// Domains is a list of domains valid for this domain.
	Domains []string
	// Main domain for "Common Name" field of cert.
	CommonName string

	// Let's Encrypt CertURL
	CertURL string
	// Let's Encrypt StableCertURL
	CertStableURL string

	PrivateKey        []byte
	Certificate       []byte
	IssuerCertificate []byte

	// Has this cert been issued yet?
	Issued bool

	// NotAfter
	Expiry time.Time

	// RewnewAt specifies the number of days before expiration a cert should be
	// renewed by.
	RenewAt int

	LastError error

	ModTime time.Time

	ACMEEmail        string
	ACMERegistration *registration.Resource
	ACMEKey          *ecdsa.PrivateKey
}

func NewCertificate

func NewCertificate(domains []string, email string) (*Certificate, error)

NewCertificate sets up everything needed for Lego to move forward with cert issuance and renewal, as well as generating a unique ID, and a cryptographically secure secret.

func (*Certificate) GetEmail

func (c *Certificate) GetEmail() string

GetEmail is needed to implement the User interface for Lego Clients.

func (*Certificate) GetPrivateKey

func (c *Certificate) GetPrivateKey() crypto.PrivateKey

GetPrivateKey is needed to implement the User interface for Lego Clients.

func (*Certificate) GetRegistration

func (c *Certificate) GetRegistration() *registration.Resource

GetRegistration is needed to implement the User interface for Lego Clients.

type ChallengeConfig

type ChallengeConfig struct {
	// AuthEmail is the Cloudflare account email
	AuthEmail string

	// AuthKey is the API key to use to then retrieve a Cloudflare API token.
	AuthKey string
}

ChallengeConfig provides all necessary information for a Cloudflare DNS Challenge provider.

type Config

type Config struct {
	// If JWTSecret is ever invalid, we generate a new one randomly.
	JWTSecret *auth.JWTSecret
	// SuperAdmin is the username of the SA account. If this is "" we allow
	// generation of a new one from the superadmin endpoint. (first time running)
	SuperAdmin string

	SessionKey []byte
}

Config holds all the necessary application level configuration items.

type User

type User struct {
	Name string
	Role string // RBAC role

	Hash string // Will always be an encoding of a password hash
}

User is a system user for the webapp.

func NewUser

func NewUser(name, password, role string) (*User, error)

NewUser creates a user object with a hashed version of the passed in password.

func (User) ComparePasswordAndHash

func (u User) ComparePasswordAndHash(password string) (bool, error)

ComparePasswordAndHash takes a password as input, and compares the password hashes to determine if they should be authenticated.

func (*User) SetPassword

func (u *User) SetPassword(password string) error

SetPassword takes a plaintext password and stores the hash of it in the object.

Jump to

Keyboard shortcuts

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