omniauth-uaa-oauth2 0.0.7 → 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9a489cbe8839c4e742091c3513b60fd0f768d3b049b1b7e6e33ef1016882a9a4
4
- data.tar.gz: 208380d605c1c83f3f9ee5b7dd3bcd812e589a01b87c9fb770ccfacd344094b6
3
+ metadata.gz: 9e8de9c63b6c5f6302ff2188fcb99045128f8af146d6014c8a0e26403e23e7b0
4
+ data.tar.gz: 995fc9391a8e7c91d6464adc34565a825f7c6853877e4b1467326043e38aeb21
5
5
  SHA512:
6
- metadata.gz: fc2ac39ff8d9b63c6ce3e9e653c5292521b396472197c8936cf41297d4b949d90bd11057c8e6a0e5eef19a1ff1e8676b742f6e8d66ba760be7977c136cdffd2a
7
- data.tar.gz: 28a719a09fc4f45c433ff38da8c87d54363c1d57040857dfcf228c58afe8560404d69082c1854ab8aeae2319fb7fdb1234677c0e2ca34f464cd2d55adf75a271
6
+ metadata.gz: 85a906769d31270b17cf11c0ee1c9f2f905ff7fe2d36d7024a522ffb3d2da756714854f8e3ff71b237944ab11794dbf60161ca44d115986c8c05732a57a3ae0c
7
+ data.tar.gz: 88982fdba7d3fc827a892bf0fc3317e8261ce7fd1b2d0cd94c9c7730d8d6c9b157bbe6d2f88b1c2d1e82f99dc52fad7c67d0ae0d5767c0689e60162a2633a1b6
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
1
  *.swp
2
2
  *.swo
3
3
  *.gem
4
+ Gemfile.lock
data/.travis.yml CHANGED
@@ -1,7 +1,12 @@
1
1
  language: ruby
2
2
 
3
- rvm:
4
- - 1.9.3
3
+ before_install:
4
+ - gem update
5
+ - gem install bundler
5
6
 
7
+ rvm:
8
+ - 2.3.7
9
+ - 2.4.4
10
+ - 2.5.1
6
11
 
7
12
 
data/Gemfile CHANGED
@@ -13,7 +13,7 @@
13
13
 
14
14
  source 'http://rubygems.org'
15
15
 
16
- gem 'cf-uaa-lib', '~> 3.2.4'
16
+ gem 'rake', '< 11.0'
17
17
 
18
18
  gemspec
19
19
 
data/README.md CHANGED
@@ -3,28 +3,18 @@ CloudFoundry UAA OmniAuth Strategy
3
3
 
4
4
  OmniAuth strategy for authenticating users using the CloudFoundry UAA server.
5
5
 
6
- Set up a local ruby environment (so sudo not required):
6
+ Add the following to your `Gemfile`:
7
7
 
8
- $ rvm use 1.9.2
8
+ ```text
9
+ gem 'omniauth-uaa-oauth2'
10
+ ```
9
11
 
10
- or
12
+ For example usage see:
11
13
 
12
- $ rbenv global 1.9.2-p180
14
+ * the `examples/config.ru` sample code
15
+ * https://github.com/starkandwayne/ultimate-guide-to-uaa-examples/tree/master/ruby/omniauth-login-only
16
+ * https://github.com/starkandwayne/ultimate-guide-to-uaa-examples/tree/master/ruby/omniauth-login-and-uaa-api-calls
17
+ * https://github.com/starkandwayne/ultimate-guide-to-uaa-examples/tree/master/ruby/resource-server-wrapper-ui
13
18
 
14
- see: https://rvm.io/ or http://rbenv.org/
15
-
16
- Build and install the cf-uaa-lib gem located at https://github.com/cloudfoundry/cf-uaa-lib
17
-
18
- Build the gem
19
-
20
- $ bundle install
21
- $ bundle exec gem build omniauth-uaa-oauth2.gemspec
22
-
23
- Install it
24
-
25
- $ gem install omniauth-uaa-oauth2-*.gem
26
-
27
-
28
- See the examples folder for details on how to use it.
29
19
 
30
20
  Warning: Unlike the omniauth-oauth2 gem, this gem does not support the oauth2 'state' security parameter.
