Latest | 0.0.4 |
---|---|
Homepage | https://github.com/HungerStation/SwiftyHawk |
License | MIT |
Platforms | ios 8.0 |
Authors |
Based on the original implementation of Hawk: https://github.com/hueniverse/hawk.
Installation
SwiftyHawk is available through CocoaPods. To install
it, simply add the following line to your Podfile:
pod 'SwiftyHawk'
Usage
Usage is easy and straight forward, here is the basic usage:
let creds = HawkCredentials(id: "123456", key: "2983d45yun89q", algorithm: .SHA1)
let client = try! HawkClient(creds: creds)
let options = HawkOptions(url: URL(string: "http://www.example.com/resource/q?x=z&y=r"), method: .post)
let header = try! client.generateAuthorizationHeader(usingOptions: options) // example output: Hawk id="123456", ts="1353809207", nonce="Ygvqdz", ext="Bazinga!", mac="qbf1ZPG/r/e06F4ht+T77LXi5vw="
Based on the server implementation and your own requirements, you can change the following properties in the options
class:
/// Extra information to pass to the server
public var ext: String?
/// A pre-calcualated hash of the payload, if the payload validation is required.
public var payloadHash: String?
/// If the payload validation is required, and the hash not calcualted.
public var payload: String?
/// Payload ContentType, If the payload validation is required, and the hash not calcualted.
public var contentType: String?
/// Optional Timestamp, if not provided HawkClient will get the current TimeStamp
public var ts: Int?
/// Optional Nonce, if not provided HawkClient will generate a random nonce.
public var nonce: String?
/// Oz Application Id
public var app: String?
/// Oz delegator
public var dlg: String?
Tests
Few client tests are included in the project to test the output of the generateAuthorizationHeader
method for now, PRs are welcome to have a more structured, inclusive tests!
What’s Next?
Only generateAuthorizationHeader
is implemented for now, so there’s a lot of work to be done..
How to contribute?
There’re open issues for the missing parts of Hawk, you can start with that.. PRs are welcome!
As a reference, clone https://github.com/hueniverse/hawk
for specs (or you can read it from github directly)..
Latest podspec
{ "name": "SwiftyHawk", "version": "0.0.4", "summary": "Hawk Authentication Implementation for Swift", "swift_version": "4.2", "description": "Hawk Authentication Implementation for Swift based on the original implementation", "homepage": "https://github.com/HungerStation/SwiftyHawk", "license": { "type": "MIT", "file": "LICENSE" }, "authors": { "Muhamed ALGHZAWI": "[email protected]" }, "source": { "git": "https://github.com/HungerStation/SwiftyHawk.git", "tag": "0.0.4" }, "social_media_url": "https://www.linkedin.com/company/hungerstation-com", "platforms": { "ios": "8.0" }, "source_files": "SwiftyHawk/Classes/**/*" }
Mon, 28 Jan 2019 11:11:15 +0000