Latest 4.1.4
Homepage https://github.com/OpenClemson/SwiftECP
License Apache 2.0
Platforms ios 9.0, osx 10.11, requires ARC
Dependencies AEXML-CU, Alamofire, AnyError, ReactiveSwift, XCGLogger
Authors ,

Version
License
Platform

Need Shibboleth login on your iOS / MacOS app but don’t want to use a webview? Don’t want to deal with XML or read a spec? Use SwiftECP to do the work for you!

SwiftECP is a spec-conformant Shibboleth ECP client. Simply provide credentials and a Shibboleth-protected resource URL and SwiftECP will hand you a Shibboleth cookie to attach to further requests or inject into a webview.

Usage

let username = "YOUR_USERNAME"
let password = "YOUR_PASSWORD"
let protectedURL = URL(
    string: "https://app.university.edu"
)!
let logger = XCGLogger()
logger.setup(level: .debug)

ECPLogin(
    protectedURL: protectedURL,
    username: username,
    password: password,
    logger: logger
).start { event in
    switch event {

    case let .value(body):
        // If the request was successful, the protected resource will
        // be available in 'body'. Make sure to implement a mechanism to
        // detect authorization timeouts.
        print("Response body: (body)")

        // The Shibboleth auth cookie is now stored in the sharedHTTPCookieStorage.
        // Attach this cookie to subsequent requests to protected resources.
        // You can access the cookie with the following code:
        if let cookies = HTTPCookieStorage.shared.cookies {
            let shibCookie = cookies.filter { (cookie: HTTPCookie) in
                cookie.name.range(of: "shibsession") != nil
            }[0]
            print(shibCookie)
        }

    case let .failed(error):
        // This is an AnyError that wraps the error thrown.
        // This can help diagnose problems with your SP, your IdP, or even this library :)

        switch error.cause {
        case let ecpError as ECPError:
            // Error with ECP
            // User-friendly error message
            print(ecpError.userMessage)

            // Technical/debug error message
            print(ecpError.description)
        case let alamofireRACError as AlamofireRACError:
            // Error with the networking layer
            print(alamofireRACError.description)
        default:
            print("Unknown error!")
            print(error)
        }

    default:
        break
    }
}

Requirements

  • iOS 9.0+ / MacOS 10.11+
  • Xcode 8.1+
  • Swift 3.0+

Test

To run the example project, clone the repo, and run pod install from the Example directory first.

You can test your SP and IdP’s ECP configuration by opening the example project and replacing username, password, and protectedURL with your own.

Installation

SwiftECP is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "SwiftECP"

Todo

  • Unit and integration tests
  • Detailed documentation
  • Support for channel bindings and holder-of-key
  • Better IdP discovery

Pull requests are welcome and encouraged!

Authors

License

SwiftECP is available under the Apache 2.0 license. See the LICENSE file for more info.

Latest podspec

{
    "name": "SwiftECP",
    "version": "4.1.4",
    "summary": "SwiftECP is a simple Shibboleth ECP client for iOS.",
    "description": "Need Shibboleth login on your iOS or macOS app but don't want to use a webview? Don't want to deal with XML or read a spec? Use SwiftECP to do the work for you! SwiftECP is a spec-conformant Shibboleth ECP client. Simply provide credentials and a Shibboleth-protected resource URL and SwiftECP will hand you a Shibboleth cookie to attach to further requests or inject into a webview.",
    "homepage": "https://github.com/OpenClemson/SwiftECP",
    "license": "Apache 2.0",
    "authors": {
        "Tyler Thompson": "[email protected]",
        "Tanner Stokes": "[email protected]"
    },
    "source": {
        "git": "https://github.com/OpenClemson/SwiftECP.git",
        "tag": "4.1.4"
    },
    "platforms": {
        "ios": "9.0",
        "osx": "10.11"
    },
    "requires_arc": true,
    "source_files": "Pod/Source/**/*",
    "dependencies": {
        "AEXML-CU": [
            "~> 4.2.2"
        ],
        "Alamofire": [
            "~> 4.5"
        ],
        "AnyError": [
            "~> 2.0.1"
        ],
        "ReactiveSwift": [
            "~> 3.0"
        ],
        "XCGLogger": [
            "~> 6.0"
        ]
    },
    "pushed_with_swift_version": "4.0"
}

Pin It on Pinterest

Share This