Class: OpenID::Server::CheckAuthRequest
- Inherits:
-
OpenIDRequest
- Object
- OpenIDRequest
- OpenID::Server::CheckAuthRequest
- Defined in:
- lib/openid/server.rb
Overview
A request to verify the validity of a previous response.
See OpenID Specs, Verifying Directly with the OpenID Provider <openid.net/specs/openid-authentication-2_0-12.html#verifying_signatures>
Instance Attribute Summary collapse
-
#assoc_handle ⇒ Object
The association handle the response was signed with.
-
#invalidate_handle ⇒ Object
An association handle the client is asking about the validity of.
-
#sig ⇒ Object
Returns the value of attribute sig.
-
#signed ⇒ Object
The message with the signature which wants checking.
Attributes inherited from OpenIDRequest
Class Method Summary collapse
-
.from_message(message, op_endpoint = UNUSED) ⇒ Object
Construct me from an OpenID::Message.
Instance Method Summary collapse
-
#answer(signatory) ⇒ Object
Respond to this request.
-
#initialize(assoc_handle, signed, invalidate_handle = nil) ⇒ CheckAuthRequest
constructor
Construct me.
- #to_s ⇒ Object
Constructor Details
#initialize(assoc_handle, signed, invalidate_handle = nil) ⇒ CheckAuthRequest
Construct me.
These parameters are assigned directly as class attributes.
Parameters:
- assoc_handle
-
the association handle for this request
- signed
-
The signed message
- invalidate_handle
-
An association handle that the relying party is checking to see if it is invalid
67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/openid/server.rb', line 67 def initialize(assoc_handle, signed, invalidate_handle=nil) super() @mode = "check_authentication" @required_fields = ["identity", "return_to", "response_nonce"].freeze @sig = nil @assoc_handle = assoc_handle @signed = signed @invalidate_handle = invalidate_handle @namespace = OPENID2_NS end |
Instance Attribute Details
#assoc_handle ⇒ Object
The association handle the response was signed with.
47 48 49 |
# File 'lib/openid/server.rb', line 47 def assoc_handle @assoc_handle end |
#invalidate_handle ⇒ Object
An association handle the client is asking about the validity of. May be nil.
54 55 56 |
# File 'lib/openid/server.rb', line 54 def invalidate_handle @invalidate_handle end |
#sig ⇒ Object
Returns the value of attribute sig.
56 57 58 |
# File 'lib/openid/server.rb', line 56 def sig @sig end |
#signed ⇒ Object
The message with the signature which wants checking.
50 51 52 |
# File 'lib/openid/server.rb', line 50 def signed @signed end |
Class Method Details
.from_message(message, op_endpoint = UNUSED) ⇒ Object
Construct me from an OpenID::Message.
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/openid/server.rb', line 81 def self.(, op_endpoint=UNUSED) assoc_handle = .get_arg(OPENID_NS, 'assoc_handle') invalidate_handle = .get_arg(OPENID_NS, 'invalidate_handle') signed = .copy() # openid.mode is currently check_authentication because # that's the mode of this request. But the signature # was made on something with a different openid.mode. # http://article.gmane.org/gmane.comp.web.openid.general/537 if signed.has_key?(OPENID_NS, "mode") signed.set_arg(OPENID_NS, "mode", "id_res") end obj = self.new(assoc_handle, signed, invalidate_handle) obj. = obj.namespace = .get_openid_namespace() obj.sig = .get_arg(OPENID_NS, 'sig') if !obj.assoc_handle or !obj.sig msg = sprintf("%s request missing required parameter from message %s", obj.mode, ) raise ProtocolError.new(, msg) end return obj end |
Instance Method Details
#answer(signatory) ⇒ Object
Respond to this request.
Given a Signatory, I can check the validity of the signature and the invalidate_handle. I return a response with an is_valid (and, if appropriate invalidate_handle) field.
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/openid/server.rb', line 114 def answer(signatory) is_valid = signatory.verify(@assoc_handle, @signed) # Now invalidate that assoc_handle so it this checkAuth # message cannot be replayed. signatory.invalidate(@assoc_handle, dumb=true) response = OpenIDResponse.new(self) valid_str = is_valid ? "true" : "false" response.fields.set_arg(OPENID_NS, 'is_valid', valid_str) if @invalidate_handle assoc = signatory.get_association(@invalidate_handle, false) if !assoc response.fields.set_arg( OPENID_NS, 'invalidate_handle', @invalidate_handle) end end return response end |
#to_s ⇒ Object
134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/openid/server.rb', line 134 def to_s ih = nil if @invalidate_handle ih = sprintf(" invalidate? %s", @invalidate_handle) else ih = "" end s = sprintf("<%s handle: %s sig: %s: signed: %s%s>", self.class, @assoc_handle, @sig, @signed, ih) return s end |