Skip to content

Commit

Permalink
Merge pull request #127 from cache-sk/main
Browse files Browse the repository at this point in the history
Added required_user_groups for client get, add and update
  • Loading branch information
strehle committed Nov 21, 2023
2 parents 8757516 + cfb7501 commit 4736244
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
25 changes: 20 additions & 5 deletions lib/uaa/cli/client_reg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ class ClientCli < CommonCli
:autoapprove => 'list',
:allowpublic => 'list',
:allowedproviders => 'list',
:'signup_redirect_url' => 'url'
:'signup_redirect_url' => 'url',
:required_user_groups => 'list'
}
CLIENT_SCHEMA.each { |k, v| define_option(k, "--#{k} <#{v}>") }

Expand Down Expand Up @@ -65,8 +66,18 @@ def client_info(defaults)

desc "client get [id]", "Get specific client registration", :attrs do |id|
pp(scim_request do |sr|
client = scim_get_object(sr, :client, clientid(id), opts[:attrs])
add_meta_fields_to_client(sr, client)
if opts[:attrs] == nil
# return whole object, not search by filter
begin
client = sr.get(:client, clientid(id))
rescue NotFound
# to raise same error as scim_get_object
raise NotFound
end
else
client = scim_get_object(sr, :client, clientid(id), opts[:attrs])
end
add_meta_fields_to_client(sr, client, id)
end)
end

Expand Down Expand Up @@ -153,8 +164,12 @@ def update_client(cr, info)
add_meta_fields_to_client(cr, client)
end

def add_meta_fields_to_client(cr, client)
meta = cr.get_client_meta(client['client_id'])
def add_meta_fields_to_client(cr, client, id = nil)
# when attrs for get does not contain client_id, client does not have client_id, therefore i have added id
if id == nil
id = client['client_id']
end
meta = cr.get_client_meta(id)
client.merge({:created_by => meta['createdby']})
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/uaa/stub/scim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class StubScim
client: [*COMMON_ATTRS, :client_id, :name, :client_secret, :authorities,
:authorized_grant_types, :scope, :autoapprove,
:access_token_validity, :refresh_token_validity, :redirect_uri, :allowedproviders,
:'signup_redirect_url'].to_set,
:'signup_redirect_url', :required_user_groups].to_set,
group: [*COMMON_ATTRS, :displayname, :members, :writers, :readers, :external_groups].to_set }
VISIBLE_ATTRS = {user: Set.new(LEGAL_ATTRS[:user] - HIDDEN_ATTRS),
client: Set.new(LEGAL_ATTRS[:client] - HIDDEN_ATTRS),
Expand Down

0 comments on commit 4736244

Please sign in to comment.