Documentation
¶
Overview ¶
Package httpauth provides helpers and encoders for nostr NIP-98 HTTP authentication header messages and a new JWT authentication message and delegation event kind 13004 that enables time limited expiring delegations of authentication (as with NIP-42 auth) for the HTTP API.
Index ¶
- Constants
- Variables
- func AddNIP98Header(r *http.Request, ur *url.URL, method, hash string, sign signer.I, expiry int64) (err error)
- func CheckAuth(r *http.Request, tolerance ...time.Duration) (valid bool, pubkey []byte, err error)
- func CreateNIP98Blob(ur, method, hash string, expiry int64, sign signer.I) (blob string, err error)
- func MakeNIP98Event(u, method, hash string, expiry int64) (ev *event.E)
Constants ¶
View Source
const ( HeaderKey = "Authorization" NIP98Prefix = "Nostr" )
Variables ¶
View Source
var ErrMissingKey = fmt.Errorf( "'%s' key missing from request header", HeaderKey, )
Functions ¶
func AddNIP98Header ¶
func AddNIP98Header( r *http.Request, ur *url.URL, method, hash string, sign signer.I, expiry int64, ) (err error)
AddNIP98Header creates a NIP-98 http auth event and adds the standard header to a provided http.Request.
func CheckAuth ¶
func CheckAuth(r *http.Request, tolerance ...time.Duration) ( valid bool, pubkey []byte, err error, )
CheckAuth verifies a received http.Request has got a valid authentication event in it, with an optional specification for tolerance of before and after, and provides the public key that should be verified to be authorized to access the resource associated with the request.
func CreateNIP98Blob ¶ added in v0.4.0
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.