File: example.rb

package info (click to toggle)
ruby-rack-oauth2 2.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 564 kB
  • sloc: ruby: 4,038; makefile: 4
file content (37 lines) | stat: -rw-r--r-- 900 bytes parent folder | download | duplicates (5)
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
37
module Rack
  module OAuth2
    module Server
      class Token
        module Extension
          class Example < Abstract::Handler
            GRANT_TYPE_URN = 'urn:ietf:params:oauth:grant-type:example'

            class << self
              def grant_type_for?(grant_type)
                grant_type == GRANT_TYPE_URN
              end
            end

            def _call(env)
              @request  = Request.new env
              @response = Response.new request
              super
            end

            class Request < Token::Request
              attr_required :assertion
              attr_optional :client_id

              def initialize(env)
                super
                @grant_type = GRANT_TYPE_URN
                @assertion = params['assertion']
                attr_missing!
              end
            end
          end
        end
      end
    end
  end
end