bosh-director 1.3000.0 → 1.3001.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bosh/director/api/controllers/info_controller.rb +1 -1
- data/lib/bosh/director/api/extensions/scoping.rb +7 -2
- data/lib/bosh/director/api/local_identity_provider.rb +11 -17
- data/lib/bosh/director/api/uaa_identity_provider.rb +37 -24
- data/lib/bosh/director/api/user/config_user_manager.rb +4 -24
- data/lib/bosh/director/api/user/database_user_manager.rb +10 -11
- data/lib/bosh/director/jobs/export_release.rb +19 -3
- data/lib/bosh/director/version.rb +1 -1
- metadata +21 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91ee041025021bd6951468bb3b7ddade9cfbd156
|
4
|
+
data.tar.gz: 88e4bbd9f8d8ace47039dc90ca417f993973b9e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c1c17476af49745d5ec1f2b2ca1753c2af6fac762ffe8e7e4fa089e36e9f957a503f381a4fea17c42d8d8d4cffe27a7f48975e73c85eba124f159c217b1843d
|
7
|
+
data.tar.gz: 43f25613d07eb8adacc947eb4f9073fcf3727b0636582bf00942ab918ef7013674103c1245477fc72c3dd09679d479ddd94d84fff0578b2691588ae35b5da354
|
@@ -34,9 +34,14 @@ module Bosh::Director
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
if (@user.nil? ||
|
37
|
+
if requires_authentication? && (@user.nil? || !identity_provider.valid_access?(@user, scope))
|
38
38
|
response['WWW-Authenticate'] = 'Basic realm="BOSH Director"'
|
39
|
-
|
39
|
+
if @user.nil?
|
40
|
+
message = "Not authorized\n"
|
41
|
+
else
|
42
|
+
message = "Not authorized: #{request.path} requires one of the scopes: #{identity_provider.required_scopes(scope).join(", ")}\n"
|
43
|
+
end
|
44
|
+
throw(:halt, [401, message])
|
40
45
|
end
|
41
46
|
end
|
42
47
|
end
|
@@ -21,30 +21,24 @@ module Bosh
|
|
21
21
|
def get_user(request_env)
|
22
22
|
auth ||= Rack::Auth::Basic::Request.new(request_env)
|
23
23
|
raise AuthenticationError unless auth.provided? && auth.basic? && auth.credentials
|
24
|
-
|
25
|
-
|
26
|
-
password = auth.credentials[1]
|
27
|
-
LocalUser.new(@user_manager, username, password)
|
28
|
-
else
|
24
|
+
|
25
|
+
unless @user_manager.authenticate(*auth.credentials)
|
29
26
|
raise AuthenticationError
|
30
27
|
end
|
31
|
-
end
|
32
28
|
|
33
|
-
|
34
|
-
|
35
|
-
attr_reader :username
|
29
|
+
LocalUser.new(*auth.credentials)
|
30
|
+
end
|
36
31
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
@password = password
|
41
|
-
end
|
32
|
+
def valid_access?(user, _)
|
33
|
+
@user_manager.authenticate(user.username, user.password)
|
34
|
+
end
|
42
35
|
|
43
|
-
|
44
|
-
|
45
|
-
end
|
36
|
+
def required_scopes(_)
|
37
|
+
raise NotImplemented
|
46
38
|
end
|
47
39
|
end
|
40
|
+
|
41
|
+
class LocalUser < Struct.new(:username, :password); end
|
48
42
|
end
|
49
43
|
end
|
50
44
|
end
|
@@ -27,47 +27,60 @@ module Bosh
|
|
27
27
|
def get_user(request_env)
|
28
28
|
auth_header = request_env['HTTP_AUTHORIZATION']
|
29
29
|
token = @token_coder.decode(auth_header)
|
30
|
-
UaaUser.new(token
|
30
|
+
UaaUser.new(token)
|
31
31
|
rescue CF::UAA::DecodeError, CF::UAA::AuthError => e
|
32
32
|
raise AuthenticationError, e.message
|
33
33
|
end
|
34
|
-
end
|
35
34
|
|
36
|
-
|
35
|
+
def valid_access?(user, requested_access)
|
36
|
+
if user.scopes
|
37
|
+
required_scopes = required_scopes(requested_access)
|
38
|
+
return has_admin_scope?(user.scopes) || contains_requested_scope?(required_scopes, user.scopes)
|
39
|
+
end
|
37
40
|
|
38
|
-
|
41
|
+
false
|
42
|
+
end
|
39
43
|
|
40
|
-
def
|
41
|
-
|
42
|
-
@director_uuid = director_uuid
|
44
|
+
def required_scopes(requested_access)
|
45
|
+
permissions[requested_access]
|
43
46
|
end
|
44
47
|
|
45
|
-
|
46
|
-
|
48
|
+
private
|
49
|
+
|
50
|
+
def permissions
|
51
|
+
{
|
52
|
+
:read => ['bosh.admin', "bosh.#{@director_uuid}.admin", 'bosh.read', "bosh.#{@director_uuid}.read"],
|
53
|
+
:write => ['bosh.admin', "bosh.#{@director_uuid}.admin"]
|
54
|
+
}
|
47
55
|
end
|
48
56
|
|
49
|
-
def
|
50
|
-
|
51
|
-
|
52
|
-
return true
|
53
|
-
end
|
57
|
+
def has_admin_scope?(token_scopes)
|
58
|
+
!(intersect(permissions[:write], token_scopes).empty?)
|
59
|
+
end
|
54
60
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
61
|
+
def contains_requested_scope?(valid_scopes, token_scopes)
|
62
|
+
return false unless valid_scopes
|
63
|
+
!(intersect(valid_scopes, token_scopes).empty?)
|
64
|
+
end
|
59
65
|
|
60
|
-
|
66
|
+
def intersect(valid_scopes, token_scopes)
|
67
|
+
valid_scopes & token_scopes
|
61
68
|
end
|
69
|
+
end
|
62
70
|
|
63
|
-
|
71
|
+
class UaaUser
|
72
|
+
attr_reader :token
|
73
|
+
|
74
|
+
def initialize(token)
|
75
|
+
@token = token
|
76
|
+
end
|
64
77
|
|
65
|
-
def
|
66
|
-
|
78
|
+
def username
|
79
|
+
@token['user_name'] || @token['client_id']
|
67
80
|
end
|
68
81
|
|
69
|
-
def
|
70
|
-
|
82
|
+
def scopes
|
83
|
+
@token['scope']
|
71
84
|
end
|
72
85
|
end
|
73
86
|
end
|
@@ -11,22 +11,13 @@ module Bosh::Director
|
|
11
11
|
false
|
12
12
|
end
|
13
13
|
|
14
|
-
# @param [String] name User name
|
15
|
-
def find_by_name(name)
|
16
|
-
user = @users.find { |u| u['name'] == name }
|
17
|
-
if user.nil?
|
18
|
-
raise UserNotFound, "User `#{name}' doesn't exist"
|
19
|
-
end
|
20
|
-
User.new(user)
|
21
|
-
end
|
22
|
-
|
23
14
|
def authenticate(username, password)
|
24
15
|
return false if username.empty? || password.empty?
|
25
16
|
|
26
|
-
user =
|
27
|
-
user.
|
28
|
-
|
29
|
-
|
17
|
+
user = @users.find { |u| u['name'] == username }
|
18
|
+
return false if user.nil?
|
19
|
+
|
20
|
+
user['password'] == password
|
30
21
|
end
|
31
22
|
|
32
23
|
def delete_user(_)
|
@@ -45,16 +36,5 @@ module Bosh::Director
|
|
45
36
|
raise NotSupported
|
46
37
|
end
|
47
38
|
end
|
48
|
-
|
49
|
-
private
|
50
|
-
|
51
|
-
class User
|
52
|
-
attr_reader :username, :password
|
53
|
-
|
54
|
-
def initialize(options)
|
55
|
-
@username = options.fetch('name')
|
56
|
-
@password = options.fetch('password')
|
57
|
-
end
|
58
|
-
end
|
59
39
|
end
|
60
40
|
end
|
@@ -3,17 +3,6 @@
|
|
3
3
|
module Bosh::Director
|
4
4
|
module Api
|
5
5
|
class DatabaseUserManager
|
6
|
-
|
7
|
-
# @param [String] name User name
|
8
|
-
# @return [Models::User] User
|
9
|
-
def find_by_name(name)
|
10
|
-
user = Models::User[:username => name]
|
11
|
-
if user.nil?
|
12
|
-
raise UserNotFound, "User `#{name}' doesn't exist"
|
13
|
-
end
|
14
|
-
user
|
15
|
-
end
|
16
|
-
|
17
6
|
def supports_api_update?
|
18
7
|
true
|
19
8
|
end
|
@@ -59,6 +48,16 @@ module Bosh::Director
|
|
59
48
|
|
60
49
|
private
|
61
50
|
|
51
|
+
# @param [String] name User name
|
52
|
+
# @return [Models::User] User
|
53
|
+
def find_by_name(name)
|
54
|
+
user = Models::User[:username => name]
|
55
|
+
if user.nil?
|
56
|
+
raise UserNotFound, "User `#{name}' doesn't exist"
|
57
|
+
end
|
58
|
+
user
|
59
|
+
end
|
60
|
+
|
62
61
|
# Saves user in DB and handles validation errors.
|
63
62
|
# @param [Models::User]
|
64
63
|
# @return [void]
|
@@ -13,13 +13,29 @@ module Bosh::Director
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def initialize(deployment_name, release_name, release_version, stemcell_os, stemcell_version, options = {})
|
16
|
-
|
17
|
-
|
16
|
+
@deployment_name = deployment_name
|
17
|
+
@release_name = release_name
|
18
|
+
@release_version = release_version
|
19
|
+
@stemcell_os = stemcell_os
|
20
|
+
@stemcell_version = stemcell_version
|
18
21
|
end
|
19
22
|
|
23
|
+
|
20
24
|
# @return [void]
|
21
25
|
def perform
|
22
|
-
logger.info("
|
26
|
+
logger.info("Exporting release: #{@release_name}/#{@release_version} for #{@stemcell_os}/#{@stemcell_version}")
|
27
|
+
|
28
|
+
release = Bosh::Director::Models::Release.find(:name => @release_name)
|
29
|
+
if release.nil?
|
30
|
+
raise ReleaseNotFound
|
31
|
+
end
|
32
|
+
|
33
|
+
matching_versions = release.versions_dataset.where(:version => @release_version).all
|
34
|
+
if matching_versions.empty?
|
35
|
+
raise ReleaseVersionNotFound
|
36
|
+
end
|
37
|
+
|
38
|
+
logger.info "!!!RELEASE: #{release.pretty_inspect}"
|
23
39
|
end
|
24
40
|
end
|
25
41
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bosh-director
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3001.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- VMware
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bcrypt-ruby
|
@@ -30,126 +30,126 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.
|
33
|
+
version: 1.3001.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.
|
40
|
+
version: 1.3001.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bosh-core
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.
|
47
|
+
version: 1.3001.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.
|
54
|
+
version: 1.3001.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: bosh-director-core
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.
|
61
|
+
version: 1.3001.0
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 1.
|
68
|
+
version: 1.3001.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: bosh_common
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 1.
|
75
|
+
version: 1.3001.0
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 1.
|
82
|
+
version: 1.3001.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: bosh-template
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 1.
|
89
|
+
version: 1.3001.0
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 1.
|
96
|
+
version: 1.3001.0
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: bosh_cpi
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 1.
|
103
|
+
version: 1.3001.0
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 1.
|
110
|
+
version: 1.3001.0
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: bosh_openstack_cpi
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 1.
|
117
|
+
version: 1.3001.0
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 1.
|
124
|
+
version: 1.3001.0
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: bosh_aws_cpi
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: 1.
|
131
|
+
version: 1.3001.0
|
132
132
|
type: :runtime
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: 1.
|
138
|
+
version: 1.3001.0
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: bosh_vsphere_cpi
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
143
|
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: 1.
|
145
|
+
version: 1.3001.0
|
146
146
|
type: :runtime
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: 1.
|
152
|
+
version: 1.3001.0
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: bosh_vcloud_cpi
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -572,7 +572,7 @@ dependencies:
|
|
572
572
|
version: '0'
|
573
573
|
description: |-
|
574
574
|
BOSH Director
|
575
|
-
|
575
|
+
7cc77f
|
576
576
|
email: support@cloudfoundry.com
|
577
577
|
executables:
|
578
578
|
- bosh-director
|