omniauth-citrix 0.1.0

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: a1e00d185eff9e179dfc7004e135ddcbf87e5a3e
4
+ data.tar.gz: 7bcc975fbd000470edc9d5062c79a3db19e2cf20
5
+ SHA512:
6
+ metadata.gz: bd3bddf77be05a429b719e4021cf78a0477301ced4f2c73a4e9e3ca90246791c9b269717028c54b1cf3f2f1b4d4808101346e3a220cdbd3c573d8576ed38095c
7
+ data.tar.gz: cb4a48e6625aff1a5d6e160cf644feb795cfab55a6606d65cafbbe6f01e81061df90b15e017eaacdb3419e935bbcd81d14543a04861a581d4e4f9594d33e687b
data/.gitignore ADDED
@@ -0,0 +1,22 @@
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
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.5
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-citrix.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Nando Vieira
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,39 @@
1
+ # Omniauth::Citrix
2
+
3
+ Citrix OAuth2 Strategy for OmniAuth.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'omniauth-citrix'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install omniauth-citrix
18
+
19
+ ## Usage
20
+
21
+ `OmniAuth::Strategies::Citrix` is simply a Rack middleware. Read the OmniAuth docs for detailed instructions: <https://github.com/intridea/omniauth>.
22
+
23
+ Here's a quick example, adding the middleware to a Rails app in `config/initializers/omniauth.rb`:
24
+
25
+ ```ruby
26
+ Rails.application.config.middleware.use OmniAuth::Builder do
27
+ provider :citrix, ENV['CITRIX_CONSUMER_KEY'], ENV['CITRIX_CONSUMER_SECRET']
28
+ end
29
+ ```
30
+
31
+ Now visit `/auth/citrix` to start authentication against Citrix.
32
+
33
+ ## Contributing
34
+
35
+ 1. Fork it ( https://github.com/fnando/omniauth-citrix/fork )
36
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
37
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
38
+ 4. Push to the branch (`git push origin my-new-feature`)
39
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+
@@ -0,0 +1,53 @@
1
+ require 'omniauth'
2
+ require 'omniauth-oauth2'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ class Citrix < OmniAuth::Strategies::OAuth2
7
+ option :client_options, {
8
+ authorize_url: 'https://api.citrixonline.com/oauth/authorize',
9
+ token_url: 'https://api.citrixonline.com/oauth/access_token'
10
+ }
11
+
12
+ option :provider_ignores_state, true
13
+
14
+ def authorize_params
15
+ {client_id: client.id}
16
+ end
17
+
18
+ def token_params
19
+ {
20
+ grant_type: 'authorization_code',
21
+ code: request.params['code'],
22
+ client_id: client.id
23
+ }
24
+ end
25
+
26
+ uid do
27
+ access_token.params['account_key']
28
+ end
29
+
30
+ info do
31
+ {
32
+ organizer_key: access_token.params['organizer_key'],
33
+ account_key: access_token.params['account_key'],
34
+ account_type: access_token.params['account_type'],
35
+ first_name: access_token.params['firstName'].strip,
36
+ last_name: access_token.params['lastName'].strip,
37
+ email: access_token.params['email'],
38
+ platform: access_token.params['platform']
39
+ }
40
+ end
41
+
42
+ protected
43
+
44
+ def build_access_token
45
+ client.auth_code.get_token(
46
+ request.params['code'],
47
+ {redirect_uri: callback_url}.merge(token_params),
48
+ deep_symbolize(options.auth_token_params)
49
+ )
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Citrix
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require 'omniauth-citrix/version'
2
+ require 'omniauth/strategies/citrix'
@@ -0,0 +1,23 @@
1
+ require './lib/omniauth-citrix/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = 'omniauth-citrix'
5
+ spec.version = Omniauth::Citrix::VERSION
6
+ spec.authors = ['Nando Vieira']
7
+ spec.email = ['fnando.vieira@gmail.com']
8
+ spec.summary = 'OmniAuth strategy for Citrix.'
9
+ spec.description = spec.summary
10
+ spec.homepage = 'https://github.com/fnando/omniauth-citrix'
11
+ spec.license = 'MIT'
12
+
13
+ spec.files = `git ls-files -z`.split("\x0")
14
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
15
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
16
+ spec.require_paths = ['lib']
17
+
18
+ spec.add_runtime_dependency 'omniauth-oauth2'
19
+ spec.add_development_dependency 'bundler'
20
+ spec.add_development_dependency 'rake'
21
+ spec.add_development_dependency 'rspec'
22
+ spec.add_development_dependency 'pry-meta'
23
+ end
@@ -0,0 +1,90 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::Citrix do
4
+ let(:app) { -> env {} }
5
+
6
+ subject(:strategy) do
7
+ OmniAuth::Strategies::Citrix.new(app, 'consumer_id', 'consumer_secret')
8
+ end
9
+
10
+ describe 'client options' do
11
+ it 'sets name' do
12
+ expect(strategy.options.name).to eq('citrix')
13
+ end
14
+
15
+ it 'sets authorize url' do
16
+ expect(strategy.options.client_options.authorize_url).to eq('https://api.citrixonline.com/oauth/authorize')
17
+ end
18
+
19
+ it 'sets token url' do
20
+ expect(strategy.options.client_options.token_url).to eq('https://api.citrixonline.com/oauth/access_token')
21
+ end
22
+
23
+ it 'ignores state' do
24
+ expect(strategy.options.provider_ignores_state).to be_truthy
25
+ end
26
+ end
27
+
28
+ describe '#authorize_params' do
29
+ it 'includes client id' do
30
+ expect(strategy.authorize_params).to include(client_id: 'consumer_id')
31
+ end
32
+ end
33
+
34
+ describe '#token_params' do
35
+ before do
36
+ request = double('request', params: {'code' => 'CODE'})
37
+ allow(strategy).to receive(:request).and_return(request)
38
+ end
39
+
40
+ it 'sets grant type' do
41
+ expect(strategy.token_params).to include(grant_type: 'authorization_code')
42
+ end
43
+
44
+ it 'sets code' do
45
+ expect(strategy.token_params).to include(code: 'CODE')
46
+ end
47
+
48
+ it 'sets client id' do
49
+ expect(strategy.token_params).to include(client_id: 'consumer_id')
50
+ end
51
+ end
52
+
53
+ describe '#uid' do
54
+ before do
55
+ access_token = double('access_token', {params: {
56
+ 'account_key' => 'ACCOUNT_KEY'
57
+ }})
58
+
59
+ allow(strategy).to receive(:access_token).and_return(access_token)
60
+ end
61
+
62
+ it 'returns uid' do
63
+ expect(strategy.uid).to eq('ACCOUNT_KEY')
64
+ end
65
+ end
66
+
67
+ describe '#info' do
68
+ before do
69
+ access_token = double('access_token', {params: {
70
+ 'account_key' => 'ACCOUNT_KEY',
71
+ 'organizer_key' => 'ORGANIZER_KEY',
72
+ 'firstName' => 'FIRST_NAME',
73
+ 'lastName' => 'LAST_NAME',
74
+ 'account_type' => 'ACCOUNT_TYPE',
75
+ 'email' => 'EMAIL',
76
+ 'platform' => 'PLATFORM'
77
+ }})
78
+
79
+ allow(strategy).to receive(:access_token).and_return(access_token)
80
+ end
81
+
82
+ it { expect(strategy.info[:account_key]).to eq('ACCOUNT_KEY') }
83
+ it { expect(strategy.info[:organizer_key]).to eq('ORGANIZER_KEY') }
84
+ it { expect(strategy.info[:first_name]).to eq('FIRST_NAME') }
85
+ it { expect(strategy.info[:last_name]).to eq('LAST_NAME') }
86
+ it { expect(strategy.info[:account_type]).to eq('ACCOUNT_TYPE') }
87
+ it { expect(strategy.info[:email]).to eq('EMAIL') }
88
+ it { expect(strategy.info[:platform]).to eq('PLATFORM') }
89
+ end
90
+ end
@@ -0,0 +1,2 @@
1
+ require 'bundler/setup'
2
+ require 'omniauth-citrix'
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-citrix
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Nando Vieira
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth-oauth2
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry-meta
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: OmniAuth strategy for Citrix.
84
+ email:
85
+ - fnando.vieira@gmail.com
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-citrix.rb
98
+ - lib/omniauth-citrix/version.rb
99
+ - lib/omniauth/strategies/citrix.rb
100
+ - omniauth-citrix.gemspec
101
+ - spec/omniauth/strategies/citrix_spec.rb
102
+ - spec/spec_helper.rb
103
+ homepage: https://github.com/fnando/omniauth-citrix
104
+ licenses:
105
+ - MIT
106
+ metadata: {}
107
+ post_install_message:
108
+ rdoc_options: []
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ requirements: []
122
+ rubyforge_project:
123
+ rubygems_version: 2.2.2
124
+ signing_key:
125
+ specification_version: 4
126
+ summary: OmniAuth strategy for Citrix.
127
+ test_files:
128
+ - spec/omniauth/strategies/citrix_spec.rb
129
+ - spec/spec_helper.rb