Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added required_user_groups for client get, add and update #127

Merged
merged 1 commit into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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