sinatra_auth_github 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -54,5 +54,5 @@ Extension Options
54
54
  * `:scopes` - The OAuth2 scopes you require, [Learn More](http://gist.github.com/419219)
55
55
  * `:secret` - The client secret that GitHub provides
56
56
  * `:client_id` - The client id that GitHub provides
57
- * `:failure_app` - A Sinatra::Base class that has a route for `/authenticated`, Useful for overriding the securocat default page.
57
+ * `:failure_app` - A Sinatra::Base class that has a route for `/unauthenticated`, Useful for overriding the securocat default page.
58
58
  * `:callback_url` - The path that GitHub posts back to, defaults to `/auth/github/callback`.
@@ -5,7 +5,7 @@ require 'rest_client'
5
5
  module Sinatra
6
6
  module Auth
7
7
  module Github
8
- VERSION = "0.1.2"
8
+ VERSION = "0.1.5"
9
9
 
10
10
  # Simple way to serve an image early in the stack and not get blocked by
11
11
  # application level before filters
@@ -79,7 +79,7 @@ module Sinatra
79
79
  # Returns a parsed JSON response
80
80
  #
81
81
  # Examples
82
- # github_raw_request("/user")
82
+ # github_request("/user")
83
83
  # # => { 'login' => 'atmos', ... }
84
84
  def github_request(path)
85
85
  JSON.parse(github_raw_request(path))
@@ -101,7 +101,7 @@ module Sinatra
101
101
  #
102
102
  # name - the organization name
103
103
  #
104
- # Returns: true if the uesr has access, false otherwise
104
+ # Returns: true if the user has access, false otherwise
105
105
  def github_organization_access?(name)
106
106
  orgs = github_request("orgs/#{name}/members")
107
107
  orgs.map { |org| org["login"] }.include?(github_user.login)
@@ -113,7 +113,7 @@ module Sinatra
113
113
  #
114
114
  # team_id - the team's id
115
115
  #
116
- # Returns: true if the uesr has access, false otherwise
116
+ # Returns: true if the user has access, false otherwise
117
117
  def github_team_access?(team_id)
118
118
  members = github_request("teams/#{team_id}/members")
119
119
  members.map { |user| user["login"] }.include?(github_user.login)
@@ -164,7 +164,7 @@ module Sinatra
164
164
  manager.failure_app = app.github_options[:failure_app] || BadAuthentication
165
165
 
166
166
  manager[:github_secret] = app.github_options[:secret] || ENV['GITHUB_CLIENT_SECRET']
167
- manager[:github_scopes] = app.github_options[:scopes] || 'email,offline_access'
167
+ manager[:github_scopes] = app.github_options[:scopes] || ''
168
168
  manager[:github_client_id] = app.github_options[:client_id] || ENV['GITHUB_CLIENT_ID']
169
169
  manager[:github_callback_url] = app.github_options[:callback_url] || '/auth/github/callback'
170
170
  end
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "sinatra_auth_github"
6
- s.version = "0.1.4"
6
+ s.version = "0.1.5"
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["Corey Donohoe"]
9
9
  s.email = ["atmos@atmos.org"]
data/spec/app.rb CHANGED
@@ -7,8 +7,7 @@ module Example
7
7
  set :github_options, {
8
8
  :secret => ENV['GITHUB_CLIENT_SECRET'],
9
9
  :client_id => ENV['GITHUB_CLIENT_ID'],
10
- :scopes => 'user,offline_access,repo' # repo is need for org auth :\
11
- }
10
+ }
12
11
 
13
12
  register Sinatra::Auth::Github
14
13
 
@@ -24,14 +23,15 @@ module Example
24
23
  end
25
24
 
26
25
  get '/orgs/:id' do
27
- github_organization_authenticate!(params['id'])
26
+ github_public_organization_authenticate!(params['id'])
28
27
  "Hello There, #{github_user.name}! You have access to the #{params['id']} organization."
29
28
  end
30
29
 
31
- get '/teams/:id' do
32
- github_team_authenticate!(params['id'])
33
- "Hello There, #{github_user.name}! You have access to the #{params['id']} team."
34
- end
30
+ # the scopes above need to include repo for team access :(
31
+ # get '/teams/:id' do
32
+ # github_team_authenticate!(params['id'])
33
+ # "Hello There, #{github_user.name}! You have access to the #{params['id']} team."
34
+ # end
35
35
 
36
36
  get '/logout' do
37
37
  logout!
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra_auth_github
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 4
10
- version: 0.1.4
9
+ - 5
10
+ version: 0.1.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Corey Donohoe
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-20 00:00:00 -07:00
18
+ date: 2011-10-27 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency