Module: Rack::OAuth2::Server::Utils
- Defined in:
- lib/rack/oauth2/server/utils.rb
Class Method Summary collapse
-
.normalize_scope(scope) ⇒ Object
Given scope as either array or string, return array of same names, unique and sorted.
-
.parse_redirect_uri(redirect_uri) ⇒ Object
Parses the redirect URL, normalizes it and returns a URI object.
Class Method Details
.normalize_scope(scope) ⇒ Object
Given scope as either array or string, return array of same names, unique and sorted.
22 23 24 |
# File 'lib/rack/oauth2/server/utils.rb', line 22 def normalize_scope(scope) (Array === scope ? scope.join(" ") : scope || "").split(/\s+/).compact.uniq.sort end |
.parse_redirect_uri(redirect_uri) ⇒ Object
Parses the redirect URL, normalizes it and returns a URI object.
Raises InvalidRequestError if not an absolute HTTP/S URL.
11 12 13 14 15 16 17 18 |
# File 'lib/rack/oauth2/server/utils.rb', line 11 def parse_redirect_uri(redirect_uri) raise InvalidRequestError, "Missing redirect URL" unless redirect_uri uri = URI.parse(redirect_uri).normalize rescue nil raise InvalidRequestError, "Redirect URL looks fishy to me" unless uri raise InvalidRequestError, "Redirect URL must be absolute URL" unless uri.absolute? && uri.host raise InvalidRequestError, "Redirect URL must point to HTTP/S location" unless uri.scheme == "http" || uri.scheme == "https" uri end |