class Osso::Oauth
Private Instance Methods
access_token()
click to toggle source
# File lib/osso/routes/oauth.rb, line 107 def access_token params[:access_token] || env.fetch('HTTP_AUTHORIZATION', '').slice(-64..-1) end
domain_from_params()
click to toggle source
# File lib/osso/routes/oauth.rb, line 86 def domain_from_params params[:domain] || params[:email].split('@')[1] end
find_client(identifier)
click to toggle source
# File lib/osso/routes/oauth.rb, line 90 def find_client(identifier) @client ||= Models::OauthClient.find_by!(identifier: identifier) rescue ActiveRecord::RecordNotFound raise Osso::Error::InvalidOAuthClientIdentifier end
find_providers()
click to toggle source
# File lib/osso/routes/oauth.rb, line 69 def find_providers if params[:email] user = Osso::Models::User. includes(:identity_provider). find_by(email: params[:email]) return [user.identity_provider] if user end Osso::Models::IdentityProvider. joins(:oauth_client). not_pending. where( domain: domain_from_params, oauth_clients: { identifier: params[:client_id] }, ) end
render_hosted_login?()
click to toggle source
# File lib/osso/routes/oauth.rb, line 65 def render_hosted_login? [params[:email], params[:domain]].all?(&:nil?) end
validate_oauth_request(env)
click to toggle source
# File lib/osso/routes/oauth.rb, line 96 def validate_oauth_request(env) # rubocop:disable Metrics/AbcSize Rack::OAuth2::Server::Authorize.new do |req, _res| 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] session[:osso_oauth_requested] = { domain: req[:domain], email: req[:email] } end.call(env) rescue Rack::OAuth2::Server::Authorize::BadRequest raise Osso::Error::InvalidRedirectUri.new(redirect_uri: params[:redirect_uri]) end