github_employee_auth 0.9.1

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/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ vendor
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in github_employee_auth.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,6 @@
1
+ guard 'rspec', :version => 2 do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
4
+ watch('spec/spec_helper.rb') { "spec" }
5
+ end
6
+
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Corey Donohoe
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # GithubEmployeeAuth
2
+
3
+ This is what you should be using if you're writing internal applications
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'github_employee_auth'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install github_employee_auth
18
+
19
+ ## Usage
20
+
21
+ ```ruby
22
+ require "github_employee_auth"
23
+
24
+ class InternalApp < Sinatra::Base
25
+ register GitHub::Employee::Auth
26
+
27
+ get "/"
28
+ github_employee_auth!
29
+ end
30
+ end
31
+
32
+ ```
33
+
34
+ ## Contributing
35
+
36
+ 1. Fork it
37
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
38
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
39
+ 4. Push to the branch (`git push origin my-new-feature`)
40
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
data/example/config.ru ADDED
@@ -0,0 +1,26 @@
1
+ require 'pp'
2
+ $:.push(File.dirname(__FILE__) + "/../lib")
3
+
4
+ require "github_employee_auth"
5
+
6
+ module Example
7
+ class App < Sinatra::Base
8
+ enable :sessions
9
+
10
+ register GitHub::Employee::Auth
11
+
12
+ get '/' do
13
+ github_employee_auth!
14
+ "Hello there, #{github_user.login}, you work at GitHub!"
15
+ end
16
+
17
+ get '/logout' do
18
+ logout!
19
+ redirect 'https://github.com'
20
+ end
21
+ end
22
+ end
23
+
24
+ app = Example::App
25
+
26
+ run app
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/github_employee_auth/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Corey Donohoe"]
6
+ gem.email = ["atmos@atmos.org"]
7
+ gem.description = %q{make it even easier to build internal apps}
8
+ gem.summary = %q{authenticate github employees easily in sinatra apps}
9
+ gem.homepage = "https://github.com/atmos/github_employee_auth"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "github_employee_auth"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = GithubEmployeeAuth::VERSION
17
+
18
+ gem.add_dependency "rack-ssl"
19
+ gem.add_dependency "sinatra_auth_github", "~>0.5.4"
20
+
21
+ gem.add_development_dependency "guard"
22
+ gem.add_development_dependency "rspec", "~>2.0"
23
+ gem.add_development_dependency "rack-test"
24
+ gem.add_development_dependency "ruby-debug"
25
+ end
@@ -0,0 +1,32 @@
1
+ require 'sinatra/auth/github/test/test_helper'
2
+
3
+ module GitHub
4
+ module Employee
5
+ module Auth
6
+ module TestHelper
7
+ include Sinatra::Auth::Github::Test::Helper
8
+
9
+ class Employee < Sinatra::Auth::Github::Test::Helper::User
10
+ def team_member?(id)
11
+ if id == 135235
12
+ true
13
+ else
14
+ super(id)
15
+ end
16
+ end
17
+ def organization_member?(org_name)
18
+ if id == 'github'
19
+ true
20
+ else
21
+ super(org_name)
22
+ end
23
+ end
24
+ end
25
+
26
+ def make_employee(attrs = {})
27
+ Employee.new(attrs)
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,3 @@
1
+ module GithubEmployeeAuth
2
+ VERSION = "0.9.1"
3
+ end
@@ -0,0 +1,26 @@
1
+ require "github_employee_auth/version"
2
+
3
+ require 'sinatra/auth/github'
4
+
5
+ module GitHub
6
+ module Employee
7
+ module Auth
8
+ module Helpers
9
+ include Sinatra::Auth::Github::Helpers
10
+ def github_employee_auth!
11
+ github_team_authenticate!(135235)
12
+ end
13
+
14
+ def github_employee_request(path)
15
+ github_request(path)
16
+ end
17
+ end
18
+
19
+ def self.registered(app)
20
+ app.register(Sinatra::Auth::Github)
21
+ app.helpers(Helpers)
22
+ app.set(:github_options, {:scopes => "user"})
23
+ end
24
+ end
25
+ end
26
+ end
data/spec/auth_spec.rb ADDED
@@ -0,0 +1,21 @@
1
+ require "spec_helper"
2
+
3
+ describe "Logged in users" do
4
+ before do
5
+ @user = make_user('login' => 'coda')
6
+ @employee = make_employee('login' => 'defunkt')
7
+ end
8
+
9
+ it "does not allow non github employee's" do
10
+ login_as @user
11
+ get "/"
12
+ last_response.status.should == 403
13
+ end
14
+
15
+ it "allow's github employee team access" do
16
+ login_as @employee
17
+
18
+ get "/"
19
+ last_response.body.should == "Hello there, defunkt! You work for GitHub!"
20
+ end
21
+ end
@@ -0,0 +1,37 @@
1
+ $:.unshift "lib"
2
+ require "github_employee_auth"
3
+ require "github_employee_auth/test_helper"
4
+
5
+ require "rspec"
6
+ require "rspec/expectations"
7
+ require "rspec/mocks"
8
+ require "rack/test"
9
+ require "ruby-debug"
10
+
11
+ class TestApp < Sinatra::Base
12
+ enable :sessions
13
+ enable :raise_errors
14
+ disable :show_exceptions
15
+
16
+ register GitHub::Employee::Auth
17
+
18
+ get "/" do
19
+ github_employee_auth!
20
+ "Hello there, #{github_user.login}! You work for GitHub!"
21
+ end
22
+ end
23
+
24
+ RSpec.configure do |config|
25
+ config.expect_with :stdlib
26
+ config.alias_example_to :test
27
+
28
+ config.include Rack::Test::Methods
29
+ config.include GitHub::Employee::Auth::TestHelper
30
+
31
+ def app
32
+ TestApp
33
+ end
34
+
35
+ config.before(:all) do
36
+ end
37
+ end
metadata ADDED
@@ -0,0 +1,167 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: github_employee_auth
3
+ version: !ruby/object:Gem::Version
4
+ hash: 57
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 9
9
+ - 1
10
+ version: 0.9.1
11
+ platform: ruby
12
+ authors:
13
+ - Corey Donohoe
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-05-31 00:00:00 -07:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rack-ssl
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: sinatra_auth_github
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ - 5
47
+ - 4
48
+ version: 0.5.4
49
+ type: :runtime
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: guard
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ hash: 3
60
+ segments:
61
+ - 0
62
+ version: "0"
63
+ type: :development
64
+ version_requirements: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ name: rspec
67
+ prerelease: false
68
+ requirement: &id004 !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ~>
72
+ - !ruby/object:Gem::Version
73
+ hash: 3
74
+ segments:
75
+ - 2
76
+ - 0
77
+ version: "2.0"
78
+ type: :development
79
+ version_requirements: *id004
80
+ - !ruby/object:Gem::Dependency
81
+ name: rack-test
82
+ prerelease: false
83
+ requirement: &id005 !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ hash: 3
89
+ segments:
90
+ - 0
91
+ version: "0"
92
+ type: :development
93
+ version_requirements: *id005
94
+ - !ruby/object:Gem::Dependency
95
+ name: ruby-debug
96
+ prerelease: false
97
+ requirement: &id006 !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ hash: 3
103
+ segments:
104
+ - 0
105
+ version: "0"
106
+ type: :development
107
+ version_requirements: *id006
108
+ description: make it even easier to build internal apps
109
+ email:
110
+ - atmos@atmos.org
111
+ executables: []
112
+
113
+ extensions: []
114
+
115
+ extra_rdoc_files: []
116
+
117
+ files:
118
+ - .gitignore
119
+ - Gemfile
120
+ - Guardfile
121
+ - LICENSE
122
+ - README.md
123
+ - Rakefile
124
+ - example/config.ru
125
+ - github_employee_auth.gemspec
126
+ - lib/github_employee_auth.rb
127
+ - lib/github_employee_auth/test_helper.rb
128
+ - lib/github_employee_auth/version.rb
129
+ - spec/auth_spec.rb
130
+ - spec/spec_helper.rb
131
+ has_rdoc: true
132
+ homepage: https://github.com/atmos/github_employee_auth
133
+ licenses: []
134
+
135
+ post_install_message:
136
+ rdoc_options: []
137
+
138
+ require_paths:
139
+ - lib
140
+ required_ruby_version: !ruby/object:Gem::Requirement
141
+ none: false
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ hash: 3
146
+ segments:
147
+ - 0
148
+ version: "0"
149
+ required_rubygems_version: !ruby/object:Gem::Requirement
150
+ none: false
151
+ requirements:
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ hash: 3
155
+ segments:
156
+ - 0
157
+ version: "0"
158
+ requirements: []
159
+
160
+ rubyforge_project:
161
+ rubygems_version: 1.6.2
162
+ signing_key:
163
+ specification_version: 3
164
+ summary: authenticate github employees easily in sinatra apps
165
+ test_files:
166
+ - spec/auth_spec.rb
167
+ - spec/spec_helper.rb