Skip to content

Commit 47a4188

Browse files
authored
feature: support federated jwt client configuration (#104)
1 parent 70ae47d commit 47a4188

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

lib/uaa/scim.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,13 +380,19 @@ def change_secret(client_id, new_secret, old_secret = nil)
380380
# @param [String] jwks the JSON Web Key Set
381381
# @param [String] kid If changeMode is DELETE provide the id of key
382382
# @param [String] changeMode Change mode, possible is ADD, UPDATE, DELETE
383+
# @param [String] iss Issuer in case of federation JWT trust
384+
# @param [String] sub Subject in case of federation JWT trust
385+
# @param [String] aud Audience in case of federation JWT trust
383386
# @return [Hash] success message from server
384-
def change_clientjwt(client_id, jwks_uri = nil, jwks = nil, kid = nil, changeMode = nil)
387+
def change_clientjwt(client_id, jwks_uri = nil, jwks = nil, kid = nil, changeMode = nil, iss = nil, sub = nil, aud = nil)
385388
req = {"client_id" => client_id }
386389
req["jwks_uri"] = jwks_uri if jwks_uri
387390
req["jwks"] = jwks if jwks
388391
req["kid"] = kid if kid
389392
req["changeMode"] = changeMode if changeMode
393+
req["iss"] = iss if iss
394+
req["sub"] = sub if sub
395+
req["aud"] = aud if aud
390396
json_parse_reply(@key_style, *json_put(@target,
391397
"#{type_info(:client, :path)}/#{Addressable::URI.encode(client_id)}/clientjwt", req, headers))
392398
end

spec/scim_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,18 @@ def check_headers(headers, content, accept, zone)
184184
result['id'].should == 'id12345'
185185
end
186186

187+
it "add federated client's jwt trust using issuer, subject and audience" do
188+
subject.set_request_handler do |url, method, body, headers|
189+
url.should == "#{@target}/oauth/clients/id12345/clientjwt"
190+
method.should == :put
191+
check_headers(headers, :json, :json, nil)
192+
body.should include('"iss":"issuer"', '"sub":"subject"', '"aud":"audience"')
193+
[200, '{"id":"id12345"}', {'content-type' => 'application/json'}]
194+
end
195+
result = subject.change_clientjwt('id12345', jwks_uri=nil, jwks=nil, kid=nil, changemod='ADD', iss='issuer', sub='subject', aud='audience')
196+
result['id'].should == 'id12345'
197+
end
198+
187199
it 'unlocks a user' do
188200
subject.set_request_handler do |url, method, body, headers|
189201
url.should == "#{@target}/Users/id12345/status"

0 commit comments

Comments
 (0)