macaroons

package
v2.3.5-0...-2fac4e2 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const TenantAll = "all"

Variables

View Source
var (
	TenantReadPermissions = []bakery.Op{
		{
			Entity: "info",
			Action: "read",
		},
		{
			Entity: "swap",
			Action: "read",
		},
		{
			Entity: "wallet",
			Action: "read",
		},
		{
			Entity: "autoswap",
			Action: "read",
		},
	}
	TenantWritePermissons = []bakery.Op{
		{
			Entity: "info",
			Action: "write",
		},
		{
			Entity: "swap",
			Action: "write",
		},
		{
			Entity: "wallet",
			Action: "write",
		},
		{
			Entity: "autoswap",
			Action: "write",
		},
	}
	ReadPermissions = append([]bakery.Op{
		{
			Entity: "admin",
			Action: "read",
		},
	}, TenantReadPermissions...)

	WritePermissions = append([]bakery.Op{
		{
			Entity: "admin",
			Action: "write",
		},
	}, TenantWritePermissons...)

	RPCServerPermissions = map[string][]bakery.Op{
		"/boltzrpc.Boltz/GetInfo": {{
			Entity: "info",
			Action: "read",
		}},
		"/boltzrpc.Boltz/GetServiceInfo": {{
			Entity: "info",
			Action: "read",
		}},
		"/boltzrpc.Boltz/GetPairInfo": {{
			Entity: "info",
			Action: "read",
		}},
		"/boltzrpc.Boltz/GetPairs": {{
			Entity: "info",
			Action: "read",
		}},
		"/boltzrpc.Boltz/ListSwaps": {{
			Entity: "swap",
			Action: "read",
		}},
		"/boltzrpc.Boltz/GetStats": {{
			Entity: "swap",
			Action: "read",
		}},
		"/boltzrpc.Boltz/GetSwapInfo": {{
			Entity: "swap",
			Action: "read",
		}},
		"/boltzrpc.Boltz/GetSwapInfoStream": {{
			Entity: "swap",
			Action: "read",
		}},
		"/boltzrpc.Boltz/Deposit": {{
			Entity: "swap",
			Action: "write",
		}},
		"/boltzrpc.Boltz/CreateSwap": {{
			Entity: "swap",
			Action: "write",
		}},
		"/boltzrpc.Boltz/CreateChainSwap": {{
			Entity: "swap",
			Action: "write",
		}},
		"/boltzrpc.Boltz/RefundSwap": {{
			Entity: "swap",
			Action: "write",
		}},
		"/boltzrpc.Boltz/ClaimSwaps": {{
			Entity: "swap",
			Action: "write",
		}},
		"/boltzrpc.Boltz/CreateChannel": {{
			Entity: "swap",
			Action: "write",
		}},
		"/boltzrpc.Boltz/CreateReverseSwap": {{
			Entity: "swap",
			Action: "write",
		}},
		"/boltzrpc.Boltz/CreateWallet": {{
			Entity: "wallet",
			Action: "write",
		}},
		"/boltzrpc.Boltz/ImportWallet": {{
			Entity: "wallet",
			Action: "write",
		}},
		"/boltzrpc.Boltz/SetSubaccount": {{
			Entity: "wallet",
			Action: "write",
		}},
		"/boltzrpc.Boltz/GetSubaccounts": {{
			Entity: "wallet",
			Action: "read",
		}},
		"/boltzrpc.Boltz/GetWalletSendFee": {{
			Entity: "wallet",
			Action: "read",
		}},
		"/boltzrpc.Boltz/RemoveWallet": {{
			Entity: "wallet",
			Action: "write",
		}},
		"/boltzrpc.Boltz/WalletSend": {{
			Entity: "wallet",
			Action: "write",
		}},
		"/boltzrpc.Boltz/WalletReceive": {{
			Entity: "wallet",
			Action: "read",
		}},
		"/boltzrpc.Boltz/GetWalletCredentials": {{
			Entity: "wallet",
			Action: "write",
		}},
		"/boltzrpc.Boltz/GetWallets": {{
			Entity: "wallet",
			Action: "read",
		}},
		"/boltzrpc.Boltz/ListWalletTransactions": {{
			Entity: "wallet",
			Action: "read",
		}},
		"/boltzrpc.Boltz/GetWallet": {{
			Entity: "wallet",
			Action: "read",
		}},
		"/boltzrpc.Boltz/Stop": {{
			Entity: "admin",
			Action: "write",
		}},
		"/boltzrpc.Boltz/Unlock": {{
			Entity: "admin",
			Action: "write",
		}},
		"/boltzrpc.Boltz/ChangeWalletPassword": {{
			Entity: "admin",
			Action: "write",
		}},
		"/boltzrpc.Boltz/VerifyWalletPassword": {{
			Entity: "admin",
			Action: "read",
		}},
		"/boltzrpc.Boltz/CreateTenant": {{
			Entity: "admin",
			Action: "write",
		}},
		"/boltzrpc.Boltz/ListTenants": {{
			Entity: "admin",
			Action: "read",
		}},
		"/boltzrpc.Boltz/GetTenant": {{
			Entity: "admin",
			Action: "read",
		}},
		"/boltzrpc.Boltz/BakeMacaroon": {{
			Entity: "admin",
			Action: "write",
		}},
		"/autoswaprpc.AutoSwap/GetRecommendations": {{
			Entity: "autoswap",
			Action: "read",
		}},
		"/autoswaprpc.AutoSwap/ExecuteRecommendations": {{
			Entity: "autoswap",
			Action: "write",
		}},
		"/autoswaprpc.AutoSwap/GetStatus": {{
			Entity: "autoswap",
			Action: "read",
		}},
		"/autoswaprpc.AutoSwap/GetConfig": {{
			Entity: "autoswap",
			Action: "read",
		}},
		"/autoswaprpc.AutoSwap/ReloadConfig": {{
			Entity: "autoswap",
			Action: "write",
		}},
		"/autoswaprpc.AutoSwap/UpdateChainConfig": {{
			Entity: "autoswap",
			Action: "write",
		}},
		"/autoswaprpc.AutoSwap/UpdateLightningConfig": {{
			Entity: "autoswap",
			Action: "write",
		}},
	}
)

