Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 60 lines (40 sloc) 2.178 kb
56ebb74 @atmos initial import of the sinatra extension to use github auth
authored
1 sinatra_auth_github
2 ===================
3
51a68fa @atmos adding a few docs
authored
4 A sinatra extension that provides oauth authentication to github. Find out more about enabling your application at github's [oauth quickstart](http://gist.github.com/419219).
56ebb74 @atmos initial import of the sinatra extension to use github auth
authored
5
b3f2ef0 @atmos doc fixups
authored
6 To test it out on localhost set your callback url to 'http://localhost:9393/auth/github/callback'
51a68fa @atmos adding a few docs
authored
7
b3f2ef0 @atmos doc fixups
authored
8 The gist of this project is to provide a few things easily:
9
10 * authenticate a user against github's oauth service
11 * provide an easy way to make API requests for the authenticated user
12 * optionally restrict users to a specific github organization
13 * optionally restrict users to a specific github team
51a68fa @atmos adding a few docs
authored
14
b3f2ef0 @atmos doc fixups
authored
15 Installation
16 ============
17
18 % gem install sinatra_auth_github
19
20 Running the Example
21 ===================
56ebb74 @atmos initial import of the sinatra extension to use github auth
authored
22 % gem install bundler
23 % bundle install
b3f2ef0 @atmos doc fixups
authored
24 % GITHUB_CLIENT_ID="<from GH>" GITHUB_CLIENT_SECRET="<from GH>" bundle exec rackup -p9393
dbe019d @atmos enable restricting to organization and team members
authored
25
b3f2ef0 @atmos doc fixups
authored
26 There's an example app in [spec/app.rb](/atmos/sinatra_auth_github/blob/master/spec/app.rb).
dbe019d @atmos enable restricting to organization and team members
authored
27
b3f2ef0 @atmos doc fixups
authored
28 Example App Functionality
29 =========================
dbe019d @atmos enable restricting to organization and team members
authored
30
b3f2ef0 @atmos doc fixups
authored
31 You can simply authenticate via GitHub by hitting http://localhost:9292
dbe019d @atmos enable restricting to organization and team members
authored
32
b3f2ef0 @atmos doc fixups
authored
33 You can check organization membership by hitting http://localhost:9292/orgs/github
dbe019d @atmos enable restricting to organization and team members
authored
34
b3f2ef0 @atmos doc fixups
authored
35 You can check team membership by hitting http://localhost:9292/teams/42
dbe019d @atmos enable restricting to organization and team members
authored
36
b3f2ef0 @atmos doc fixups
authored
37 All unsuccessful authentication requests get sent to the securocat denied page.
dbe019d @atmos enable restricting to organization and team members
authored
38
b3f2ef0 @atmos doc fixups
authored
39 API Requests
40 ============
dbe019d @atmos enable restricting to organization and team members
authored
41
b3f2ef0 @atmos doc fixups
authored
42 The extension also provides a simple way to do get requests against the
43 GitHub API as the authenticated user.
dbe019d @atmos enable restricting to organization and team members
authored
44
b3f2ef0 @atmos doc fixups
authored
45 def repos
469b0b8 @atmos link to v3 api docs and use correct api
authored
46 github_request("user/repos")
dbe019d @atmos enable restricting to organization and team members
authored
47 end
48
469b0b8 @atmos link to v3 api docs and use correct api
authored
49 There's awesome docs on the v3 API [available here](http://developer.github.com/v3/).
50
b3f2ef0 @atmos doc fixups
authored
51 Extension Options
52 =================
53
54 * `:scopes` - The OAuth2 scopes you require, [Learn More](http://gist.github.com/419219)
55 * `:secret` - The client secret that GitHub provides
56 * `:client_id` - The client id that GitHub provides
dacec23 @vinbarnes correct unauthenticated route in extension options section
vinbarnes authored
57 * `:failure_app` - A Sinatra::Base class that has a route for `/unauthenticated`, Useful for overriding the securocat default page.
b3f2ef0 @atmos doc fixups
authored
58 * `:callback_url` - The path that GitHub posts back to, defaults to `/auth/github/callback`.
39ff84a @atmos configurable oauth endpoints for local testing
authored
59 * `:oauth_domain` - The scheme and host that's GitHub's endpoint, defaults to `https://github.com`
Something went wrong with that request. Please try again.