@@ -14,18 +14,24 @@ module SASL
14
14
class OAuthAuthenticator
15
15
include GS2Header
16
16
17
- # Authorization identity: an identity to act as or on behalf of.
17
+ # Authorization identity: an identity to act as or on behalf of. The
18
+ # identity form is application protocol specific. If not provided or
19
+ # left blank, the server derives an authorization identity from the
20
+ # authentication identity. The server is responsible for verifying the
21
+ # client's credentials and verifying that the identity it associates
22
+ # with the client's authentication identity is allowed to act as (or on
23
+ # behalf of) the authorization identity.
24
+ #
25
+ # For example, an administrator or superuser might take on another role:
26
+ #
27
+ # imap.authenticate "PLAIN", "root", passwd, authzid: "user"
18
28
#
19
- # If no explicit authorization identity is provided, it is usually
20
- # derived from the authentication identity. For the OAuth-based
21
- # mechanisms, the authentication identity is the identity established by
22
- # the OAuth credential.
23
29
attr_reader :authzid
24
30
25
- # Hostname to which the client connected.
31
+ # Hostname to which the client connected. (optional)
26
32
attr_reader :host
27
33
28
- # Service port to which the client connected.
34
+ # Service port to which the client connected. (optional)
29
35
attr_reader :port
30
36
31
37
# HTTP method. (optional)
@@ -47,20 +53,22 @@ class OAuthAuthenticator
47
53
# Creates an RFC7628[https://tools.ietf.org/html/rfc7628] OAuth
48
54
# authenticator.
49
55
#
50
- # === Options
56
+ # ==== Parameters
51
57
#
52
- # See child classes for required configuration parameter(s). The
53
- # following parameters are all optional, but protocols or servers may
54
- # add requirements for #authzid, #host, #port, or any other parameter.
58
+ # See child classes for required parameter(s). The following parameters
59
+ # are all optional, but it is worth noting that <b>application protocols
60
+ # are allowed to require</b> #authzid (or other parameters, such as
61
+ # #host or #port) <b>as are specific server implementations</b>.
55
62
#
56
- # * #authzid ― Identity to act as or on behalf of.
57
- # * #host — Hostname to which the client connected.
58
- # * #port — Service port to which the client connected.
59
- # * #mthd — HTTP method
60
- # * #path — HTTP path data
61
- # * #post — HTTP post data
62
- # * #qs — HTTP query string
63
+ # * _optional_ #authzid ― Authorization identity to act as or on behalf of.
64
+ # * _optional_ #host — Hostname to which the client connected.
65
+ # * _optional_ #port — Service port to which the client connected.
66
+ # * _optional_ #mthd — HTTP method
67
+ # * _optional_ #path — HTTP path data
68
+ # * _optional_ #post — HTTP post data
69
+ # * _optional_ #qs — HTTP query string
63
70
#
71
+ # Any other keyword parameters are quietly ignored.
64
72
def initialize ( authzid : nil , host : nil , port : nil ,
65
73
mthd : nil , path : nil , post : nil , qs : nil , **)
66
74
@authzid = authzid
@@ -116,7 +124,7 @@ def authorization; raise "must be implemented by subclass" end
116
124
# the bearer token.
117
125
class OAuthBearerAuthenticator < OAuthAuthenticator
118
126
119
- # An OAuth2 bearer token, generally the access token.
127
+ # An OAuth 2.0 bearer token. See {RFC-6750}[https://www.rfc-editor.org/rfc/rfc6750]
120
128
attr_reader :oauth2_token
121
129
122
130
# :call-seq:
@@ -127,19 +135,22 @@ class OAuthBearerAuthenticator < OAuthAuthenticator
127
135
#
128
136
# Called by Net::IMAP#authenticate and similar methods on other clients.
129
137
#
130
- # === Options
138
+ # ==== Parameters
139
+ #
140
+ # * #oauth2_token — An OAuth2 bearer token
131
141
#
132
- # Only +oauth2_token+ is required by the mechanism, however protocols
133
- # and servers may add requirements for #authzid, #host, #port, or any
134
- # other parameter.
142
+ # All other keyword parameters are passed to
143
+ # {super}[rdoc-ref:OAuthAuthenticator::new] (see OAuthAuthenticator).
144
+ # The most common ones are:
135
145
#
136
- # * #oauth2_token — An OAuth2 bearer token or access token. *Required.*
137
- # May be provided as either regular or keyword argument.
138
- # * #authzid ― Identity to act as or on behalf of.
139
- # * #host — Hostname to which the client connected.
140
- # * #port — Service port to which the client connected.
141
- # * See OAuthAuthenticator documentation for less common parameters.
146
+ # * _optional_ #authzid ― Authorization identity to act as or on behalf of.
147
+ # * _optional_ #host — Hostname to which the client connected.
148
+ # * _optional_ #port — Service port to which the client connected.
142
149
#
150
+ # Although only oauth2_token is required by this mechanism, it is worth
151
+ # noting that <b><em>application protocols are allowed to
152
+ # require</em></b> #authzid (<em>or other parameters, such as</em> #host
153
+ # _or_ #port) <b><em>as are specific server implementations</em></b>.
143
154
def initialize ( oauth2_token_arg = nil , oauth2_token : nil , **args , &blk )
144
155
super ( **args , &blk ) # handles authzid, host, port, etc
145
156
oauth2_token && oauth2_token_arg and
0 commit comments