Functions

func AddTenantToContext

func AddTenantToContext(ctx context.Context, tenant *database.Tenant) context.Context

func AdminPermissions

func AdminPermissions() []bakery.Op

func GetPermissions

func GetPermissions(isTenant bool, permissions []*boltzrpc.MacaroonPermissions) (result []bakery.Op)

func TenantFromContext

func TenantFromContext(ctx context.Context) *database.Tenant

func TenantIdFromContext

func TenantIdFromContext(ctx context.Context) *database.Id

Types

type RootKeyStorage

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

func (*RootKeyStorage) Get

func (storage *RootKeyStorage) Get(_ context.Context, id []byte) ([]byte, error)

func (*RootKeyStorage) RootKey

func (storage *RootKeyStorage) RootKey(ctx context.Context) ([]byte, []byte, error)

type Service

type Service struct {
	Database *database.Database
	// contains filtered or unexported fields
}

func (*Service) Init

func (service *Service) Init()

func (*Service) NewMacaroon

func (service *Service) NewMacaroon(tenant *database.Id, ops ...bakery.Op) (*bakery.Macaroon, error)

func (*Service) StreamServerInterceptor

func (service *Service) StreamServerInterceptor() grpc.StreamServerInterceptor

func (*Service) UnaryServerInterceptor

func (service *Service) UnaryServerInterceptor() grpc.UnaryServerInterceptor

func (*Service) ValidateMacaroon

func (service *Service) ValidateMacaroon(macBytes []byte, requiredPermissions []bakery.Op) (*bakery.AuthInfo, error)

Jump to

Keyboard shortcuts

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