All Projects → thoughtbot → Superb

thoughtbot / Superb

Licence: mit
Pluggable HTTP authentication for Swift.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Superb

Fullstack Apollo React Boilerplate
💥A sophisticated Apollo in React boilerplate project.
Stars: ✭ 136 (-33.98%)
Mutual labels:  authentication, authorization
Spotify Clone Client
A ReactJS clone application of the popular Spotify music streaming service. This application utilizes the Spotify API and the Spotify Web Playback SDK
Stars: ✭ 162 (-21.36%)
Mutual labels:  authentication, authorization
Vuejs2 Authentication Tutorial
Stars: ✭ 144 (-30.1%)
Mutual labels:  authentication, authorization
Laravel Auth
A powerful authentication, authorization and verification package built on top of Laravel. It provides developers with Role Based Access Control, Two-Factor Authentication, Social Authentication, and much more, compatible Laravel’s standard API and fully featured out of the box.
Stars: ✭ 128 (-37.86%)
Mutual labels:  authentication, authorization
Feathers Vue
A boiler plate template using Feathers with Email Verification, Vue 2 with Server Side Rendering, stylus, scss, jade, babel, webpack, ES 6-8, login form, user authorization, and SEO
Stars: ✭ 195 (-5.34%)
Mutual labels:  authentication, authorization
Registration Login Spring Xml Maven Jsp Mysql
Registration and Login Example with Spring MVC, Spring Security, Spring Data JPA, XML Configuration, Maven, JSP, and MySQL.
Stars: ✭ 134 (-34.95%)
Mutual labels:  authentication, authorization
Spark Pac4j
Security library for Sparkjava: OAuth, CAS, SAML, OpenID Connect, LDAP, JWT...
Stars: ✭ 154 (-25.24%)
Mutual labels:  authentication, authorization
Graphql Directive Auth
GraphQL directive for handling auth
Stars: ✭ 120 (-41.75%)
Mutual labels:  authentication, authorization
Pac4j
Security engine for Java (authentication, authorization, multi frameworks): OAuth, CAS, SAML, OpenID Connect, LDAP, JWT...
Stars: ✭ 2,097 (+917.96%)
Mutual labels:  authentication, authorization
React Firestore Authentication
🔥Boilerplate Project for Authentication with Firestore in React.
Stars: ✭ 165 (-19.9%)
Mutual labels:  authentication, authorization
Rabbitmq Auth Backend Http
HTTP-based authorisation and authentication for RabbitMQ
Stars: ✭ 194 (-5.83%)
Mutual labels:  authentication, authorization
Huge
Simple user-authentication solution, embedded into a small framework.
Stars: ✭ 2,125 (+931.55%)
Mutual labels:  authentication, authorization
Fosite
Extensible security first OAuth 2.0 and OpenID Connect SDK for Go.
Stars: ✭ 1,738 (+743.69%)
Mutual labels:  authentication, authorization
Awesome Iam
👤 Identity and Access Management Knowledge for Cloud Platforms
Stars: ✭ 186 (-9.71%)
Mutual labels:  authentication, authorization
Serverless Architectures Aws
The code repository for the Serverless Architectures on AWS book
Stars: ✭ 120 (-41.75%)
Mutual labels:  authentication, authorization
Express Mongodb Rest Api Boilerplate
A boilerplate for Node.js apps / Rest API / Authentication from scratch - express, mongodb (mongoose).
Stars: ✭ 153 (-25.73%)
Mutual labels:  authentication, authorization
Cakephp Tinyauth
CakePHP TinyAuth plugin for an easy and fast user authentication and authorization. Single or multi role. DB or config file based.
Stars: ✭ 114 (-44.66%)
Mutual labels:  authentication, authorization
Xxl Sso
A distributed single-sign-on framework.(分布式单点登录框架XXL-SSO)
Stars: ✭ 1,635 (+693.69%)
Mutual labels:  authentication, authorization
Security.identity
.NET DevPack Identity is a set of common implementations to help you implementing Identity, Jwt, claims validation and another facilities
Stars: ✭ 165 (-19.9%)
Mutual labels:  authentication, authorization
Bottle Cork
Authentication module for the Bottle and Flask web frameworks
Stars: ✭ 174 (-15.53%)
Mutual labels:  authentication, authorization

