Documentation
¶
Index ¶
- Constants
- Variables
- func IsSuperMacaroon(macHex string) bool
- func NewSuperMacaroonRootKeyID(id [4]byte) uint64
- func ParseMacaroon(macHex string) (*macaroon.Macaroon, error)
- func RootKeyIDFromMacaroon(mac *macaroon.Macaroon) (uint64, error)
- func SerializeSession(w io.Writer, session *Session) error
- func UseLogger(logger btclog.Logger)
- type DB
- type FeaturesConfig
- type GRPCServerCreator
- type ID
- type MacaroonBaker
- type MacaroonRecipe
- type Server
- type Session
- type State
- type Store
- type SuperMacaroonValidator
- type Type
Constants ¶
const ( // DBFilename is the default filename of the session database. DBFilename = "session.db" // DefaultSessionDBTimeout is the default maximum time we wait for the // session bbolt database to be opened. If the database is already // opened by another process, the unique lock cannot be obtained. With // the timeout we error out after the given time instead of just // blocking for forever. DefaultSessionDBTimeout = 5 * time.Second )
const Subsystem = "SESS"
Variables ¶
var ( // ErrDBReversion is returned when detecting an attempt to revert to a // prior database version. ErrDBReversion = errors.New("cannot revert to prior version") )
var ( // ErrSessionNotFound is an error returned when we attempt to retrieve // information about a session but it is not found. ErrSessionNotFound = errors.New("session not found") )
var ( // SuperMacaroonRootKeyPrefix is the prefix we set on a super macaroon's // root key to clearly mark it as such. SuperMacaroonRootKeyPrefix = [4]byte{0xFF, 0xEE, 0xDD, 0xCC} )
Functions ¶
func IsSuperMacaroon ¶
IsSuperMacaroon returns true if the given hex encoded macaroon is a super macaroon baked by LiT which can be identified by its root key ID.
func NewSuperMacaroonRootKeyID ¶
NewSuperMacaroonRootKeyID returns a new macaroon root key ID that has the prefix to mark it as a super macaroon root key.
func ParseMacaroon ¶
ParseMacaroon parses a hex encoded macaroon into its native struct.
func RootKeyIDFromMacaroon ¶
RootKeyIDFromMacaroon extracts the root key ID of the passed macaroon.
func SerializeSession ¶
SerializeSession binary serializes the given session to the writer using the tlv format.
Types ¶
type DB ¶
DB is a bolt-backed persistent store.
func (*DB) GetSession ¶
GetSession fetches the session with the given key.
func (*DB) ListSessions ¶
ListSessions returns all sessions currently known to the store.
func (*DB) RevokeSession ¶
RevokeSession updates the state of the session with the given local public key to be revoked.
func (*DB) StoreSession ¶
StoreSession stores a session in the store. If a session with the same local public key already exists, the existing record is updated/ overwritten instead.
type FeaturesConfig ¶
FeaturesConfig is a map from feature name to a raw byte array which stores any config feature config options.
type GRPCServerCreator ¶
type GRPCServerCreator func(opts ...grpc.ServerOption) *grpc.Server
type ID ¶
type ID [4]byte
ID represents the id of a session.
func IDFromBytes ¶
IDFromBytes is a helper function that creates a session ID from a byte slice.
func IDFromMacRootKeyID ¶
IDFromMacRootKeyID converts a macaroon root key ID to a session ID.
func IDFromMacaroon ¶
IDFromMacaroon is a helper function that creates a session ID from a macaroon ID.
type MacaroonBaker ¶
type MacaroonBaker func(ctx context.Context, rootKeyID uint64, recipe *MacaroonRecipe) (string, error)
MacaroonBaker is a function type for baking a super macaroon.
type MacaroonRecipe ¶
MacaroonRecipe defines the permissions and caveats that should be used to bake a macaroon.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(serverCreator GRPCServerCreator) *Server
func (*Server) StartSession ¶
func (*Server) StopSession ¶
type Session ¶
type Session struct { ID ID Label string State State Type Type Expiry time.Time CreatedAt time.Time RevokedAt time.Time ServerAddr string DevServer bool MacaroonRootKey uint64 MacaroonRecipe *MacaroonRecipe PairingSecret [mailbox.NumPassphraseEntropyBytes]byte LocalPrivateKey *btcec.PrivateKey LocalPublicKey *btcec.PublicKey RemotePublicKey *btcec.PublicKey FeatureConfig *FeaturesConfig WithPrivacyMapper bool }
Session is a struct representing a long-term Terminal Connect session.
func DeserializeSession ¶
DeserializeSession deserializes a session from the given reader, expecting the data to be encoded in the tlv format.
type Store ¶
type Store interface { // StoreSession stores a session in the store. If a session with the // same local public key already exists, the existing record is updated/ // overwritten instead. StoreSession(*Session) error // ListSessions returns all sessions currently known to the store. ListSessions() ([]*Session, error) // RevokeSession updates the state of the session with the given local // public key to be revoked. RevokeSession(*btcec.PublicKey) error }
Store is the interface a persistent storage must implement for storing and retrieving Terminal Connect sessions.