16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/rack/oauth2/assertion_profile.rb', line 16
def call(env)
request = Request.new(env)
if (request.assertion_profile? && request.format == :saml)
InformationCard::Config.audience_scope, InformationCard::Config.audiences = :site, [@opts[:scope]]
token = InformationCard::SamlToken.create(request.token)
unless token.valid?
return [400, {'Content-Type' => "application/x-www-form-urlencoded"}, "error=unauthorized_client"]
end
swt = token_builder.build(token.claims)
return [200, {'Content-Type' => "application/x-www-form-urlencoded"}, "access_token=#{CGI.escape(swt)}"]
end
return @app.call(env)
end
|