Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/matejlach/httpsigver-ap
Go library to sign & verify HTTP signatures, compatible with Mastodon/ActivityPub servers.
https://github.com/matejlach/httpsigver-ap
activitypub golang http-signatures mastodon
Last synced: 2 months ago
JSON representation
Go library to sign & verify HTTP signatures, compatible with Mastodon/ActivityPub servers.
- Host: GitHub
- URL: https://github.com/matejlach/httpsigver-ap
- Owner: MatejLach
- License: agpl-3.0
- Created: 2024-09-13T12:20:32.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-09-15T14:24:02.000Z (3 months ago)
- Last Synced: 2024-10-10T14:05:01.331Z (2 months ago)
- Topics: activitypub, golang, http-signatures, mastodon
- Language: Go
- Homepage: https://pkg.go.dev/github.com/MatejLach/httpsigver-ap
- Size: 23.4 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# httpsigver-ap
`httpsigver-ap` is a Go library allowing everyone to easily add Mastodon/ActivityPub-compatible HTTP signature to any HTTP request as well
as verify the validity of a request's signature originating from an ActivityPub server.## Usage
[![Go Reference](https://pkg.go.dev/badge/github.com/MatejLach/httpsigver-ap.svg)](https://pkg.go.dev/github.com/MatejLach//httpsigver-ap#section-documentation)
### Signing requests
```go
package mainimport (
//...
"github.com/MatejLach/httpsigver-ap"
)func main() {
// ...
req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("%s/user/me", server.URL), nil)
if err != nil {
// error handling
}reqActorPubKeyId, err := url.Parse(fmt.Sprintf("%s/user/me", server.URL))
if err != nil {
// error handling
}err = httpsigver.SignRequest(context.Background(), req, reqActorPubKeyId, privateKeyPem.String())
if err != nil {
// error handling
}
}
```### Verifying requests
```go
package mainimport (
//...
"github.com/MatejLach/httpsigver-ap"
)func main() {
// ...
validSignature, err := httpsigver.ReqHasValidSignature(context.Background(), req, "", true)
if err != nil {
// error handling
}
}
```See the test suite for a more complete example.
## Contributing
Pull requests and bug reports are welcome.