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.