sinatra_auth_github

简单的 sinatra 扩展,针对github oauth对用户进行身份验证。(simple sinatra extension to authenticate users against github oauth.)

  • 所有者: atmos/sinatra_auth_github
  • 平台:
  • 許可證: MIT License
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

sinatra_auth_github

A sinatra extension that provides oauth authentication to github. Find out more about enabling your application at github's oauth quickstart.

To test it out on localhost set your callback url to 'http://localhost:9393/auth/github/callback'

The gist of this project is to provide a few things easily:

  • authenticate a user against github's oauth service
  • provide an easy way to make API requests for the authenticated user
  • optionally restrict users to a specific github organization
  • optionally restrict users to a specific github team

Installation

% gem install sinatra_auth_github

Running the Example

% gem install bundler
% bundle install
% GITHUB_CLIENT_ID="<from GH>" GITHUB_CLIENT_SECRET="<from GH>" bundle exec rackup -p9393

There's an example app in spec/app.rb.

Example App Functionality

You can simply authenticate via GitHub by hitting http://localhost:9393

You can check organization membership by hitting http://localhost:9393/orgs/github

You can check team membership by hitting http://localhost:9393/teams/42

All unsuccessful authentication requests get sent to the securocat denied page.

API Access

The extension also provides a simple way to access the GitHub API, by providing an
authenticated Octokit::Client for the user.

def repos
  github_user.api.repositories
end

For more information on API access, refer to the octokit documentation.

Extension Options

  • :scopes - The OAuth2 scopes you require, Learn More
  • :secret - The client secret that GitHub provides
  • :client_id - The client id that GitHub provides
  • :failure_app - A Sinatra::Base class that has a route for /unauthenticated, Useful for overriding the securocat default page.
  • :callback_url - The path that GitHub posts back to, defaults to /auth/github/callback.

Enterprise Authentication

Under the hood, the warden-github portion is powered by octokit. If you find yourself wanting to connect to a GitHub Enterprise installation you'll need to export two environmental variables.

主要指標

概覽
名稱與所有者atmos/sinatra_auth_github
主編程語言Ruby
編程語言Ruby (語言數: 2)
平台
許可證MIT License
所有者活动
創建於2010-06-01 21:18:35
推送於2017-09-08 17:13:59
最后一次提交2017-09-08 10:13:44
發布數53
最新版本名稱v2.0.0 (發布於 )
第一版名稱v0.0.1 (發布於 )
用户参与
星數189
關注者數12
派生數51
提交數130
已啟用問題?
問題數0
打開的問題數0
拉請求數16
打開的拉請求數0
關閉的拉請求數2
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?