cf-uaac 4.3.0 → 4.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8ec28aaefed5216eceb8c2665fd861167475f4b02202c0f7a432ded556374b02
4
- data.tar.gz: aa68a4e5bdced51b1a049f8cad96237eec7784c596dfc51f77de0c5dd0a3fdc8
3
+ metadata.gz: 9b0ccc68333fba77918370b92678e803a339d2efd0bf80415f06a469015f69ca
4
+ data.tar.gz: 15fd888cb1d7beeb64df62f9393a6d148daa76377e8af02eb9b531b43b39afe5
5
5
  SHA512:
6
- metadata.gz: f5e0299e7af1702bd5ec78da39eb6d731a1eda5d1458c5ff564f6a0b141877ee9e84351fa107984719c77be3e49ca4323967222ddff7dc08f8e24daa74f725dc
7
- data.tar.gz: 19999aa17a59d217da5e01cdef536834d4b10529a4bc860b5ddbdac07637336ebf594b5d18e18dd93256b2cdb3607067ea283c8f687d679c75c627391721f545
6
+ metadata.gz: 6f37d4c1122288ebad48fdc0612c1263a8eebcedca8a12e467ca2b625bddf0cf5136fe11511e085a8f8f0ca6a03bc4283a2b580e30a79b626c13779d4888355b
7
+ data.tar.gz: f22f6149a3b769a9b3428def9568091a2f9cac5a99042c9c9a9bce76e9fc5984849fa1393ca3966f9e81952abac84c4b35f66b70f9a8c89a599de371cad6049e
@@ -0,0 +1,26 @@
1
+ name: Ruby
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ test:
11
+
12
+ runs-on: ubuntu-latest
13
+ strategy:
14
+ fail-fast: false
15
+ matrix:
16
+ ruby-version: ['2.5', '2.7', '3.0', '3.1']
17
+
18
+ steps:
19
+ - uses: actions/checkout@v2
20
+ - name: Set up Ruby
21
+ uses: ruby/setup-ruby@v1
22
+ with:
23
+ ruby-version: ${{ matrix.ruby-version }}
24
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
25
+ - name: Run tests
26
+ run: bundle exec rake cov
data/README.md CHANGED
@@ -1,8 +1,13 @@
1
1
  # CloudFoundry UAA Command Line Client
2
2
 