data/examples/config.ru CHANGED
@@ -1,16 +1,3 @@
1
- #--
2
- # Cloud Foundry 2012.02.03 Beta
3
- # Copyright (c) [2009-2012] VMware, Inc. All Rights Reserved.
4
- #
5
- # This product is licensed to you under the Apache License, Version 2.0 (the "License").
6
- # You may not use this product except in compliance with the License.
7
- #
8
- # This product includes a number of subcomponents with
9
- # separate copyright notices and license terms. Your use of these
10
- # subcomponents is subject to the terms and conditions of the
11
- # subcomponent's license, as noted in the LICENSE file.
12
- #++
13
-
14
1
  # Run with "bundle exec rackup"
15
2
 
16
3
  require 'rubygems'
@@ -32,7 +19,7 @@ class App < Sinatra::Base
32
19
  content_type 'application/json'
33
20
  request.env['omniauth.auth'].to_hash.to_json rescue "No Data"
34
21
  end
35
-
22
+
36
23
  get '/auth/failure' do
37
24
  content_type 'text/plain'
38
25
  request.env['omniauth.auth'].to_hash.inspect rescue "No Data"
@@ -1,14 +1 @@
1
- #--
2
- # Cloud Foundry 2012.02.03 Beta
3
- # Copyright (c) [2009-2012] VMware, Inc. All Rights Reserved.
4
- #
5
- # This product is licensed to you under the Apache License, Version 2.0 (the "License").
6
- # You may not use this product except in compliance with the License.
7
- #
8
- # This product includes a number of subcomponents with
9
- # separate copyright notices and license terms. Your use of these
10
- # subcomponents is subject to the terms and conditions of the
11
- # subcomponent's license, as noted in the LICENSE file.
12
- #++
13
-
14
1
  require 'omniauth/strategies/cloudfoundry'
@@ -1,16 +1,3 @@
1
- #--
2
- # Cloud Foundry 2012.02.03 Beta
3
- # Copyright (c) [2009-2012] VMware, Inc. All Rights Reserved.
4
- #
5
- # This product is licensed to you under the Apache License, Version 2.0 (the "License").
6
- # You may not use this product except in compliance with the License.
7
- #
8
- # This product includes a number of subcomponents with
9
- # separate copyright notices and license terms. Your use of these
10
- # subcomponents is subject to the terms and conditions of the
11
- # subcomponent's license, as noted in the LICENSE file.
12
- #++
13
-
14
1
  require 'uaa'
15
2
  require 'omniauth'
16
3
  require 'timeout'
@@ -48,6 +35,8 @@ module OmniAuth
48
35
  option :scope, nil
49
36
  option :async_calls, false
50
37
  option :skip_ssl_validation, false
38
+ option :ssl_ca_file, nil
39
+ option :ssl_cert_store, nil
51
40
 
52
41
  attr_accessor :access_token
53
42
  attr_reader :token_issuer
@@ -78,8 +67,10 @@ module OmniAuth
78
67
  options.client_id,
79
68
  options.client_secret,
80
69
  {
81
- :token_target => @token_server_url,
82
- :skip_ssl_validation => options.skip_ssl_validation
70
+ token_target: @token_server_url,
71
+ ssl_ca_file: options.ssl_ca_file,
72
+ ssl_cert_store: options.ssl_cert_store,
73
+ skip_ssl_validation: options.skip_ssl_validation
83
74
  })
84
75
  log :info, "Client: #{options.client_id} auth_server: #{@auth_server_url} token_server: #{@token_server_url}"
85
76
  @token_issuer.logger = OmniAuth.logger
@@ -91,7 +82,9 @@ module OmniAuth
91
82
  def uaa_info
92
83
  @uaa_info ||= CF::UAA::Info.new(
93
84
  @token_server_url,
94
- :skip_ssl_validation => options.skip_ssl_validation
85
+ ssl_ca_file: options.ssl_ca_file,
86
+ ssl_cert_store: options.ssl_cert_store,
87
+ skip_ssl_validation: options.skip_ssl_validation
95
88
  )
96
89
  end
97
90
 
@@ -144,10 +137,10 @@ module OmniAuth
144
137
 
145
138
  info do
146
139
  prune!({
147
- :name => raw_info["name"],
148
- :email => raw_info["email"],
149
- :first_name => raw_info["given_name"],
150
- :last_name => raw_info["family_name"]
140
+ name: raw_info["name"],
141
+ email: raw_info["email"],
142
+ first_name: raw_info["given_name"],
143
+ last_name: raw_info["family_name"]
151
144
  })
