lib/osso/routes/oauth.rb in osso-0.0.5.pre.epsilon vs lib/osso/routes/oauth.rb in osso-0.0.5.pre.eta
- old
+ new
@@ -21,14 +21,15 @@
validate_oauth_request(env)
redirect "/auth/saml/#{enterprise.provider.id}" if enterprise.single_provider?
- @providers = enterprise.identity_providers
- erb :multiple_providers
+ @providers = enterprise.identity_providers.not_pending
+ erb :multiple_providers if @providers.count > 1
- rescue Osso::Error::OAuthError => e
+ raise Osso::Error::MissingConfiguredIdentityProvider.new(domain: params[:domain])
+ rescue Osso::Error::Base => e
@error = e
erb :error
end
# Exchange an authorization code for an access token.
@@ -62,11 +63,11 @@
def find_account(domain:, client_id:)
Models::EnterpriseAccount.
includes(:identity_providers).
find_by!(domain: domain, oauth_client_id: client_id)
rescue ActiveRecord::RecordNotFound
- raise Osso::Error::NoAccountForOAuthClientError
+ raise Osso::Error::NoAccountForOAuthClientError.new(domain: params[:domain])
end
def find_client(identifier)
@client ||= Models::OauthClient.find_by!(identifier: identifier)
rescue ActiveRecord::RecordNotFound
@@ -78,9 +79,9 @@
client = find_client(req[:client_id])
session[:osso_oauth_redirect_uri] = req.verify_redirect_uri!(client.redirect_uri_values)
session[:osso_oauth_state] = params[:state]
end.call(env)
rescue Rack::OAuth2::Server::Authorize::BadRequest
- raise Osso::Error::InvalidRedirectUri
+ raise Osso::Error::InvalidRedirectUri.new(redirect_uri: params[:redirect_uri])
end
end
end