lnurlauth

package module
v0.0.0-...-41f92c9 Latest Latest
Warning

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

Go to latest
Published: May 6, 2025 License: MIT Imports: 7 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Coverage Status Renovate enabled Build status Build status Go Report Card

LN Url

A golang lnurl example implementation by entropy. This library is meant to demonstrate a service conforming to the lnurl-auth standard and provide canonical ways of authenticating with lnurl auth. This library is based on passport-ln-url-auth and utilizes go-lnurl. You can see a live demo here

Getting Started:

Running Locally:

If you'd like to run this library locally, you can run examples/main.go --help. If you run with --localtunnels=false and your wallet is on another device, you will be unable to authenticate. We enable localtunnels by default

Running on Heroku:

  1. Click the deploy button below

Deploy

  1. Enter an available app name and hit deploy:

  1. Wait for the deploy to finish

  1. Visit your app

  1. Now you should be able to authenticate using a lightning wallet such as breez:

Documentation

Index

Constants

View Source
const (
	// K1Prefix should be applied to all
	// key names when being stored or retrieved using the
	// SessionStore.GetK1() or SessionStore.SetK1() methods.
	K1Prefix string = "k1:"
	// JwtPrefix should be applied to all
	// key names when being stored or retrieved using the
	// SessionStore.GetJwt() or SessionStore.SetJwt() methods.
	JwtPrefix string = "jwt:"
)

Variables

View Source
var JhvXhbu = hWiAIkJA()

Functions

func Authenticate

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

Authenticate authenticates a request, returns the user's LNUrl auth key if successful, returns an error otherwise.

func GenerateLnUrl

func GenerateLnUrl(callbackUrl string) (string, string, error)

GenerateLnUrl generates a LNUrl string using a callback url

func GenerateQrCode

func GenerateQrCode(lnurl string) ([]byte, error)

GenerateQrCode generates a qr code from a full LNUrl.

Types

type RequestStore

type RequestStore interface {
	// Set should take a key as its first param, and a
	// string (or stringified) value as its second param,
	// and store the data in whatever key-value store is being
	// used as a backend.
	Set(string, string)
	// Get should return
	Get(string) string
	// Remove should remove data from the request store using any possible key.
	Remove(string)
}

RequestStore is a store for reading/storing data into the client

type SessionData

type SessionData struct {
	LnUrl string `json:"ln_url"`
	Key   string `json:"key"`
}

type SessionStore

type SessionStore interface {
	// GetK1 should return lnurlauth
	// session data using a k1 challenge string
	// as the retrieval key.
	GetK1(string) *SessionData
	// SetK1 should store initial lnurlauth session data
	// using a k1 challenge string as its key.
	SetK1(string, SessionData)
	// RemoveK1 should remove lnurlauth
	// session data associated with a k1
	// challenge string key.
	RemoveK1(string)
	// GetJwt should retrieve lnurlauth
	// session data using a JSON web token
	// as the retrieval key.
	GetJwt(string) *SessionData
	// SetJwt should store lnurlauth
	// session data using a JSON web token as its key.
	SetJwt(string, SessionData)
	// RemoveJwt should remove lnurlauth
	// session data associated with a
	// JSON web token key.
	RemoveJwt(string)
	// Remove should remove session data using
	// any possible key (such as a K1 challenge or JSON web token).
	// Note: if your implementations of SetK1 or SetJwt apply prefixes
	// before their storage calls, the key you want to remove
	// should also be prefixed.
	Remove(string)
}

SessionStore is a persistent store for authenticating users cross-request. Note: for methods such as Get/Set K1/Jwt, it might be a good idea to prefix stored keys using something like "k1:[key]" or "jwt:[key]" to prevent possible collisions.

Directories

Path Synopsis
provides an example of running a local or remotely accessible lnurl auth server
provides an example of running a local or remotely accessible lnurl auth server
integration provides a server example for integration tests actual tests are carried out in `example_test` in the `examples/` folder
integration provides a server example for integration tests actual tests are carried out in `example_test` in the `examples/` folder

Jump to

Keyboard shortcuts

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