Skip to content

Commit fc55700

Browse files
committed
refine user minting logic
1 parent d7bd008 commit fc55700

2 files changed

Lines changed: 32 additions & 13 deletions

File tree

app/lib/client/ldap/ldap.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -442,13 +442,13 @@ def default_users(role)
442442
end
443443

444444
def create_user(params)
445-
ark = UC3S3::ConfigObjectsClient.client.mint(
445+
dn = "uid=#{params.fetch('uid', '')},#{user_base}"
446+
ark = UC3S3::ConfigObjectsClient.client.mint_user(
446447
UC3S3::ConfigObjectsClient.client.mint_user_url,
447-
params.fetch('cn', '')
448+
dn
448449
)
449450
logger.info("User Ark Minted: #{ark}")
450451

451-
dn = "uid=#{params.fetch('uid', '')},#{user_base}"
452452
attributes = {
453453
objectclass: %w[top person organizationalPerson merrittUser inetOrgPerson],
454454
uid: params.fetch('uid', ''),

app/lib/client/s3/config_objects.rb

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -162,18 +162,9 @@ def mint_user_url
162162
"#{@ezidconf.fetch(:api, 'http://ezid:4567')}/shoulder/#{@ezidconf.fetch(:user_shoulder, 'ark:/99166/p9')}"
163163
end
164164

165-
def mint(url, description)
165+
def do_mint(url, body)
166166
raise 'Minting not supported' unless @ezidconf.fetch(:supported, true)
167167

168-
# https://ezid.cdlib.org/doc/apidoc.html#internal-metadata
169-
body = []
170-
body << "_target: #{@ezidconf.fetch(:target, '')}"
171-
body << '_owner: merritt'
172-
body << '_profile: erc'
173-
body << '_status: reserved'
174-
body << '_export: no'
175-
body << "what: #{description}"
176-
177168
r = post_url_body(
178169
url,
179170
body: body.join("\n"),
@@ -187,6 +178,34 @@ def mint(url, description)
187178
m[2]
188179
end
189180

181+
def mint(url, description)
182+
# https://ezid.cdlib.org/doc/apidoc.html#internal-metadata
183+
body = []
184+
body << "_target: #{@ezidconf.fetch(:target, '')}"
185+
body << '_owner: merritt'
186+
body << '_profile: erc'
187+
body << '_status: reserved'
188+
body << '_export: no'
189+
body << "what: #{description}"
190+
191+
do_mint(url, body)
192+
end
193+
194+
def mint_user(url, dnid)
195+
# https://ezid.cdlib.org/doc/apidoc.html#internal-metadata
196+
body = []
197+
body << "_target: #{@ezidconf.fetch(:target, '')}"
198+
body << '_owner: merritt'
199+
body << '_profile: erc'
200+
body << '_status: reserved'
201+
body << '_export: no'
202+
body << "who: #{dnid}"
203+
body << 'what: Merritt User'
204+
body << "when: #{Date.today.strftime('%Y-%m-%d')}"
205+
206+
do_mint(url, body)
207+
end
208+
190209
def create_collection(params)
191210
ark = mint(mint_collection_url, params.fetch('description', ''))
192211
logger.info("Collection Ark Minted: #{ark}")

0 commit comments

Comments
 (0)