@@ -8,18 +8,27 @@ module V4
8
8
9
9
def authn_login account , username , password
10
10
verify_account ( account )
11
- RestClient ::Resource . new ( Conjur . configuration . authn_url , user : username , password : password ) [ 'users/login' ]
11
+ RestClient ::Resource . new (
12
+ Conjur . configuration . authn_url ,
13
+ Conjur . configuration . create_rest_client_options (
14
+ user : username ,
15
+ password : password
16
+ )
17
+ ) [ 'users/login' ]
12
18
end
13
19
14
20
def authn_authenticate account , username
15
21
verify_account ( account )
16
- RestClient ::Resource . new ( Conjur . configuration . authn_url ) [ 'users' ] [ fully_escape username ] [ 'authenticate' ]
22
+ RestClient ::Resource . new (
23
+ Conjur . configuration . authn_url ,
24
+ Conjur . configuration . rest_client_options
25
+ ) [ 'users' ] [ fully_escape username ] [ 'authenticate' ]
17
26
end
18
27
19
28
# For v4, the authn-local message is the username.
20
29
def authn_authenticate_local username , account , expiration , cidr , &block
21
30
verify_account ( account )
22
-
31
+
23
32
raise "'expiration' is not supported for authn-local v4" if expiration
24
33
raise "'cidr' is not supported for authn-local v4" if cidr
25
34
@@ -28,36 +37,51 @@ def authn_authenticate_local username, account, expiration, cidr, &block
28
37
29
38
def authn_rotate_api_key credentials , account , id
30
39
verify_account ( account )
31
- username = if id . kind == "user"
32
- id . identifier
33
- else
34
- [ id . kind , id . identifier ] . join ( '/' )
35
- end
36
- RestClient ::Resource . new ( Conjur . configuration . authn_url , credentials ) [ 'users' ] [ "api_key?id=#{ username } " ]
40
+ username = id . kind == "user" ? id . identifier : [ id . kind , id . identifier ] . join ( '/' )
41
+ RestClient ::Resource . new (
42
+ Conjur . configuration . authn_url ,
43
+ Conjur . configuration . create_rest_client_options ( credentials )
44
+ ) [ 'users' ] [ "api_key?id=#{ username } " ]
37
45
end
38
46
39
47
def authn_rotate_own_api_key account , username , password
40
48
verify_account ( account )
41
- RestClient ::Resource . new ( Conjur . configuration . authn_url , user : username , password : password ) [ 'users' ] [ "api_key" ]
49
+ RestClient ::Resource . new (
50
+ Conjur . configuration . authn_url ,
51
+ Conjur . configuration . create_rest_client_options ( user : username , password : password )
52
+ ) [ 'users' ] [ "api_key" ]
42
53
end
43
54
44
55
def host_factory_create_host token
45
56
http_options = {
46
57
headers : { authorization : %Q(Token token="#{ token } ") }
47
58
}
48
- RestClient ::Resource . new ( Conjur . configuration . core_url , http_options ) [ 'host_factories' ] [ 'hosts' ]
59
+ RestClient ::Resource . new (
60
+ Conjur . configuration . core_url ,
61
+ Conjur . configuration . create_rest_client_options ( http_options )
62
+ ) [ 'host_factories' ] [ 'hosts' ]
49
63
end
50
64
51
65
def host_factory_create_tokens credentials , id
52
- RestClient ::Resource . new ( Conjur . configuration . core_url , credentials ) [ 'host_factories' ] [ id . identifier ] [ 'tokens' ]
66
+ RestClient ::Resource . new (
67
+ Conjur . configuration . core_url ,
68
+ Conjur . configuration . create_rest_client_options ( credentials )
69
+ ) [ 'host_factories' ] [ id . identifier ] [ 'tokens' ]
53
70
end
54
71
55
72
def host_factory_revoke_token credentials , token
56
- RestClient ::Resource . new ( Conjur . configuration . core_url , credentials ) [ 'host_factories' ] [ 'tokens' ] [ token ]
73
+ RestClient ::Resource . new (
74
+ Conjur . configuration . core_url ,
75
+ Conjur . configuration . create_rest_client_options ( credentials )
76
+ ) [ 'host_factories' ] [ 'tokens' ] [ token ]
57
77
end
58
78
59
79
def resources_resource credentials , id
60
- RestClient ::Resource . new ( Conjur . configuration . core_url , credentials ) [ 'authz' ] [ id . account ] [ 'resources' ] [ id . kind ] [ id . identifier ]
80
+
81
+ RestClient ::Resource . new (
82
+ Conjur . configuration . core_url ,
83
+ Conjur . configuration . create_rest_client_options ( credentials )
84
+ ) [ 'authz' ] [ id . account ] [ 'resources' ] [ id . kind ] [ id . identifier ]
61
85
end
62
86
63
87
def resources_check credentials , id , privilege , role
@@ -73,47 +97,80 @@ def resources_check credentials, id, privilege, role
73
97
end
74
98
75
99
def resources_permitted_roles credentials , id , privilege
76
- RestClient ::Resource . new ( Conjur . configuration . core_url , credentials ) [ 'authz' ] [ id . account ] [ 'roles' ] [ 'allowed_to' ] [ privilege ] [ id . kind ] [ id . identifier ]
100
+ RestClient ::Resource . new (
101
+ Conjur . configuration . core_url ,
102
+ Conjur . configuration . create_rest_client_options ( credentials )
103
+ ) [ 'authz' ] [ id . account ] [ 'roles' ] [ 'allowed_to' ] [ privilege ] [ id . kind ] [ id . identifier ]
77
104
end
78
105
79
106
def roles_role credentials , id
80
- RestClient ::Resource . new ( Conjur . configuration . core_url , credentials ) [ 'authz' ] [ id . account ] [ 'roles' ] [ id . kind ] [ id . identifier ]
107
+ RestClient ::Resource . new (
108
+ Conjur . configuration . core_url ,
109
+ Conjur . configuration . create_rest_client_options ( credentials )
110
+ ) [ 'authz' ] [ id . account ] [ 'roles' ] [ id . kind ] [ id . identifier ]
81
111
end
82
112
83
113
def secrets_add credentials , id
84
114
verify_account ( id . account )
85
- RestClient ::Resource . new ( Conjur . configuration . core_url , credentials ) [ 'variables' ] [ fully_escape id . identifier ] [ 'values' ]
115
+ RestClient ::Resource . new (
116
+ Conjur . configuration . core_url ,
117
+ Conjur . configuration . create_rest_client_options ( credentials )
118
+ ) [ 'variables' ] [ fully_escape id . identifier ] [ 'values' ]
86
119
end
87
120
88
121
def variable credentials , id
89
122
verify_account ( id . account )
90
- RestClient ::Resource . new ( Conjur . configuration . core_url , credentials ) [ 'variables' ] [ fully_escape id . identifier ]
123
+ RestClient ::Resource . new (
124
+ Conjur . configuration . core_url ,
125
+ Conjur . configuration . create_rest_client_options ( credentials )
126
+ ) [ 'variables' ] [ fully_escape id . identifier ]
91
127
end
92
128
93
129
def secrets_value credentials , id , options
94
- RestClient ::Resource . new ( Conjur . configuration . core_url , credentials ) [ 'variables' ] [ fully_escape id . identifier ] [ 'value' ] [ options_querystring options ]
130
+ RestClient ::Resource . new (
131
+ Conjur . configuration . core_url ,
132
+ Conjur . configuration . create_rest_client_options ( credentials )
133
+ ) [ 'variables' ] [ fully_escape id . identifier ] [ 'value' ] [ options_querystring options ]
95
134
end
96
135
97
136
def secrets_values credentials , variable_ids
98
137
options = {
99
138
vars : Array ( variable_ids ) . map { |v | fully_escape ( v . identifier ) } . join ( ',' )
100
139
}
101
- RestClient ::Resource . new ( Conjur . configuration . core_url , credentials ) [ 'variables' ] [ 'values' ] [ options_querystring options ]
140
+ RestClient ::Resource . new (
141
+ Conjur . configuration . core_url ,
142
+ Conjur . configuration . create_rest_client_options ( credentials )
143
+ ) [ 'variables' ] [ 'values' ] [ options_querystring options ]
102
144
end
103
145
104
146
def group_attributes credentials , resource , id
105
147
verify_account ( id . account )
106
- JSON . parse ( RestClient ::Resource . new ( Conjur . configuration . core_url , credentials ) [ 'groups' ] [ fully_escape id . identifier ] . get )
148
+ JSON . parse (
149
+ RestClient ::Resource . new (
150
+ Conjur . configuration . core_url ,
151
+ Conjur . configuration . create_rest_client_options ( credentials )
152
+ ) [ 'groups' ] [ fully_escape id . identifier ] . get
153
+ )
107
154
end
108
155
109
156
def variable_attributes credentials , resource , id
110
157
verify_account ( id . account )
111
- JSON . parse ( RestClient ::Resource . new ( Conjur . configuration . core_url , credentials ) [ 'variables' ] [ fully_escape id . identifier ] . get )
158
+ JSON . parse (
159
+ RestClient ::Resource . new (
160
+ Conjur . configuration . core_url ,
161
+ Conjur . configuration . create_rest_client_options ( credentials )
162
+ ) [ 'variables' ] [ fully_escape id . identifier ] . get
163
+ )
112
164
end
113
165
114
166
def user_attributes credentials , resource , id
115
167
verify_account ( id . account )
116
- JSON . parse ( RestClient ::Resource . new ( Conjur . configuration . core_url , credentials ) [ 'users' ] [ fully_escape id . identifier ] . get )
168
+ JSON . parse (
169
+ RestClient ::Resource . new (
170
+ Conjur . configuration . core_url ,
171
+ Conjur . configuration . create_rest_client_options ( credentials )
172
+ ) [ 'users' ] [ fully_escape id . identifier ] . get
173
+ )
117
174
end
118
175
119
176
def parse_group_gidnumber attributes
0 commit comments