Ruby realizes GitHub third party authentication

Source: Internet
Author: User
Tags auth require

GitHub in the user authentication process using a dual-key mechanism, in the two-key encryption mechanism, only legitimate users have private keys, as long as the GitHub when the request can be proved to submit the request of the client to have the private key, that is, you can confirm that the operation was initiated by legitimate users. Let's simply simulate it with Ruby.

The code is simple, there's no more nonsense.


#coding: Utf-8 require ' Sinatra ' require ' Omniauth ' require ' "Omniauth-github ' use Rack::session::cookie ' Ilder do Provider:github, ' b478ae6b31dd730b20d1 ', ' 89f67d361fb348c959eaafea7e40f6db8b166366 ' End Get '/do <<-HT ML <a href= '/auth/github ' >sign in with github</a> HTML end Post '/auth/:name/callback ' do auth = require.env [' Omniauth.auth '] End

The above mentioned is the entire content of this article, I hope you can enjoy.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.