omniauth-vatsim 0.1.3

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: cd2adf8c01f5191152519f3d9d930856897bbb89
4
+ data.tar.gz: def59d5daf416be0919b0207dd5ec48f46c6def2
5
+ SHA512:
6
+ metadata.gz: 2685f37a0f81dfc9384bf2eaeb9aa58b0357f972a18298d9d8ea799cc99bcac355aa73b112983cf745b093db48b74d7508d6fdedc31d6ce076b9cf6f30a54239
7
+ data.tar.gz: ddb622943ddf633d66e99a310ca10535acafb66d0727fb456c707ed5f3c4fbcc7299ece826df2451492eb122c27ed73db9fe169ef9941e4940497e8d0172ed94
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.3
5
+ before_install: gem install bundler -v 1.13.7
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-vatsim.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Jonathan P. Voss
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all 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,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,119 @@
1
+ # OmniAuth VATSIM
2
+
3
+ OmniAuth::Strategies::Vatsim is an OmniAuth strategy for authenticating with
4
+ the VATSIM SSO with OAuth1.
5
+
6
+ Note: Currently only supports HMAC-SHA1 authentication
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'omniauth-vatsim'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install omniauth-vatsim
23
+
24
+ ## Usage
25
+
26
+ Add the strategy to your ```Gemfile```:
27
+
28
+ ```ruby
29
+ gem 'omniauth-vatsim'
30
+ ```
31
+
32
+ Or you can pull it directly from github:
33
+
34
+ ```ruby
35
+ gem 'omniauth-vatsim', git: 'https://github.com/jvoss/omniauth-vatsim.git'
36
+ ```
37
+
38
+ For a Rails application you can now create an initializer ```config/initializers/omniauth.rb```:
39
+
40
+ ```ruby
41
+ Rails.application.config.middleware.use OmniAuth::Builder do
42
+ provider :vatsim, 'app_id', 'app_secret', site: 'https://cert.vatsim.net/sso'
43
+ end
44
+ ```
45
+
46
+ For a Rails application using [Devise](https://github.com/plataformatec/devise), modify ```config/initializers/devise.rb```:
47
+
48
+ ```ruby
49
+ config.omniauth :vatsim, 'app_id', 'app_secret', client_options: {site: 'https://cert.vatsim.net/sso'}
50
+ ```
51
+
52
+ For Sinatra you would add:
53
+
54
+ ```ruby
55
+ use Rack::Session::Cookie
56
+ use OmniAuth::Builder do
57
+ provider :vatsim, 'api_id', 'api_secret', site: 'https://cert.vatsim.net/sso'
58
+ end
59
+ ```
60
+
61
+ ## Sample Auth Hash
62
+
63
+ ```
64
+ {
65
+ "provider"=>"vatsim",
66
+ "uid"=>"1300011",
67
+ "info"=>{
68
+ "id"=>"1300011",
69
+ "name_first"=>"11th",
70
+ "name_last"=>"Test",
71
+ "rating"=>{
72
+ "id"=>"11",
73
+ "short"=>"SUP",
74
+ "long"=>"Supervisor",
75
+ "GRP"=>"Supervisor"
76
+ },
77
+ "pilot_rating"=>{
78
+ "rating"=>"22",
79
+ "2"=>{
80
+ "id"=>2,
81
+ "short"=>"P2",
82
+ "long"=>"Flight Fundamentals"
83
+ },
84
+ "4"=>{
85
+ "id"=>4,
86
+ "short"=>"P3",
87
+ "long"=>"VFR Pilot"
88
+ },
89
+ "16"=>{
90
+ "id"=>16,
91
+ "short"=>"P5",
92
+ "long"=>"Advanced IFR Pilot"
93
+ }
94
+ },
95
+ "email"=>"noreply@vatsim.net",
96
+ "experience"=>"N",
97
+ "reg_date"=>"2014-05-14 17:17:26",
98
+ "country"=>{
99
+ "code"=>"GB", "name"=>"United Kingdom"
100
+ },
101
+ "region"=>{
102
+ "code"=>"EUR", "name"=>"Europe"
103
+ },
104
+ "division"=>{
105
+ "code"=>"GBR", "name"=>"United Kingdom"
106
+ },
107
+ "subdivision"=>{
108
+ "code"=>nil, "name"=>nil
109
+ }
110
+ }
111
+ ```
112
+
113
+ ## Contributing
114
+
115
+ Bug reports and pull requests are welcome on GitHub at https://github.com/jvoss/omniauth-vatsim.
116
+
117
+ ## License
118
+
119
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,70 @@
1
+ require 'omniauth-oauth'
2
+ require 'multi_json'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ class Vatsim < OmniAuth::Strategies::OAuth
7
+ option :name, 'vatsim'
8
+
9
+ option :client_options, {
10
+ site: 'http://sso.hardern.net/server', # default to demo site
11
+ authorize_path: '/auth/pre_login/?',
12
+ request_token_path: '/api/login_token',
13
+ access_token_path: '/api/login_return',
14
+ }
15
+
16
+ uid do
17
+ parse_callback['id']
18
+ end
19
+
20
+ info do
21
+ {
22
+ id: parse_callback['id'],
23
+ name_first: parse_callback['name_first'],
24
+ name_last: parse_callback['name_last'],
25
+ rating: parse_callback['rating'],
26
+ pilot_rating: parse_callback['pilot_rating'],
27
+ email: parse_callback['email'],
28
+ experience: parse_callback['experience'],
29
+ reg_date: parse_callback['reg_date'],
30
+ country: parse_callback['country'],
31
+ region: parse_callback['region'],
32
+ division: parse_callback['division'],
33
+ subdivision: parse_callback['subdivision']
34
+ }
35
+ end
36
+
37
+ # Parse the callback for user information
38
+ def parse_callback
39
+ MultiJson.decode(self.extra['access_token'].params.keys[1])['user']
40
+ end
41
+
42
+ # Customize the OAuth request phase to handle VATSIM SSO
43
+ def request_phase
44
+ request_token = consumer.get_request_token({oauth_callback: callback_url}, options.request_params) do |response_body|
45
+ # symbolize string keys returned by VATSIM SSO
46
+ MultiJson.decode(response_body)['token'].symbolize_keys
47
+ end
48
+
49
+ session['oauth'] ||= {}
50
+ session['oauth'][name.to_s] = {
51
+ 'callback_confirmed': request_token.callback_confirmed?,
52
+ 'request_token': request_token.token,
53
+ 'request_secret': request_token.secret
54
+ }
55
+
56
+ if request_token.callback_confirmed?
57
+ redirect request_token.authorize_url(options[:authorize_params])
58
+ else
59
+ redirect request_token.authorize_url(options[:authorize_params].merge(oauth_callback: callback_url))
60
+ end
61
+
62
+ rescue ::Timeout::Error => e
63
+ fail!(:timeout, e)
64
+ rescue ::Net::HTTPFatalError, ::OpenSSL::SSL::SSLError => e
65
+ fail!(:service_unavailable, e)
66
+ end # def request_phase
67
+
68
+ end # class Vatsim
69
+ end # module Strategies
70
+ end # module OmniAuth
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Vatsim
3
+ VERSION = "0.1.3"
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require 'omniauth-vatsim/version'
2
+ require 'omniauth/strategies/vatsim'
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'omniauth-vatsim/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "omniauth-vatsim"
8
+ spec.version = Omniauth::Vatsim::VERSION
9
+ spec.authors = ["Jonathan P. Voss"]
10
+ spec.email = ["jvoss@onvox.net"]
11
+
12
+ spec.summary = %q{OmniAuth strategy for VATSIM OAuth/SSO}
13
+ spec.description = %q{OmniAuth strategy for VATSIM OAuth/SSO}
14
+ spec.homepage = "https://github.com/jvoss/omniauth-vatsim"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_dependency 'multi_json', '~> 1.3'
25
+ spec.add_runtime_dependency 'omniauth-oauth', '~> 1.0'
26
+
27
+ spec.add_development_dependency "bundler", "~> 1.13"
28
+ spec.add_development_dependency "rake", "~> 10.0"
29
+ spec.add_development_dependency "rspec", "~> 3.0"
30
+ end
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-vatsim
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.3
5
+ platform: ruby
6
+ authors:
7
+ - Jonathan P. Voss
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-01-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: multi_json
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: omniauth-oauth
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.13'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.13'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ description: OmniAuth strategy for VATSIM OAuth/SSO
84
+ email:
85
+ - jvoss@onvox.net
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
93
+ - Gemfile
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - lib/omniauth-vatsim.rb
98
+ - lib/omniauth-vatsim/version.rb
99
+ - lib/omniauth/strategies/vatsim.rb
100
+ - omniauth-vatsim.gemspec
101
+ homepage: https://github.com/jvoss/omniauth-vatsim
102
+ licenses:
103
+ - MIT
104
+ metadata: {}
105
+ post_install_message:
106
+ rdoc_options: []
107
+ require_paths:
108
+ - lib
109
+ required_ruby_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ requirements: []
120
+ rubyforge_project:
121
+ rubygems_version: 2.4.1
122
+ signing_key:
123
+ specification_version: 4
124
+ summary: OmniAuth strategy for VATSIM OAuth/SSO
125
+ test_files: []