{"id":13635356,"url":"https://github.com/PerfectlySoft/Perfect-Authentication","last_synced_at":"2025-04-19T04:30:56.586Z","repository":{"id":69669919,"uuid":"79944613","full_name":"PerfectlySoft/Perfect-Authentication","owner":"PerfectlySoft","description":"OAuth2 Implementations with Facebook, Google, LinkedIn, Slack, SalesForce and GitHub providers.","archived":false,"fork":false,"pushed_at":"2018-02-09T17:46:17.000Z","size":1695,"stargazers_count":15,"open_issues_count":3,"forks_count":6,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-08T18:50:46.954Z","etag":null,"topics":["authentication","facebook","github","google","linkedin","oauth2","oauth2-provider","perfect","server-side-swift","slack","swift"],"latest_commit_sha":null,"homepage":"https://github.com/PerfectExamples/Perfect-Authentication-Demo","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PerfectlySoft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-01-24T19:11:57.000Z","updated_at":"2023-09-04T08:59:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"fb8f4036-5889-48d2-85b9-4262959b176c","html_url":"https://github.com/PerfectlySoft/Perfect-Authentication","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PerfectlySoft%2FPerfect-Authentication","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PerfectlySoft%2FPerfect-Authentication/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PerfectlySoft%2FPerfect-Authentication/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PerfectlySoft%2FPerfect-Authentication/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PerfectlySoft","download_url":"https://codeload.github.com/PerfectlySoft/Perfect-Authentication/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249606267,"owners_count":21298851,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["authentication","facebook","github","google","linkedin","oauth2","oauth2-provider","perfect","server-side-swift","slack","swift"],"created_at":"2024-08-02T00:00:44.400Z","updated_at":"2025-04-19T04:30:56.033Z","avatar_url":"https://github.com/PerfectlySoft.png","language":"Swift","readme":"# Perfect-Authentication\n\n[![Perfect logo](http://www.perfect.org/github/Perfect_GH_header_854.jpg)](http://perfect.org/get-involved.html)\n\n[![Perfect logo](http://www.perfect.org/github/Perfect_GH_button_1_Star.jpg)](https://github.com/PerfectlySoft/Perfect)\n[![Perfect logo](http://www.perfect.org/github/Perfect_GH_button_2_Git.jpg)](https://gitter.im/PerfectlySoft/Perfect)\n[![Perfect logo](http://www.perfect.org/github/Perfect_GH_button_3_twit.jpg)](https://twitter.com/perfectlysoft)\n[![Perfect logo](http://www.perfect.org/github/Perfect_GH_button_4_slack.jpg)](http://perfect.ly)\n\n\n[![Swift 3.0](https://img.shields.io/badge/Swift-3.0-orange.svg?style=flat)](https://developer.apple.com/swift/)\n[![Platforms OS X | Linux](https://img.shields.io/badge/Platforms-OS%20X%20%7C%20Linux%20-lightgray.svg?style=flat)](https://developer.apple.com/swift/)\n[![License Apache](https://img.shields.io/badge/License-Apache-lightgrey.svg?style=flat)](http://perfect.org/licensing.html)\n[![Twitter](https://img.shields.io/badge/Twitter-@PerfectlySoft-blue.svg?style=flat)](http://twitter.com/PerfectlySoft)\n[![Join the chat at https://gitter.im/PerfectlySoft/Perfect](https://img.shields.io/badge/Gitter-Join%20Chat-brightgreen.svg)](https://gitter.im/PerfectlySoft/Perfect?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n[![Slack Status](http://perfect.ly/badge.svg)](http://perfect.ly) [![GitHub version](https://badge.fury.io/gh/PerfectlySoft%2FPerfect-CURL.svg)](https://badge.fury.io/gh/PerfectlySoft%2FPerfect-CURL)\n\n## FYI, This repo has been moved to [Perfect-OAuth2](https://github.com/PerfectlySoft/Perfect-OAuth2)\n\n## This repo is deprecated and no longer supported.\n\nThis project provides [OAuth2](https://oauth.net/2/) libraries and select OAuth2 provider drivers - Facebook, Google, GitHub.\n\nFull documentation can be found at [http://www.perfect.org/docs/OAuth2.html](http://www.perfect.org/docs/OAuth2.html)\n\nA demo application can be found at [https://github.com/PerfectExamples/Perfect-Authentication-Demo](https://github.com/PerfectExamples/Perfect-Authentication-Demo) that shows the usage of the system.\n\nThis package builds with Swift Package Manager and is part of the [Perfect](https://github.com/PerfectlySoft/Perfect) project. It was written to be stand-alone and so does not require PerfectLib or any other components.\n\nEnsure you have installed and activated the latest Swift 3.0 tool chain.\n\n## Adding to your project\n\nAdd this project as a dependency in your Package.swift file.\n\n``` swift\n.Package(url: \"https://github.com/PerfectlySoft/Perfect-Authentication.git\", majorVersion: 1)\n```\n\nTo then use the OAuth2 module in your code:\n\n``` swift\nimport OAuth2\n```\n\n## Configuration\n\nEach 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. \n\nTo configure Facebook as a provider:\n\n``` swift\nFacebookConfig.appid = \"yourAppID\"\nFacebookConfig.secret = \"yourSecret\"\nFacebookConfig.endpointAfterAuth = \"http://localhost:8181/auth/response/facebook\"\nFacebookConfig.redirectAfterAuth = \"http://localhost:8181/\"\n```\n\nTo configure Google as a provider:\n\n``` swift\nGoogleConfig.appid = \"yourAppID\"\nGoogleConfig.secret = \"yourSecret\"\nGoogleConfig.endpointAfterAuth = \"http://localhost:8181/auth/response/google\"\nGoogleConfig.redirectAfterAuth = \"http://localhost:8181/\"\n```\n\nTo configure GitHub as a provider:\n\n``` swift\nGitHubConfig.appid = \"yourAppID\"\nGitHubConfig.secret = \"yourSecret\"\nGitHubConfig.endpointAfterAuth = \"http://localhost:8181/auth/response/github\"\nGitHubConfig.redirectAfterAuth = \"http://localhost:8181/\"\n```\n\n## Adding Routes\n\nThe 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.\n\nThe 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.\n\nThe 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.\n\n``` swift\nvar routes: [[String: Any]] = [[String: Any]]()\n\nroutes.append([\"method\":\"get\", \"uri\":\"/to/facebook\", \"handler\":Facebook.sendToProvider])\nroutes.append([\"method\":\"get\", \"uri\":\"/to/github\", \"handler\":GitHub.sendToProvider])\nroutes.append([\"method\":\"get\", \"uri\":\"/to/google\", \"handler\":Google.sendToProvider])\n\nroutes.append([\"method\":\"get\", \"uri\":\"/auth/response/facebook\", \"handler\":Facebook.authResponse])\nroutes.append([\"method\":\"get\", \"uri\":\"/auth/response/github\", \"handler\":GitHub.authResponse])\nroutes.append([\"method\":\"get\", \"uri\":\"/auth/response/google\", \"handler\":Google.authResponse])\n```\n\n## Information returned and made available\n\nAfter the user has been authenticated, certain information is gleaned from the OAuth2 provider.\n\nNote that the session ID can be retrieved using:\n\n``` swift\nrequest.session?.token\n```\n\nThe user-specific information can be accessed as part of the session info:\n\n``` swift\n// The UserID as defined by the provider\nrequest.session?.userid\n\n// designates the OAuth2 source - useful if you are allowing multiple OAuth providers\nrequest.session?.data[\"loginType\"]\n\n// The access token obtained in the process\nrequest.session?.data[\"accessToken\"]\n\n// The user's first name as supplied by the provider\nrequest.session?.data[\"firstName\"]\n\n// The user's last name as supplied by the provider\nrequest.session?.data[\"lastName\"]\n\n// The user's profile picture as supplied by the provider\nrequest.session?.data[\"picture\"]\n\n```\n\nWith access to this information, you can now save to the database of your choice.\n\n## Further Information\nFor more information on the Perfect project, please visit [perfect.org](http://perfect.org).\n","funding_links":[],"categories":["Authentication"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPerfectlySoft%2FPerfect-Authentication","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FPerfectlySoft%2FPerfect-Authentication","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPerfectlySoft%2FPerfect-Authentication/lists"}