152
145
  end
153
146
 
@@ -187,7 +180,8 @@ module OmniAuth
187
180
 
188
181
  def expired?(access_token)
189
182
  access_token = access_token.auth_header if access_token.respond_to? :auth_header
190
- expiry = CF::UAA::TokenCoder.decode(access_token.split()[1], nil, nil, false)[:expires_at]
183
+ # Don't need to verify signature of token if we're just inspecting its expiry date
184
+ expiry = CF::UAA::TokenCoder.decode(access_token.split()[1], verify: false, symbolize_keys: true)[:expires_at]
191
185
  expiry.is_a?(Integer) && expiry <= Time.now.to_i
192
186
  end
193
187
 
@@ -1,18 +1,5 @@
1
- #--
2
- # Cloud Foundry 2012.02.03 Beta
3
- # Copyright (c) [2009-2012] VMware, Inc. All Rights Reserved.
4
- #
5
- # This product is licensed to you under the Apache License, Version 2.0 (the "License").
6
- # You may not use this product except in compliance with the License.
7
- #
8
- # This product includes a number of subcomponents with
9
- # separate copyright notices and license terms. Your use of these
10
- # subcomponents is subject to the terms and conditions of the
11
- # subcomponent's license, as noted in the LICENSE file.
12
- #++
13
-
14
1
  module OmniAuth
15
2
  module Cloudfoundry
16
- VERSION = "0.0.7"
3
+ VERSION = "1.0.0"
17
4
  end
18
5
  end
@@ -1,14 +1 @@
1
- #--
2
- # Cloud Foundry 2012.02.03 Beta
3
- # Copyright (c) [2009-2012] VMware, Inc. All Rights Reserved.
4
- #
5
- # This product is licensed to you under the Apache License, Version 2.0 (the "License").
6
- # You may not use this product except in compliance with the License.
7
- #
8
- # This product includes a number of subcomponents with
9
- # separate copyright notices and license terms. Your use of these
10
- # subcomponents is subject to the terms and conditions of the
11
- # subcomponent's license, as noted in the LICENSE file.
12
- #++
13
-
14
1
  require "omniauth/cloudfoundry"
@@ -1,17 +1,4 @@
1
1
  # -*- encoding: utf-8 -*-
2
- #
3
- # Cloud Foundry 2012.02.03 Beta
4
- # Copyright (c) [2009-2012] VMware, Inc. All Rights Reserved.
5
- #
6
- # This product is licensed to you under the Apache License, Version 2.0 (the "License").
7
- # You may not use this product except in compliance with the License.
8
- #
9
- # This product includes a number of subcomponents with
10
- # separate copyright notices and license terms. Your use of these
11
- # subcomponents is subject to the terms and conditions of the
12
- # subcomponent's license, as noted in the LICENSE file.
13
- #
14
-
15
2
  require File.expand_path('../lib/omniauth/uaa_oauth2/version', __FILE__)
16
3
 
17
4
  Gem::Specification.new do |gem|
@@ -31,21 +31,21 @@ describe OmniAuth::Strategies::Cloudfoundry do
31
31
 
32
32
  describe 'set auth and token server' do
33
33
  it 'should set the right auth and token server' do
34
- @options = {:auth_server_url => 'https://login.cloudfoundry.com'}
34
+ @options = {auth_server_url: 'https://login.cloudfoundry.com'}
35
35
  subject.client
36
36
  subject.auth_server_url.should eq('https://login.cloudfoundry.com')
37
37
  subject.token_server_url.should eq('https://login.cloudfoundry.com')
38
38
  end
39
39
 
40
40
  it 'should set the right auth and token server if independently set' do
41
- @options = {:auth_server_url => 'https://login.cloudfoundry.com', :token_server_url => 'https://uaa.cloudfoundry.com'}
41
+ @options = {auth_server_url: 'https://login.cloudfoundry.com', token_server_url: 'https://uaa.cloudfoundry.com'}
42
42
  subject.client
43
43
  subject.auth_server_url.should eq('https://login.cloudfoundry.com')
44
44
  subject.token_server_url.should eq('https://uaa.cloudfoundry.com')
45
45
  end
