All Projects → PerfectlySoft → Perfect-Authentication

PerfectlySoft / Perfect-Authentication

Licence: Apache-2.0 License
OAuth2 Implementations with Facebook, Google, LinkedIn, Slack, SalesForce and GitHub providers.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Perfect-Authentication

Hackathon Starter Kit
A Node-Typescript/Express Boilerplate with Authentication(Local, Github, Facebook, Twitter, Google, Dropbox, LinkedIn, Discord, Slack), Authorization, and CRUD functionality + PWA Support!
Stars: ✭ 242 (+1628.57%)
Mutual labels:  slack, oauth2, facebook, linkedin
Oauth
🔗 OAuth 2.0 implementation for various providers in one place.
Stars: ✭ 336 (+2300%)
Mutual labels:  oauth2, facebook, linkedin
SimpleOAuth
Simple OAuth 2.0 for Android
Stars: ✭ 15 (+7.14%)
Mutual labels:  oauth2, facebook, oauth2-provider
Assent
Multi-provider framework in Elixir
Stars: ✭ 126 (+800%)
Mutual labels:  slack, oauth2, facebook
Socialite
Socialite is an OAuth2 Authentication tool. It is inspired by laravel/socialite, you can easily use it without Laravel.
Stars: ✭ 1,026 (+7228.57%)
Mutual labels:  oauth2, facebook, linkedin
Pow assent
Multi-provider authentication for your Pow enabled app
Stars: ✭ 236 (+1585.71%)
Mutual labels:  slack, oauth2, facebook
CwsShareCount
PHP class to get social share count for Delicious, Facebook, Google+, Linkedin, Pinterest, Reddit, StumbleUpon and Twitter.
Stars: ✭ 13 (-7.14%)
Mutual labels:  facebook, linkedin
Perfect-XML
XML support for Perfect.
Stars: ✭ 16 (+14.29%)
Mutual labels:  perfect, server-side-swift
Perfect-URLRouting
Perfect Example Module: URL Routing
Stars: ✭ 20 (+42.86%)
Mutual labels:  perfect, server-side-swift
OAuthLogin
第三方平台联合登陆(facebook、微信、微博、QQ、Kakao)
Stars: ✭ 57 (+307.14%)
Mutual labels:  oauth2, facebook
Perfect-HTTP
Base HTTP Support for Perfect.
Stars: ✭ 29 (+107.14%)
Mutual labels:  perfect, server-side-swift
Perfect-Thread
Core threading library for Perfect Server Side Swift. Includes support for serial and concurrent thread queues, locks, read/write locks and events.
Stars: ✭ 17 (+21.43%)
Mutual labels:  perfect, server-side-swift
OAuthLogin.AspNetCore
第三方平台联合登陆(facebook、微信、微博、QQ、Kakao)
Stars: ✭ 43 (+207.14%)
Mutual labels:  oauth2, facebook
Perfect-SMTP
SMTP Client for Perfect.
Stars: ✭ 19 (+35.71%)
Mutual labels:  perfect, server-side-swift
Social-Media-Automation
Automate social media because you don't have to be active on all of them😉. Best way to be active on all social media without actually being active on them. 😃
Stars: ✭ 186 (+1228.57%)
Mutual labels:  facebook, linkedin
Perfect-Weather
Demonstrate using URL Routes & variables, Fetching of remote data from API's as JSON, reading and transforming to data more appropriately consumable by an API client.
Stars: ✭ 32 (+128.57%)
Mutual labels:  perfect, server-side-swift
react-custom-share
Social media share buttons for ReactJS. Use one of the built-in button themes or create a custom one from scratch.
Stars: ✭ 47 (+235.71%)
Mutual labels:  facebook, linkedin
Perfect-Zip
Perfect Zip compression utility.
Stars: ✭ 20 (+42.86%)
Mutual labels:  perfect, server-side-swift
sharon
A lightweight and modular social sharing library
Stars: ✭ 16 (+14.29%)
Mutual labels:  facebook, linkedin
Stevenson
Stevenson is a Vapor framework designed to build integrations between Slack apps, GitHub, JIRA and CI services (CircleCI).
Stars: ✭ 57 (+307.14%)
Mutual labels:  slack, server-side-swift

