http-signatures-crystal
http_signatures
Copy of (https://github.com/99designs/http-signatures-ruby) ported to Crystal. Some specs omitted, but should generally work.
Installation
- Add the dependency to your
shard.yml
:
dependencies:
http_signatures:
github: wealth/http-signatures-crystal
- Run
shards install
Usage
require "http_signatures"
context = HttpSignatures::Context.new(
keys: {"examplekey" => "secret-key-here"},
algorithm: "hmac-sha256",
headers: ["(request-target)", "Date", "Content-Length"],
)
headers = HTTP::Headers.new
headers.add("Date", Time.now.rfc822)
headers.add("Content-Length", "0")
message = HTTP::Request.new(
"GET",
"/path?query=123",
headers
)
context.signer.sign(message)
puts message.headers["Signature"]
puts message.headers["Authorization"]
puts context.verifier.valid?(message)
Development
TODO: Write development instructions here
Contributing
- Fork it (https://github.com/wealth/http-signatures-crystal/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Contributors
- wealth - creator and maintainer
Repository
http-signatures-crystal
Owner
Statistic
- 1
- 0
- 0
- 0
- 0
- over 3 years ago
- October 30, 2019
License
MIT License
Links
Synced at
Sun, 22 Dec 2024 12:09:35 GMT
Languages