All Projects → raulriera → Authenticationviewcontroller

raulriera / Authenticationviewcontroller

Licence: mit
A simple to use, standard interface for authenticating to oauth 2.0 protected endpoints via SFSafariViewController.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Authenticationviewcontroller

Dashport
Local and OAuth authentication middleware for Deno
Stars: ✭ 131 (-48.43%)
Mutual labels:  authentication, oauth
Security.identity
.NET DevPack Identity is a set of common implementations to help you implementing Identity, Jwt, claims validation and another facilities
Stars: ✭ 165 (-35.04%)
Mutual labels:  authentication, oauth
React Native Instagram Login
a react native instagram login component (support android & ios). Pull requests are welcome!
Stars: ✭ 139 (-45.28%)
Mutual labels:  authentication, oauth
Spring Webmvc Pac4j
Security library for Spring Web MVC: OAuth, CAS, SAML, OpenID Connect, LDAP, JWT...
Stars: ✭ 110 (-56.69%)
Mutual labels:  authentication, oauth
Oauthlib
A generic, spec-compliant, thorough implementation of the OAuth request-signing logic
Stars: ✭ 2,323 (+814.57%)
Mutual labels:  authentication, oauth
Mern Boilerplate
Fullstack boilerplate with React, Redux, Express, Mongoose, Passport Local, JWT, Facebook and Google OAuth out of the box.
Stars: ✭ 112 (-55.91%)
Mutual labels:  authentication, oauth
Turnstile
An authentication framework for Swift.
Stars: ✭ 163 (-35.83%)
Mutual labels:  authentication, oauth
Connect
The SymfonyConnect official API SDK
Stars: ✭ 86 (-66.14%)
Mutual labels:  authentication, oauth
External Auth Server
easy auth for reverse proxies
Stars: ✭ 189 (-25.59%)
Mutual labels:  authentication, oauth
Hwioauthbundle
OAuth client integration for Symfony. Supports both OAuth1.0a and OAuth2.
Stars: ✭ 2,150 (+746.46%)
Mutual labels:  authentication, oauth
Warden Github Rails
Use GitHub as authorization and more. Use organizations and teams as means of authorization by simply wrapping your rails routes in a block. Also useful to get a user's details through OAuth.
Stars: ✭ 100 (-60.63%)
Mutual labels:  authentication, oauth
Spring Security Pac4j
pac4j security library for Spring Security: OAuth, CAS, SAML, OpenID Connect, LDAP, JWT...
Stars: ✭ 231 (-9.06%)
Mutual labels:  authentication, oauth
Vue Authenticate
Simple Vue.js authentication library
Stars: ✭ 1,350 (+431.5%)
Mutual labels:  authentication, oauth
Fosite
Extensible security first OAuth 2.0 and OpenID Connect SDK for Go.
Stars: ✭ 1,738 (+584.25%)
Mutual labels:  authentication, oauth
Nextjs Starter
A starter project for Next.js with authentication
Stars: ✭ 1,313 (+416.93%)
Mutual labels:  authentication, oauth
Spark Pac4j
Security library for Sparkjava: OAuth, CAS, SAML, OpenID Connect, LDAP, JWT...
Stars: ✭ 154 (-39.37%)
Mutual labels:  authentication, oauth
Stormpath Sdk Php
PHP SDK for the Stormpath User Management and Authentication REST+JSON API
Stars: ✭ 72 (-71.65%)
Mutual labels:  authentication, oauth
Ueberauth
An Elixir Authentication System for Plug-based Web Applications
Stars: ✭ 1,259 (+395.67%)
Mutual labels:  authentication, oauth
Pac4j
Security engine for Java (authentication, authorization, multi frameworks): OAuth, CAS, SAML, OpenID Connect, LDAP, JWT...
Stars: ✭ 2,097 (+725.59%)
Mutual labels:  authentication, oauth
Awesome Iam
👤 Identity and Access Management Knowledge for Cloud Platforms
Stars: ✭ 186 (-26.77%)
Mutual labels:  authentication, oauth

AuthenticationViewController

A simple to use, standard interface for authenticating to OAuth 2.0 protected endpoints via SFSafariViewController.

Step1

Instructions

In order to use this View Controller you need to be running iOS 9 on your simulator or device.

Step 1

Setup the URL Scheme of your app as shown in the image below. (You can find this in the Info tab of your project's settings)

Step1

Step 2

Prepare your AppDelegate to handle this newly created URL Scheme

func application(app: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool {

    // Before doing this, you should check the url is your redirect-uri before doing anything. Be safe :)
    if let components = NSURLComponents(URL: url, resolvingAgainstBaseURL: false),
        queryItems = components.queryItems, 
        code = queryItems.first?.value {

        // Let's find the instance of our authentication controller, 
        // it would be the presentedViewController. This is another 
        // reason to check before that we are actually coming from the SFSafariViewController
        if let rootViewController = window?.rootViewController,
            authenticationViewController = rootViewController.presentedViewController as? AuthenticationViewController {
            authenticationViewController.authenticateWithCode(code)
        }

        return true
    }

    return false
}

Note that you need to pass the authentication code received by your URL scheme to the AuthenticationViewController so it can exchange it for an actual access token.

Step 3

Create an AuthenticationProvider following the AuthenticationProvider protocol.

Step 4

Instantiate an AuthenticationViewController in your code and pass in the provider.

let provider = OAuthDribbble(clientId: "your-client-id", 
    clientSecret: "your-client-secret", 
    scopes: ["public", "upload"])

let authenticationViewController = AuthenticationViewController(provider: provider)

authenticationViewController.failureHandler = { error in
    print(error)
}

authenticationViewController.authenticationHandler = { token in
    print(token)

    authenticationViewController.dismissViewControllerAnimated(true, completion: nil)
}

presentViewController(authenticationViewController, animated: true, completion: nil)

That is it, when you fill in your user account in the AuthenticationViewController and if everything went correctly you should get the access token in the authenticationHandler closure. Otherwise check for any errors in the failureHandler closure.

Installation

Choose one of the following options.

Carthage

Add the following to your Cartfile:

github "raulriera/AuthenticationViewController"

CocoaPods

Add the following to your Podfile:

pod "AuthenticationViewController"

Manual

Just drag and drop the AuthenticationViewController/AuthenticationViewController folder into your project.

Example

Sometimes it's easier to dig in into some code, included in this project is an example for Dribbble and Instagram. You will still need to edit the source code to provide real clientId, clientSecret, and your URL scheme.

Created by

Raul Riera, @raulriera

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].