46
46
 
47
47
  it 'should set the right auth and token server' do
48
- @options = {:auth_server_url => 'login.cloudfoundry.com'}
48
+ @options = {auth_server_url: 'login.cloudfoundry.com'}
49
49
  subject.client
50
50
  subject.auth_server_url.should eq('https://login.cloudfoundry.com')
51
51
  subject.token_server_url.should eq('https://login.cloudfoundry.com')
@@ -111,13 +111,13 @@ describe OmniAuth::Strategies::Cloudfoundry do
111
111
 
112
112
  describe 'set scopes' do
113
113
  it 'should set the right scopes if requested' do
114
- @options = {:auth_server_url => 'https://login.cloudfoundry.com', :token_server_url => 'https://uaa.cloudfoundry.com', :scope => "openid cloud_controller.read"}
114
+ @options = {auth_server_url: 'https://login.cloudfoundry.com', token_server_url: 'https://uaa.cloudfoundry.com', :scope => "openid cloud_controller.read"}
115
115
  subject.client
116
116
  subject.options[:scope].should eq("openid cloud_controller.read")
117
117
  end
118
118
 
119
119
  it 'should not set any scopes if not requested' do
120
- @options = {:auth_server_url => 'https://login.cloudfoundry.com', :token_server_url => 'https://uaa.cloudfoundry.com'}
120
+ @options = {auth_server_url: 'https://login.cloudfoundry.com', token_server_url: 'https://uaa.cloudfoundry.com'}
121
121
  subject.client
122
122
  subject.options[:scope].should eq(nil)
123
123
  end
@@ -211,4 +211,15 @@ describe OmniAuth::Strategies::Cloudfoundry do
211
211
  subject.build_access_token('query-string').should be_empty
212
212
  end
213
213
  end
214
+
215
+ describe '#expired?' do
216
+ it 'sets params correctly on TokenCoder#decode' do
217
+ subject.access_token = OmniAuth::Strategies::CFAccessToken.new
218
+ CF::UAA::TokenCoder.should_receive(:decode)
219
+ .with(subject.access_token.auth_header.split()[1], verify: false, symbolize_keys: true)
220
+ .and_return({expires_at: 12345})
221
+
222
+ subject.expired?(subject.access_token)
223
+ end
224
+ end
214
225
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-uaa-oauth2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel D'sa
@@ -90,7 +90,6 @@ files:
90
90
  - ".gitignore"
91
91
  - ".travis.yml"
92
92
  - Gemfile
93
- - Gemfile.lock
94
93
  - LICENSE
95
94
  - NOTICE
96
95
  - README.md
data/Gemfile.lock DELETED
@@ -1,48 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- omniauth-uaa-oauth2 (0.0.7)
5
- cf-uaa-lib (>= 3.2, < 4.0)
6
- omniauth (~> 1.0)
7
-
8
- GEM
9
- remote: http://rubygems.org/
10
- specs:
11
- cf-uaa-lib (3.2.4)
12
- multi_json
13
- diff-lcs (1.1.3)
14
- hashie (3.5.7)
15
- multi_json (1.11.2)
16
- omniauth (1.4.2)
17
- hashie (>= 1.2, < 4)
18
- rack (>= 1.0, < 3)
19
- rack (1.4.1)
20
- rack-protection (1.2.0)
21
- rack
22
- rake (0.9.2.2)
23
- rspec (2.6.0)
24
- rspec-core (~> 2.6.0)
25
- rspec-expectations (~> 2.6.0)
26
- rspec-mocks (~> 2.6.0)
27
- rspec-core (2.6.4)
28
- rspec-expectations (2.6.0)
29
- diff-lcs (~> 1.1.2)
30
- rspec-mocks (2.6.0)
31
- sinatra (1.3.3)
32
- rack (~> 1.3, >= 1.3.6)
33
- rack-protection (~> 1.2)
34
- tilt (~> 1.3, >= 1.3.3)
35
- tilt (1.3.3)
36
-
37
- PLATFORMS
38
- ruby
39
-
40
- DEPENDENCIES
41
- cf-uaa-lib (~> 3.2.4)
42
- omniauth-uaa-oauth2!
43
- rake
44
- rspec (~> 2.6.0)
45
- sinatra
46
-
47
- BUNDLED WITH
48
- 1.16.2