Skip to content

Commit 55a2a0c

Browse files
committed
clean up comments
1 parent 1e1cd31 commit 55a2a0c

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

src/kemal-hmac/client.cr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ require "./token"
22

33
module Kemal::Hmac
44
class Client
5-
# :param client: the client name which will be sending HTTP requests to the server using HMAC auth (String)
6-
# :param secret: the secret used to generate the HMAC token in relation to the client (String)
7-
# # :param algorithm: the algorithm used to generate the HMAC token (String) - defaults to SHA256
5+
# `client` the client name which will be sending HTTP requests to the server using HMAC auth (String)
6+
# `secret` the secret used to generate the HMAC token in relation to the client (String)
7+
# `algorithm` the algorithm used to generate the HMAC token (String) - defaults to SHA256
88
def initialize(client : String, secret : String, algorithm : String? = "SHA256")
99
@client = client
1010
@secret = secret
@@ -18,8 +18,8 @@ module Kemal::Hmac
1818

1919
# A public helper method to generate the HMAC headers for a given path
2020
# Use this method to get pre-filled headers to send with your request to the server
21-
# :param path: the path (HTTP path) to generate the headers for (String) - e.g. "/api/path"
22-
# :return: a Hash of the HMAC headers
21+
# `path` the path (HTTP path) to generate the headers for (String) - e.g. "/api/path"
22+
# returns a Hash of the HMAC headers
2323
def generate_headers(path : String) : Hash(String, String)
2424
timestamp = Time::Format::ISO_8601_DATE_TIME.format(Time.utc)
2525
hmac_token = Kemal::Hmac::Token.new(@client, path.split("?").first, timestamp, @algorithm).hexdigest(@secret)

src/kemal-hmac/handler.cr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,12 @@ module Kemal::Hmac
133133
end
134134

135135
# Check the request token by building our own with our known metadata and secret
136-
# :param request_token: token provided in request
137-
# :param secret: secret used to build token
138-
# :param client: client name used to build token
139-
# :param path: path used to build token
140-
# :param timestamp: timestamp used to build token
141-
# :return: True if token matches, False otherwise
136+
# `request_token` token provided in request
137+
# `secret` secret used to build token
138+
# `client` client name used to build token
139+
# `path` path used to build token
140+
# `timestamp` timestamp used to build token
141+
# returns True if token matches, False otherwise
142142
def valid_token?(request_token, secret, client, path, timestamp)
143143
token = Kemal::Hmac::Token.new(client, path, timestamp, @hmac_algorithm)
144144
Crypto::Subtle.constant_time_compare(token.hexdigest(secret), request_token)

src/kemal-hmac/token.cr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ require "openssl/hmac"
33

44
module Kemal::Hmac
55
class Token
6-
# :param subject: the subject of the token (String)
7-
# :param resource: the resource of the token (String)
8-
# :param timestamp: the timestamp of the token (String)
6+
# `subject` the subject of the token (String)
7+
# `resource` the resource of the token (String)
8+
# `timestamp` the timestamp of the token (String)
99
def initialize(subject : String, resource : String, timestamp : String, algorithm : OpenSSL::Algorithm? = nil)
1010
@subject = subject
1111
@resource = resource
@@ -14,8 +14,8 @@ module Kemal::Hmac
1414
end
1515

1616
# Build an HMAC token with the given secret
17-
# :param secret: the secret used to build token
18-
# :return: HMAC token (hexdigest)
17+
# `secret` the secret used to build token
18+
# returns HMAC token (hexdigest)
1919
def hexdigest(secret : String) : String
2020
OpenSSL::HMAC.hexdigest(@algorithm, secret, message)
2121
end

0 commit comments

Comments
 (0)