File: mac.rb

package info (click to toggle)
ruby-rack-oauth2 1.9.2-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 624 kB
  • sloc: ruby: 4,482; makefile: 4
file content (36 lines) | stat: -rw-r--r-- 909 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
module Rack
  module OAuth2
    module Server
      class Resource
        class MAC < Resource
          def _call(env)
            self.request = Request.new(env)
            super
          end

          private

          class Request < Resource::Request
            attr_reader :nonce, :ts, :ext, :signature

            def setup!
              auth_params = Rack::Auth::Digest::Params.parse(@auth_header.params).with_indifferent_access
              @access_token = auth_params[:id]
              @nonce = auth_params[:nonce]
              @ts = auth_params[:ts]
              @ext = auth_params[:ext]
              @signature = auth_params[:mac]
              self
            end

            def oauth2?
              @auth_header.provided? && @auth_header.scheme.to_s == 'mac'
            end
          end
        end
      end
    end
  end
end

require 'rack/oauth2/server/resource/mac/error'