3
- [![Build Status](https://travis-ci.org/cloudfoundry/cf-uaac.svg?branch=master)](https://travis-ci.org/cloudfoundry/cf-uaac)
3
+ ![Build status](https://github.com/cloudfoundry/cf-uaac/actions/workflows/ruby.yml/badge.svg)
4
4
  [![Gem Version](https://badge.fury.io/rb/cf-uaac.png)](https://rubygems.org/gems/cf-uaac)
5
5
 
6
+ ## Operating system compatibility
7
+
8
+ The `uaac` CLI is tested on Linux and Mac OS, and is supported on these systems.
9
+ It is not tested or supported on Windows, though it has been known to work at some point.
10
+
6
11
  ## Installation
7
12
 
8
13
  From Rubygems:
@@ -17,6 +22,24 @@ gem build cf-uaac.gemspec
17
22
  gem install cf-uaac*.gem
18
23
  ```
19
24
 
25
+ ### Troubleshooting possible installation issues
26
+
27
+ You may encounter some errors when building native extentions of the required
28
+ Gems. We redirect you to the documentation of those Gem dependencies, as many
29
+ different compilation/linking issue may occur.
30
+
31
+ Typical issues with x86 Darwin systems (i.e. macOS) may involve the following
32
+ `cflags` and `ldflags` options, for the `bundler` Gem to properly build the
33
+ required Gems native extensions. You should not use them blindly without
34
+ knowing what you're doing. If you don't want persistent workarounds in your
35
+ Bundler config, those settings can also be passed to one-off `gem install`
36
+ invocations. Please refer to `gem help install` and `man bundle-config`.
37
+
38
+ ```
39
+ bundle config build.eventmachine --with-cflags="-fms-extensions"
40
+ bundle config build.mysql2 --with-ldflags="-L/usr/local/opt/openssl@1.1/lib"
41
+ bundle config build.thin --with-cflags="-fms-extensions -Wno-error=implicit-function-declaration"
42
+ ```
20
43
 
21
44
  ## Concepts
22
45
 
@@ -35,6 +58,11 @@ Now that UAAC has your token, you're able to run commands and hit the endpoints
35
58
 
36
59
  To use the APIs, see: https://github.com/cloudfoundry/cf-uaa-lib
37
60
 
61
+ ### Caveats in connecting
62
+
63
+ When necessary, the `--skip-ssl-validation` flag should be used once only,
64
+ along with the `uaac target` invocation. See `uaac target -h`.
65
+
38
66
 
39
67
  ## Creating clients
40
68
 
@@ -67,4 +95,4 @@ export UAA_CLIENT_ID="admin"
67
95
  export UAA_CLIENT_SECRET="adminsecret"
68
96
  export UAA_CLIENT_TARGET="http://localhost:8080/uaa"
69
97
  bundle exec rake test
70
- ```
98
+ ```
data/cf-uaac.gemspec CHANGED
@@ -24,8 +24,6 @@ Gem::Specification.new do |s|
24
24
  s.summary = %q{Command line interface for CloudFoundry UAA}
25
25
  s.description = %q{Client command line tools for interacting with the CloudFoundry User Account and Authorization (UAA) server. The UAA is an OAuth2 Authorization Server so it can be used by webapps and command line apps to obtain access tokens to act on behalf of users. The tokens can then be used to access protected resources in a Resource Server. This library can be used by clients (as a convenient wrapper for mainstream oauth gems) or by resource servers.}
26
26
 
27
- s.rubyforge_project = 'cf-uaac'
28
-
29
27
  s.license = 'Apache-2.0'
30
28
  s.files = `git ls-files`.split("\n")
31
29
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -33,13 +31,14 @@ Gem::Specification.new do |s|
33
31
  s.require_paths = ['lib']
34
32
 
35
33
  # dependencies
36
- s.add_runtime_dependency 'cf-uaa-lib', '~> 3.11'
34
+ s.add_runtime_dependency 'cf-uaa-lib', '~> 4.0'
37
35
  s.add_development_dependency 'rake', '>= 10.3.1', '~> 13.0'
38
36
  s.add_development_dependency 'rspec', '>= 2.14.1', '~> 3.9'
39
37
  s.add_development_dependency 'simplecov', '~> 0.21.2'
40
- s.add_development_dependency 'simplecov-rcov', '~> 0.2.3'
41
- s.add_development_dependency 'ci_reporter', '~> 1.9', '>= 1.9.2'
42
- s.add_runtime_dependency 'highline', '~> 1.6', '>= 1.6.21'
38
+ s.add_development_dependency 'simplecov-rcov', '~> 0.3.0'
39
+ s.add_development_dependency 'ci_reporter', '>= 1.9.2', '~> 2.0'
40
+ s.add_development_dependency 'ci_reporter_rspec', '~> 1.0'
41
+ s.add_runtime_dependency 'highline', '~> 2.0'
43
42
  s.add_runtime_dependency 'eventmachine', '~> 1.0', '>= 1.0.3'
44
43
  s.add_runtime_dependency 'launchy', '~> 2.4', '>= 2.4.2'
45
44
  s.add_runtime_dependency 'em-http-request', '~> 1.1', '>= 1.1.2'
data/lib/uaa/cli/base.rb CHANGED
@@ -14,6 +14,7 @@
14
14
  require 'highline'
15
15
  require 'optparse'
16
16
  require 'json/pure'
17
+ require 'io/console'
17
18
 
18
19
  module CF; module UAA end end
19
20
 
@@ -65,7 +66,7 @@ class Topic
65
66
 
66
67
  def terminal_columns
67
68
  return @terminal_columns ||= 0 if @terminal_columns || !@output.tty?
68
- cols = HighLine::SystemExtensions.terminal_size.first rescue 0
69
+ cols = IO.console.winsize.last rescue 0 if $stdin.tty?
69
70
  @terminal_columns = !cols || cols < 40 ? 0 : cols
70
71
  end
71
72
 
@@ -28,6 +28,8 @@ class ClientCli < CommonCli
28
28
  :refresh_token_validity => 'seconds',
29
29
  :redirect_uri => 'list',
30
30
  :autoapprove => 'list',
31
+ :allowpublic => 'list',
32
+ :allowedproviders => 'list',
31
33
  :'signup_redirect_url' => 'url'
32
34
  }
33
35
  CLIENT_SCHEMA.each { |k, v| define_option(k, "--#{k} <#{v}>") }
@@ -45,12 +47,15 @@ class ClientCli < CommonCli
45
47
  info[k] = opts[:interact] ?
46
48
  info[k] = askd("#{k.to_s.gsub('_', ' ')} (#{p})", default): default
47
49
  end
48
- if k == :autoapprove && (info[k] == 'true' || info[k] == 'false')
50
+ if (k == :autoapprove || k == :allowpublic) && (info[k] == 'true' || info[k] == 'false')
49
51
  info[k] = !!(info[k] == 'true')
50
52
  else
51
53
  info[k] = Util.arglist(info[k]) if p == 'list'
52
54
  info.delete(k) unless info[k]
53
55
  end
56
+ if opts.key?(k) && k == :allowedproviders && (info[k].join('') == 'all' || info[k].join('') == 'null' || info[k].join('') == 'nil')
57
+ info[:allowedproviders] = nil
58
+ end
54
59
  end
55
60
  end
56
61
 
@@ -31,7 +31,7 @@ class CommonCli < Topic
31
31
 
32
32
  def username(name); name || ask("User name") end
33
33
  def userpwd(pwd = opts[:password]); pwd || ask_pwd("Password") end
34
- def passcode(passcode = opts[:passcode]); passcode || ask("Passcode (from #{Config.target}/passcode)") end
34
+ def passcode(passcode = opts[:passcode]); passcode || ask("Passcode ( from #{Config.target}/passcode )") end
35
35
  def clientid(id = opts[:client]); id || ask("Client ID") end
36
36
  def clientsecret(secret = opts[:secret]); secret || ask_pwd("Client secret") end
37
37
  def clientname(name = opts[:name]); name end
@@ -186,7 +186,8 @@ class MiscCli < CommonCli
186
186
  define_option :ca_cert, "--ca-cert [file]", "use the given CA certificate to validate the target's SSL certificate"
187
187
  define_option :skip_ssl_validation, "--skip-ssl-validation", "do not attempt to validate ssl certificate"
188
188
  define_option :force, "--[no-]force", "-f", "set even if target does not respond"
189
- desc "target [uaa_url]", "Display current or set new target", :force, :ca_cert, :skip_ssl_validation do |uaa_url|
189
+ define_option :basic_auth, "--[no-]basic_auth", "set if you need basic or oauth2 (url encoded) client authentication"
190
+ desc "target [uaa_url]", "Display current or set new target", :force, :ca_cert, :skip_ssl_validation, :basic_auth do |uaa_url|
190
191
  msg, info = nil, {}
191
192
  if uaa_url
192
193
  if uaa_url.to_i.to_s == uaa_url
@@ -204,6 +205,8 @@ class MiscCli < CommonCli
204
205
  Config.target = url # we now have a canonical url set to https if possible
205
206
  Config.target_opts(skip_ssl_validation: true) if opts[:skip_ssl_validation]
206
207
  Config.target_opts(ca_cert: opts[:ca_cert])
208
+ Config.target_opts(basic_auth: true) if opts[:basic_auth] == true
209
+ Config.target_opts(basic_auth: false) if opts[:basic_auth] == false
207
210
  update_target_info(info) if info[:prompts]
208
211
  end
209
212
  return say "no target set" unless Config.target
data/lib/uaa/cli/info.rb CHANGED
@@ -47,10 +47,6 @@ class InfoCli < CommonCli
47
47
  pp info
48
48
  end
49
49
 
50
- desc "stats", "Show UAA's current usage statistics", :client, :secret do
51
- pp misc_request { @cli_class.uaa_info_client.varz(clientid, clientsecret) }
52
- end
53
-
54
50
  desc "password strength [password]", "calculate strength score of a password" do |pwd|
55
51
  pp misc_request { @cli_class.uaa_info_client.password_strength(userpwd(pwd)) }
56
52
  end
data/lib/uaa/cli/token.rb CHANGED
@@ -25,6 +25,7 @@ class TokenCatcher < Stub::Base
25
25
  secret = server.info.delete(:client_secret)
26
26
  ti = TokenIssuer.new(Config.target, server.info.delete(:client_id), secret,
27
27
  { token_target: Config.target_value(:token_target),
28
+ basic_auth: Config.target_value(:basic_auth),
28
29
  skip_ssl_validation: Config.target_value(:skip_ssl_validation)})
29
30
  tkn = secret ? ti.authcode_grant(server.info.delete(:uri), data) :
30
31
  ti.implicit_grant(server.info.delete(:uri), data)
@@ -88,8 +89,9 @@ class TokenCli < CommonCli
88
89
 
89
90
  def issuer_request(client_id, secret = nil)
90
91
  update_target_info
91
- yield TokenIssuer.new(Config.target.to_s, CGI.escape(client_id), CGI.escape(secret),
92
+ yield TokenIssuer.new(Config.target.to_s, client_id, secret,
92
93
  { token_target: Config.target_value(:token_endpoint),
94
+ basic_auth: Config.target_value(:basic_auth),
93
95
  skip_ssl_validation: Config.target_value(:skip_ssl_validation),
94
96
  ssl_ca_file: Config.target_value(:ca_cert) })
95
97
  rescue Exception => e
data/lib/uaa/cli/user.rb CHANGED
@@ -19,12 +19,12 @@ class UserCli < CommonCli
19
19
 
20
20
  topic 'User Accounts', 'account'
21
21
 
22
+ define_option :origin, '--origin <name>, select user to update by identity provider origin. Defaults to UAA'
22
23
  define_option :givenName, '--given_name <name>'
23
24
  define_option :familyName, '--family_name <name>'
24
25
  define_option :emails, '--emails <addresses>'
25
26
  define_option :phoneNumbers, '--phones <phone_numbers>'
26
- define_option :origin, '--origin <identity provider origin, defaults to UAA>'
27
- USER_INFO_OPTS = [:givenName, :familyName, :emails, :phoneNumbers, :origin]
27
+ USER_INFO_OPTS = [:origin, :givenName, :familyName, :emails, :phoneNumbers]
28
28
 
29
29
  def user_opts(info = {})
30
30
  [:emails, :phoneNumbers].each do |o|
data/lib/uaa/stub/scim.rb CHANGED
@@ -65,7 +65,7 @@ class StubScim
65
65
  :authorizations, :groups].to_set,
66
66
  client: [*COMMON_ATTRS, :client_id, :name, :client_secret, :authorities,
67
67
  :authorized_grant_types, :scope, :autoapprove,
68
- :access_token_validity, :refresh_token_validity, :redirect_uri,
68
+ :access_token_validity, :refresh_token_validity, :redirect_uri, :allowedproviders,
69
69
  :'signup_redirect_url'].to_set,
70
70
  group: [*COMMON_ATTRS, :displayname, :members, :writers, :readers, :external_groups].to_set }
71
71
  VISIBLE_ATTRS = {user: Set.new(LEGAL_ATTRS[:user] - HIDDEN_ATTRS),
@@ -58,8 +58,8 @@ describe ClientCli do
58
58
  end
59
59
 
60
60
  it 'does not wrap the output of the access token in the terminal' do
61
- @output.stub(:tty?) { true }
62
- HighLine::SystemExtensions.stub(:terminal_size) { [80] }
61
+ allow(@output).to receive(:tty?).and_return(true)
62
+ allow(IO.console).to receive(:winsize).and_return([40, 80])
63
63
  Cli.run('context').should be
64
64
  Cli.output.string.should match /access_token: \S+?\s+token_type/m
65
65
  end
data/spec/common_spec.rb CHANGED
@@ -44,7 +44,7 @@ describe CommonCli do
44
44
 
45
45
  it "displays user help with -h has --origin option" do
46
46
  Cli.run("user -h")
47
- Cli.output.string.should include("--origin <identity provider origin, defaults to UAA>")
47
+ Cli.output.string.should include("--origin <name>, select user to update by identity provider origin. Defaults to UAA")
48
48
  end
49
49
 
50
50
  it "displays group help with -h has --origin option" do
data/spec/info_spec.rb CHANGED
@@ -53,11 +53,6 @@ describe InfoCli do
53
53
  Cli.output.string.should include "score", "requiredScore"
54
54
  end
55
55
 
56
- it "gets the server stats" do
57
- pending "no UAA_VARZ_SECRET environment variable set" unless @varz_secret
58
- Cli.run("stats -c varz -s #{@varz_secret}").should be
59
- Cli.output.string.should include 'type: UAA', 'mem:', 'version:'
60
- end
61
56
 
62
57
  it "sets multiple targets to be fully qualified in config and targets output" do
63
58
  Config.load("")
data/spec/spec_helper.rb CHANGED
@@ -26,6 +26,12 @@ require 'rspec'
26
26
  require 'eventmachine'
27
27
  require 'uaa/stub/uaa'
28
28
 
29
+ RSpec.configure do |config|
30
+ config.expect_with :rspec do |expectations|
31
+ expectations.syntax = [:expect, :should]
32
+ end
33
+ end
34
+
29
35
  module CF::UAA
30
36
 
31
37
  module SpecHelper
data/spec/user_spec.rb CHANGED
@@ -69,7 +69,7 @@ describe UserCli do
69
69
  Cli.input = StringIO.new("password") # selecting first origin through stdin
70
70
  Cli.run("user add #{user_with_origin} " +
71
71
  '--emails sam@example.com --given_name SamueL ' +
72
- "--phones 801-555-1212 --family_name jonES --origin uaa").should be
72
+ "--phones 801-555-1212 --family_name jonES --origin uaa")
73
73
 
74
74
  expect(Cli.output.string).to match 'Password:'
75
75
  Cli.run("user delete #{user_with_origin}")
@@ -80,7 +80,7 @@ describe UserCli do
80
80
  Cli.input = StringIO.new("password") # selecting first origin through stdin
81
81
  Cli.run("user add #{user_with_origin} " +
82
82
  '--emails sam@example.com --given_name SamueL ' +
83
- "--phones 801-555-1212 --family_name jonES").should be
83
+ "--phones 801-555-1212 --family_name jonES")
84
84
 
85
85
  expect(Cli.output.string).to match 'Password:'
86
86
  Cli.run("user delete #{user_with_origin}")
data/version.txt CHANGED
@@ -1 +1 @@
1
- 4.3.0
1
+ 4.6.0
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cf-uaac
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.3.0
4
+ version: 4.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Syer
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2021-10-27 00:00:00.000000000 Z
15
+ date: 2022-07-28 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: cf-uaa-lib
@@ -20,14 +20,14 @@ dependencies:
20
20
  requirements:
21
21
  - - "~>"
22
22
  - !ruby/object:Gem::Version
23
- version: '3.11'
23
+ version: '4.0'
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
27
27
  requirements:
28
28
  - - "~>"
29
29
  - !ruby/object:Gem::Version
30
- version: '3.11'
30
+ version: '4.0'
31
31
  - !ruby/object:Gem::Dependency
32
32
  name: rake
33
33
  requirement: !ruby/object:Gem::Requirement
@@ -88,54 +88,62 @@ dependencies:
88
88
  requirements:
89
89
  - - "~>"
90
90
  - !ruby/object:Gem::Version
91
- version: 0.2.3
91
+ version: 0.3.0
92
92
  type: :development
93
93
  prerelease: false
94
94
  version_requirements: !ruby/object:Gem::Requirement
95
95
  requirements:
96
96
  - - "~>"
97
97
  - !ruby/object:Gem::Version
98
- version: 0.2.3
98
+ version: 0.3.0
99
99
  - !ruby/object:Gem::Dependency
100
100
  name: ci_reporter
101
101
  requirement: !ruby/object:Gem::Requirement
102
102
  requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: 1.9.2
103
106
  - - "~>"
104
107
  - !ruby/object:Gem::Version
105
- version: '1.9'
108
+ version: '2.0'
109
+ type: :development
110
+ prerelease: false
111
+ version_requirements: !ruby/object:Gem::Requirement
112
+ requirements:
106
113
  - - ">="
107
114
  - !ruby/object:Gem::Version
108
115
  version: 1.9.2
116
+ - - "~>"
117
+ - !ruby/object:Gem::Version
118
+ version: '2.0'
119
+ - !ruby/object:Gem::Dependency
120
+ name: ci_reporter_rspec
121
+ requirement: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - "~>"
124
+ - !ruby/object:Gem::Version
125
+ version: '1.0'
109
126
  type: :development
110
127
  prerelease: false
111
128
  version_requirements: !ruby/object:Gem::Requirement
112
129
  requirements:
113
130
  - - "~>"
114
131
  - !ruby/object:Gem::Version
115
- version: '1.9'
116
- - - ">="
117
- - !ruby/object:Gem::Version
118
- version: 1.9.2
132
+ version: '1.0'
119
133
  - !ruby/object:Gem::Dependency
120
134
  name: highline
121
135
  requirement: !ruby/object:Gem::Requirement
122
136
  requirements:
123
137
  - - "~>"
124
138
  - !ruby/object:Gem::Version
125
- version: '1.6'
126
- - - ">="
127
- - !ruby/object:Gem::Version
128
- version: 1.6.21
139
+ version: '2.0'
129
140
  type: :runtime
130
141
  prerelease: false
131
142
  version_requirements: !ruby/object:Gem::Requirement
132
143
  requirements:
133
144
  - - "~>"
134
145
  - !ruby/object:Gem::Version
135
- version: '1.6'
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: 1.6.21
146
+ version: '2.0'
139
147
  - !ruby/object:Gem::Dependency
140
148
  name: eventmachine
141
149
  requirement: !ruby/object:Gem::Requirement
@@ -257,8 +265,8 @@ extensions: []
257
265
  extra_rdoc_files: []
258
266
  files:
259
267
  - ".github/dependabot.yml"
268
+ - ".github/workflows/ruby.yml"
260
269
  - ".gitignore"
261
- - ".travis.yml"
262
270
  - ".yardopts"
263
271
  - Gemfile
264
272
  - LICENSE
data/.travis.yml DELETED
@@ -1,10 +0,0 @@
1
- language: ruby
2
-
3
- before_install:
4
- - gem update
5
- - gem install bundler
6
-
7
- rvm:
8
- - 2.7
9
- - 2.6
10
- - 2.5