Module: Authlete::Utility
- Included in:
- Api, Model::Client, Model::Hsk, Model::Request::AuthorizationIssueRequest, Model::Request::BackchannelAuthenticationCompleteRequest, Model::Request::DeviceCompleteRequest, Model::Request::DeviceVerificationRequest, Model::Request::PushedAuthReqRequest, Model::Request::TokenCreateRequest, Model::Request::TokenIssueRequest, Model::Request::TokenRequest, Model::Request::TokenUpdateRequest, Model::Response::AccessToken, Model::Response::AuthenticationCallbackResponse, Model::Response::AuthorizationResponse, Model::Response::BackchannelAuthenticationResponse, Model::Response::ClientListResponse, Model::Response::DeveloperAuthenticationCallbackResponse, Model::Response::DeviceAuthorizationResponse, Model::Response::DeviceVerificationResponse, Model::Response::IntrospectionResponse, Model::Response::ServiceListResponse, Model::Response::TokenIssueResponse, Model::Response::TokenListResponse, Model::Result, Model::Scope, Model::Service, Model::ServiceOwner, Model::SnsCredentials, Model::TaggedValue
- Defined in:
- lib/authlete/utility.rb
Instance Method Summary collapse
-
#extract_access_token(request) ⇒ Object
Extract an access token (RFC 6750).
- #get_parsed_array(array) ⇒ Object
- #to_rack_response_json(status_code, content) ⇒ Object
- #to_rack_response_www_authenticate(status_code, content) ⇒ Object
Instance Method Details
#extract_access_token(request) ⇒ Object
Extract an access token (RFC 6750)
21 22 23 24 25 26 27 28 29 |
# File 'lib/authlete/utility.rb', line 21 def extract_access_token(request) header = request.env['HTTP_AUTHORIZATION'] if /^Bearer[ ]+(.+)/i =~ header return $1 end request['access_token'] end |
#get_parsed_array(array) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/authlete/utility.rb', line 31 def get_parsed_array(array) return nil if !array.kind_of?(Array) or array.empty? elements = [] array.each do |element| parsed_element = yield(element) elements.push(parsed_element) unless parsed_element.nil? end elements.empty? ? nil : elements end |
#to_rack_response_json(status_code, content) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/authlete/utility.rb', line 44 def to_rack_response_json(status_code, content) [ status_code, { 'Content-Type' => 'application/json;charset=UTF-8', 'Cache-Control' => 'no-store', 'Pragma' => 'no-cache' }, [ content ] ] end |
#to_rack_response_www_authenticate(status_code, content) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/authlete/utility.rb', line 58 def to_rack_response_www_authenticate(status_code, content) [ status_code, { 'WWW-Authenticate' => content, 'Cache-Control' => 'no-store', 'Pragma' => 'no-cache' }, nil ] end |