-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: authorization_code grant with public client usage (#90)
* feature: authoriation_code grant with public client usage * add PKCE to authorization code * optional allow to omit client_secret * add client_auth_method to class to distinguish between basic and post - later private_key_jwt * add example ruby script * add default as it was before * test update * add extra option for pkce and set it to false * review removed client_secret_post for now The methods itself are useful therefore add it later with extra PR renamed the test PKCE in cf-uaa-lib is active if a) you provide a secret for the calculation b) you set use_pkce=true in initialization of the lib By default PKCE is off. * less code, less logic. Tests not touched
- Loading branch information
Showing
3 changed files
with
118 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env ruby | ||
|
||
# Start a develop UAA with default profile or add client with allowpublic=true | ||
# uaac client add login -s loginsecret \ | ||
# --authorized_grant_types authorization_code,refresh_token \ | ||
# --scope "openid" \ | ||
# --authorities uaa.none \ | ||
# --allowpublic true \ | ||
# --redirect_uri=http://localhost:7000/callback | ||
|
||
require 'uaa' | ||
require 'cgi' | ||
|
||
url = ENV["UAA_URL"] || 'http://localhost:8080/uaa' | ||
client = "login" | ||
secret = nil | ||
|
||
def show(title, object) | ||
puts "#{title}: #{object.inspect}" | ||
puts | ||
end | ||
|
||
uaa_options = { skip_ssl_validation: true, use_pkce:true, client_auth_method: 'none'} | ||
uaa_options[:ssl_ca_file] = ENV["UAA_CA_CERT_FILE"] if ENV["UAA_CA_CERT_FILE"] | ||
show "uaa_options", uaa_options | ||
|
||
uaa_info = CF::UAA::Info.new(url, uaa_options) | ||
show "UAA server info", uaa_info.server | ||
|
||
token_issuer = CF::UAA::TokenIssuer.new(url, client, secret, uaa_options) | ||
auth_uri = token_issuer.authcode_uri("http://localhost:7000/callback", nil) | ||
show "UAA authorization URL", auth_uri | ||
|
||
puts "Enter Callback URL: " | ||
callback_url = gets | ||
show "Perform Token Request with: ", callback_url | ||
|
||
token = token_issuer.authcode_grant(auth_uri, URI.parse(callback_url).query.to_s) | ||
show "User authorization grant", token | ||
|
||
token_info = CF::UAA::TokenCoder.decode(token.info["access_token"], nil, nil, false) #token signature not verified | ||
show "Decoded access token", token_info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters