{"repo":"yegor256/glogin","free":true,"listed":false,"github":"https://github.com/yegor256/glogin","clone":"git clone https://github.com/yegor256/glogin.git","description":"Login/logout via GitHub OAuth for your Ruby web app","language":"Ruby","stars":13,"topics":["github","ruby","oauth2","ruby-gem"],"license":"MIT","category":"auth-billing-email","readme_excerpt":"OAuth Login via GitHub Made Simple This simple gem helps you enable login/logout through [GitHub OAuth][doc] for your web application. This is how it works with Sinatra, but you can do something similar in any framework. Read this blog post to get the idea: [ Simplified GitHub Login for a Ruby Web App ][blog] First, somewhere in the global space, before the app starts: Next, for all web pages we need to parse a cookie, if it exists, and convert it into a user: If the glogin cookie is coming in and contains valid data, a local variable @user is set to something like this: If the secret is an empty string, the encryption is disabled. Next, we need a URL for GitHub OAuth callback: Finally, we need a logout URL: It is recommended to provide the third \"context\" parameter to GLogin::Cookie::Closed and GLogin::Cookie::Open constructors, in order to enforce stronger security. The context may include the User-Agent HTTP header of the user, their IP address, and so on. When anything changes on the user side, they are forced to re-login. One more thing is the login URL you need for your front page. Here it is: For unit testing, you can just provide an empty string as a secret for GLogin::Cookie::Open and GLogin::Cookie::Closed and the encryption is disabled: whatever comes from the cookie is trusted. For testing it is convenient to provide a user name in a query string, like: To enable that, it's recommended to add this line (see how it works in zold-io/wts.zold.io): I use this gem in s","default_branch":null,"files":null,"tree":[],"storefront":"/r/yegor256","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/yegor256/glogin/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}