chairman 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/LICENSE +20 -0
  2. data/README.md +4 -0
  3. data/lib/chairman.rb +44 -0
  4. data/lib/version.rb +3 -0
  5. metadata +80 -0
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Jed Foster
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,4 @@
1
+ Chairman
2
+ ========
3
+
4
+ GitHub authentication for Sinatra
data/lib/chairman.rb ADDED
@@ -0,0 +1,44 @@
1
+ require 'sinatra/base'
2
+ require 'github_api'
3
+
4
+ module Chairman
5
+ class << self
6
+ attr_reader :session, :client_id, :client_secret, :scope
7
+
8
+ def config(client_id, client_secret, scope)
9
+ @client_id = client_id
10
+ @client_secret = client_secret
11
+ @scope = scope
12
+ end
13
+
14
+ def session(auth_token = '')
15
+ @session = Github.new do |config|
16
+ config.client_id = @client_id
17
+ config.client_secret = @client_secret
18
+ config.oauth_token = auth_token
19
+ end
20
+ end
21
+ end
22
+
23
+ class Routes < Sinatra::Base
24
+ get '/authorize' do
25
+ redirect to Chairman.session.authorize_url :scope => Chairman.scope
26
+ end
27
+
28
+ get '/authorize/return' do
29
+ token = Chairman.session.get_token(params[:code])
30
+
31
+ @user = Chairman.session(token.token).users.get
32
+
33
+ session[:github_token] = token.token
34
+ session[:github_id] = @user.login
35
+ session[:gravatar_id] = @user.gravatar_id
36
+ end
37
+
38
+ get '/logout' do
39
+ session[:github_token] = nil
40
+ session[:github_id] = nil
41
+ session[:gravatar_id] = nil
42
+ end
43
+ end
44
+ end
data/lib/version.rb ADDED
@@ -0,0 +1,3 @@
1
+ module Chairman
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: chairman
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jed Foster
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-08-11 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: sinatra
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 1.4.3
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 1.4.3
30
+ - !ruby/object:Gem::Dependency
31
+ name: github_api
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 0.10.2
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 0.10.2
46
+ description: GitHub authentication routes and tools for Sinatra apps
47
+ email: jed@jedfoster.com
48
+ executables: []
49
+ extensions: []
50
+ extra_rdoc_files: []
51
+ files:
52
+ - README.md
53
+ - LICENSE
54
+ - lib/chairman.rb
55
+ - lib/version.rb
56
+ homepage: https://github.com/jedfoster/Chairman
57
+ licenses: []
58
+ post_install_message:
59
+ rdoc_options: []
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ! '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ! '>='
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ requirements: []
75
+ rubyforge_project:
76
+ rubygems_version: 1.8.23
77
+ signing_key:
78
+ specification_version: 3
79
+ summary: GitHub authentication for Sinatra
80
+ test_files: []