Perfect-Authentication

Perfect logo

Perfect logo Perfect logo Perfect logo Perfect logo

Swift 3.0 Platforms OS X | Linux License Apache Twitter Join the chat at https://gitter.im/PerfectlySoft/Perfect Slack Status GitHub version

FYI, This repo has been moved to Perfect-OAuth2

This repo is deprecated and no longer supported.

This project provides OAuth2 libraries and select OAuth2 provider drivers - Facebook, Google, GitHub.

Full documentation can be found at http://www.perfect.org/docs/OAuth2.html

A demo application can be found at https://github.com/PerfectExamples/Perfect-Authentication-Demo that shows the usage of the system.

This package builds with Swift Package Manager and is part of the Perfect project. It was written to be stand-alone and so does not require PerfectLib or any other components.

Ensure you have installed and activated the latest Swift 3.0 tool chain.

Adding to your project

Add this project as a dependency in your Package.swift file.

.Package(url: "https://github.com/PerfectlySoft/Perfect-Authentication.git", majorVersion: 1)

To then use the OAuth2 module in your code:

import OAuth2

Configuration

Each provider needs an "appid", also known as a "key", and a "secret". These are usually generated by the OAuth Host, such as Facebook, GitHub and Google developer consoles. These values, as well as an "endpointAfterAuth" and "redirectAfterAuth" value must be set for each provider you wish to use.

To configure Facebook as a provider:

FacebookConfig.appid = "yourAppID"
FacebookConfig.secret = "yourSecret"
FacebookConfig.endpointAfterAuth = "http://localhost:8181/auth/response/facebook"
FacebookConfig.redirectAfterAuth = "http://localhost:8181/"

To configure Google as a provider:

GoogleConfig.appid = "yourAppID"
GoogleConfig.secret = "yourSecret"
GoogleConfig.endpointAfterAuth = "http://localhost:8181/auth/response/google"
GoogleConfig.redirectAfterAuth = "http://localhost:8181/"

To configure GitHub as a provider:

GitHubConfig.appid = "yourAppID"
GitHubConfig.secret = "yourSecret"
GitHubConfig.endpointAfterAuth = "http://localhost:8181/auth/response/github"
GitHubConfig.redirectAfterAuth = "http://localhost:8181/"

Adding Routes

The OAuth2 system relies on an authentication / exchange system, which requires a URL to be specially assembled that the user is redirected to, and a URL that the user is returned to after the user has committed the authorization action.

The first set of routes below are the action URL's that will redirect to the OAuth2 provider's system. They can be anything you wish them to be. The user will never see anything on them as they will be immediately redirected to the correct place.

The second set of routes below are where the OAuth2 provider should return the user to. Note that this is the same as the "endpointAfterAuth" configuration option. Once the "authResponse" function has been completed the user is automatically forwarded to the URL in the "redirectAfterAuth" option.

var routes: [[String: Any]] = [[String: Any]]()

routes.append(["method":"get", "uri":"/to/facebook", "handler":Facebook.sendToProvider])
routes.append(["method":"get", "uri":"/to/github", "handler":GitHub.sendToProvider])
routes.append(["method":"get", "uri":"/to/google", "handler":Google.sendToProvider])

routes.append(["method":"get", "uri":"/auth/response/facebook", "handler":Facebook.authResponse])
routes.append(["method":"get", "uri":"/auth/response/github", "handler":GitHub.authResponse])
routes.append(["method":"get", "uri":"/auth/response/google", "handler":Google.authResponse])

Information returned and made available

After the user has been authenticated, certain information is gleaned from the OAuth2 provider.

Note that the session ID can be retrieved using:

request.session?.token

The user-specific information can be accessed as part of the session info:

// The UserID as defined by the provider
request.session?.userid

// designates the OAuth2 source - useful if you are allowing multiple OAuth providers
request.session?.data["loginType"]

// The access token obtained in the process
request.session?.data["accessToken"]

// The user's first name as supplied by the provider
request.session?.data["firstName"]

// The user's last name as supplied by the provider
request.session?.data["lastName"]

// The user's profile picture as supplied by the provider
request.session?.data["picture"]

With access to this information, you can now save to the database of your choice.

Further Information

For more information on the Perfect project, please visit perfect.org.

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