Superb Carthage compatible

Pluggable HTTP authentication for Swift.

Advantages

  • Safe, secure token storage in the iOS Keychain.
  • Automatic handling of 401 responses and reauthentication.
  • Scales to handle many concurrent requests in a thread-safe way.
  • Stays out of your way until you need it with a simple, minimal API.
  • Promotes Apple's Authentication Guidelines by "delaying sign-in as long as possible".
  • Supports adapters for any number of authentication providers.
  • Extensible without requiring any source modifications or pull requests.

Caveats

  • Opinionated about user experience.

Usage

Example: GitHub OAuth Authentication

When you register the app with your OAuth provider, you will give a redirect URI. This URI must use a URL scheme that is registered for your app in your app's Info.plist.

Superb allows your app to support multiple authentication providers via a registration mechanism. iOS apps have a single entrypoint for URLs, so Superb searches through the registered providers to find the correct one to handle the redirect URL.

// GitHub+Providers.swift

import Superb
import SuperbGitHub

extension GitHubOAuthProvider {
  static var shared: GitHubOAuthProvider {
    // Register a provider to handle callback URLs
    return Superb.register(
      GitHubOAuthProvider(
        clientId: "<your client id>",
        clientSecret: "<your client secret>",
        redirectURI: URL(string: "<your chosen redirect URI>")!
      )
    )
  }
}
// AppDelegate.swift

@UIApplicationMain
final class AppDelegate: UIResponder, UIApplicationDelegate {
  // ...

  func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey: Any]) -> Bool {
    // Pass the URL and options off to Superb.
    return Superb.handleAuthenticationRedirect(url, options: options)
  }
}

Then, in our API client, we can use RequestAuthorizer to fence the code that must be run with authentication, using RequestAuthorizer.performAuthorized().

// GitHubAPIClient.swift

struct GitHubAPIClient {
  static let oauthClient = GitHubAPIClient(
    requestAuthorizer: RequestAuthorizer(
      authorizationProvider: GitHubOAuthProvider.shared
    )
  )

  private let authorizer: RequestAuthorizerProtocol

  init(requestAuthorizer: RequestAuthorizerProtocol) {
    authorizer = requestAuthorizer
  }

  // An authorized request to get the current user's profile.
  func getProfile(completionHandler: @escaping (Result<Profile, SuperbError>) -> Void) {
    let request = URLRequest(url: URL(string: "https://api.github.com/user")!)

    authorizer.performAuthorized(request) { result in
      switch result {
      case let .success(data, _):
        let profile = parseProfile(from: data)
        completionHandler(.success(profile))

      case let .failure(error):
        completionHandler(.failure(error))
      }
    }
  }

  // An unauthorized request.
  func getZen(completionHandler: @escaping (Result<String, SuperbError>) -> Void) {
    let request = URLRequest(url: URL(string: "https://api.github.com/zen")!)

    URLSession.shared.dataTask(with: request) { data, _, error in
      let result = parseZen(data, error)
      completionHandler(result)
    }.resume()
  }
}

// later
let api = GitHubAPIClient.oauthClient

api.getProfile { result in
  // ...
}

List of Authentication Providers

Installation

Carthage

Add the following to your Cartfile:

github "thoughtbot/Superb" ~> 0.2

Then run carthage update.

Follow the current instructions in Carthage's README for up to date installation instructions.

You will need to embed both Superb.framework and Result.framework in your application.

CocoaPods

Add the following to your Podfile:

pod "Superb", "~> 0.2.0"

You will also need to make sure you're opting into using frameworks:

use_frameworks!

Then run pod install.

Troubleshooting

Authentication always fails when using OAuth

You forgot to call Superb.register.

If you do not call Superb.register then your authentication provider will not have a chance to receive callback URLs.

Contributing

See the CONTRIBUTING document. Thank you, contributors!

License

Superb is Copyright (c) 2017 thoughtbot, inc. It is free software, and may be redistributed under the terms specified in the LICENSE file.

About

thoughtbot

Superb is maintained and funded by thoughtbot, inc. The names and logos for thoughtbot are trademarks of thoughtbot, inc.

We love open source software! See our other projects or look at our product case studies and hire us to help build your iOS app.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].