Latest 1.0.0
Homepage https://github.com/phenemann/Authentication
License MIT Copyright (c) 2017 Pablo Henemann

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Platforms ios 9.0
Dependencies CryptoSwift
Authors

This is a lib created to sign iOS requests, using major authentication methods

Carthage compatible
Build Status
CocoaPods Compatible

Using

It’s pretty easy to use:

let method = AuthenticationMethod.oauth1(consumerKey: myConsumerKey,
                                         consumerSecret: myConsumerSecret,
                                         accessKey: myAccessKey,
                                         accessSecret: myAccessSecret)
let authorizer = Authenticator(method: method)
let request = URLRequest(url: "http://www.MyDomain.com.br/anyAPIService")
let authorizedRequest = try? authorizer.signRequest(request: request)

And now your request is signed with OAuth1 method

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate Authentication into your Xcode project using CocoaPods, specify it in your Podfile:

platform :ios, '10.0'
use_frameworks!

target '<Your Target Name>' do
    pod 'Authentication', '~> 1.0'
end

Then, run the following command:

$ pod install

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate Authentication into your Xcode project using Carthage, specify it in your Cartfile:

github "phenemann/Authentication" ~> 1.0

Run carthage update to build the framework and drag the built Authentication.framework into your Xcode project.

Contribute

Let’s make it do more?
Today the only method is OAuth1, you can implement OAuth2, for example, by using the pattern in OAuth1. To start fork the project and checkout it in your machine.

To install and contribute to the code you going to need:

To install Homebrew open Terminal and execute the code:

$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Afterwards, install Carthage and SwiftLint:

$ brew update
$ brew install carthage
$ brew install swiftlint

Carthage will install the project dependencies, swiftlint will take care of your code style.

Now you have to write your class/struct that implements the protocol "AuthenticationProvider" that only have one function:

    /// Sign request with configured authentication method
    ///
    /// - Parameter request: request to be signed
    /// - Returns: copy of the request already signed
    /// - Throws: you can throw your errors with configured authentication method
    func signRequest(request: URLRequest) throws -> URLRequest

Write a case in "AuthenticationMethod" enum than your implementation to the "build( )" in the same enum

DO NOT FORGET TO WRITE SOME TESTS

That’s it. Your method is already working. Thanks and do with the code as you please.

=]

Latest podspec

{
    "name": "Authentication",
    "platforms": {
        "ios": "9.0"
    },
    "summary": "Simple authentication signer for iOS URLRequest",
    "version": "1.0.0",
    "license": {
        "type": "MIT",
        "text": "                    Copyright (c) 2017 Pablo Henemannnn                    Permission is hereby granted, free of charge, to any person obtaining a copyn                    of this software and associated documentation files (the "Software"), to dealn                    in the Software without restriction, including without limitation the rightsn                    to use, copy, modify, merge, publish, distribute, sublicense, and/or selln                    copies of the Software, and to permit persons to whom the Software isn                    furnished to do so, subject to the following conditions:nn                    The above copyright notice and this permission notice shall be included in alln                    copies or substantial portions of the Software.nn                    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORn                    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,n                    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEn                    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERn                    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,n                    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THEn                    SOFTWARE.n"
    },
    "authors": {
        "Pablo Henemann": "[email protected]"
    },
    "homepage": "https://github.com/phenemann/Authentication",
    "source": {
        "git": "https://github.com/phenemann/Authentication.git",
        "tag": "1.0.0"
    },
    "source_files": "Sources/*.swift",
    "dependencies": {
        "CryptoSwift": []
    },
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This