digest-auth
Version, currently 1.0.03 versions
- 1.0.2latestMar 22, 2021
- 1.0.1not indexedMay 26, 2021
- 1.0.0not indexedMay 26, 2021
github.com/spider-gazelle/digest-auth
HTTP digest auth for crystal lang
Nothing has been indexed for 1.0.0 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.
Installation
# Add this to your shard.yml
dependencies:
digest-auth:
github: spider-gazelle/digest-auth
version: ~> 1.0.0Then run:
shards installshard.yml
No shard.yml has been indexed for 1.0.0. You can read it on the repository.
Dependencies
Unknown: the shard.yml for this version has not been read yet.
README
This README is the one indexed from the repository at its latest ref, not from the tag for this version.
Crystal Lang Digest Auth
Communicate with servers that implement digest auth.
Installation
-
Add the dependency to your
shard.yml:dependencies: digest-auth: github: spider-gazelle/digest-auth -
Run
shards install
Usage
require "http/client"
require "digest-auth"
# New client per-connection, this keeps track of nonce count
digest_auth = DigestAuth.new
uri = URI.parse "http://foo.com/posts?id=30&limit=5"
# if you expect digest auth use a head request to get the challenge header
client = HTTP::Client.new uri
response = client.head uri.full_path
response.status_code # => 401
challenge = response.headers["WWW-Authenticate"]
uri.user = "username"
uri.password = "password"
# Generate the auth header, need to indicate if talking to IIS
auth_header = digest_auth.auth_header(uri, challenge, "get", iis: false)
# Make the request
response = client.get uri.full_path, HTTP::Headers{ "Authorization" => auth_header }
response.status_code # => 200
# Make a second request while the connection is still open
uri.path = "/posts/30"
auth_header = digest_auth.auth_header(uri, challenge, "post", iis: false)
response = client.post uri.full_path, HTTP::Headers{ "Authorization" => auth_header }, body: "hello!"
response.status_code # => 201
or using .before_request
require "http/client"
require "digest-auth"
digest_auth = DigestAuth.new
uri = URI.parse "http://foo.com/"
client = HTTP::Client.new uri
response = client.head uri.full_path
response.status_code # => 401
challenge = response.headers["WWW-Authenticate"]
uri.user = "username"
uri.password = "password"
client.before_request do |request|
req_path = URI.parse request.resource
uri.path = req_path.path
uri.query = req_path.query
auth_header = digest_auth.auth_header(uri, challenge, request.method, iis: false)
request.headers["Authorization"] = auth_header
end
client.get "/"
client.post "/some_path", body: "hello!"
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
1.0.0- Tagged
- May 26, 2021
- Commit
53f0ceb67a33- Indexed
- not yet
Dependents
No indexed shard depends on this one yet.
Repository
github.com/spider-gazelle/digest-auth
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 15, 2026
- Synced
- Aug 15, 2026
- Versions
- 3