blob: 59bfcf98b1b3bc64294c851c319e5224bb6c1152 [file] [log] [blame]
Bryan Duxburyd4837122010-09-08 00:06:35 +00001A Thrift SASL message shall be a byte array of one of the following forms:
2
3| 1-byte START status code | 1-byte mechanism name length | variable length mechanism name | 4-byte payload length | variable-length payload |
4| 1-byte status code | 4-byte payload length | variable-length payload |
5
6The length fields shall be interpreted as integers, with the high byte sent
7first. This indicates the length of the field immediately following it, not
8including the status code or the length bytes.
9
10The possible status codes are:
11
120x01 - START - Hello, let's go on a date.
130x02 - OK - Everything's been going alright so far, let's see each other again.
140x03 - BAD - I understand what you're saying. I really do. I just don't like it. We have to break up.
150x04 - ERROR - We can't go on like this. It's like you're speaking another language.
160x05 - COMPLETE - Will you marry me?
17
18The Thrift SASL communication will proceed as follows:
19
201. The client is configured at instantiation of the transport with a single
21underlying SASL security mechanism that it supports.
22
232. The server is configured with a mapping of underlying security mechanism
24name -> mechanism options.
25
263. At connection time, the client will initiate communication by sending the
27server a START byte, followed by a 1-byte field indicating the length in bytes
28of the underlying security mechanism name that the client would like to use.
29This mechanism name shall be 1-20 characters in length, and follow the
30specifications for SASL mechanism names specified in RFC 2222. This mechanism
31name shall be followed by a 4-byte, potentially zero-value message length word,
32followed by a potentially zero-length payload. The payload is determined by the
33output byte array of the underlying actual security mechanism, and will be
34empty except for those underlying security protocols which implement the
35optional SASL initial response.
36
374. The server receives this message and, if the mechanism name provided is
38among the set of mechanisms this server transport is configured to accept,
39appropriate initialization of the underlying security mechanism may take place.
40If the mechanism name is not one which the server is configured to support, the
41server shall return the BAD byte, followed by a 4-byte, potentially zero-value
42message length, followed by the potentially zero-length payload which may be a
43status code or message indicating failure. No further communication may take
44place via this transport. If the mechanism name is one which the server
45supports, then proceed to step 5.
46
475. The server then provides the byte array of the payload received to its
48underlying security mechanism. A challenge is generated by the underlying
49security mechanism on the server, and this is used as the payload for a message
50sent to the client. This message shall consist of an OK byte, followed by the
51non-zero message length word, followed by the payload.
52
536. The client receives this message from the server and passes the payload to
54its underlying security mechanism to generate a response. The client then sends
55the server an OK byte, followed by the non-zero-value length of the response,
56followed by the bytes of the response as the payload.
57
587. Steps 5 and 6 are repeated until both security mechanisms are satisfied with
59the challenge/response exchange. When either side has completed its security
60protocol, its next message shall be the COMPLETE byte, followed by a 4-byte
61potentially zero-value length word, followed by a potentially zero-length
62payload. This payload will be empty except for those underlying security
63mechanisms which provide additional data with success.
64
65If at any point in time either side is able to interpret the challenge or
66response sent by the other, but is dissatisfied with the contents thereof, this
67side should send the other a BAD byte, followed by a 4-byte potentially
68zero-value length word, followed by an optional, potentially zero-length
69message encoded in UTF-8 indicating failure. This message should be passed to
70the protocol above the thrift transport by whatever mechanism is appropriate
71and idiomatic for the particular language these thrift bindings are for.
72
73If at any point in time either side fails to interpret the challenge or
74response sent by the other, this side should send the other an ERROR byte,
75followed by a 4-byte potentially zero-value length word, followed by an
76optional, potentially zero-length message encoded in UTF-8. This message should
77be passed to the protocol above the thrift transport by whatever mechanism is
78appropriate and idiomatic for the particular language these thrift bindings are
79for.
80
81If step 7 completes successfully, then the communication is considered
82authenticated and subsequent communication may commence.
83
84If step 7 fails to complete successfully, then no further communication may
85take place via this transport.
86
878. All writes to the underlying transport must be prefixed by the 4-byte length
88of the payload data, followed by the payload. All reads from this transport
89should read the 4-byte length word, then read the full quantity of bytes
90specified by this length word.
91
92If no SASL QOP (quality of protection) is negotiated during steps 5 and 6, then
93all subsequent writes to/reads from this transport are written/read unaltered,
94save for the length prefix, to the underlying transport.
95
96If a SASL QOP is negotiated, then this must be used by the Thrift transport for
97all subsequent communication. This is done by wrapping subsequent writes to the
98transport using the underlying security mechanism, and unwrapping subsequent
99reads from the underlying transport. Note that in this case, the length prefix
100of the write to the underlying transport is the length of the data after it has
101been wrapped by the underlying security mechanism. Note that the complete
102message must be read before giving this data to the underlying security
103mechanism for unwrapping.
104
105If at any point in time reading of a message fails either because of a
106malformed length word or failure to unwrap by the underlying security
107mechanism, then all further communication on this transport must cease.