Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
GrantBirki committed Oct 15, 2024
1 parent 994d1b7 commit d190421
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,38 @@ Why should I use HMAC in a client/server system with kemal? Here are some of the

This readme will be broken up into two parts. The first part will cover how to use the server middleware in a kemal application. The second part will cover how to use the client to communicate with a server that uses the middleware.

## Server Usage
## Quick Start ⭐

### Installation

Using this shard with a kemal application is simple. First, add the shard to your `shard.yml` file:
Simply add the shard to your `shard.yml` file:

```yaml
dependencies:
kemal-hmac:
github: grantbirki/kemal-hmac
```
Now you can require the `kemal-hmac` shard in your kemal application and call it:
### Basic Example
The most basic example possible enabling HMAC authentication for all routes in a kemal application:
```crystal
require "kemal"
require "kemal-hmac"

hmac_auth({"my_client" => ["my_secret"]})

get "/" do |env|
"Hi, %s! You passed HMAC auth" % env.kemal_authorized_client?
end

Kemal.run
```

## Server Usage

First, you must require the `kemal-hmac` shard in your kemal application and call it:

```crystal
# file: hmac_server.cr
Expand Down

0 comments on commit d190421

Please sign in to comment.