|
18 | 18 | -type maybe_username() :: undefined | jid:luser().
|
19 | 19 | -type success() :: #{server_out := undefined | binary(),
|
20 | 20 | jid := jid:jid(),
|
21 |
| - auth_module := cyrsasl:sasl_module()}. |
| 21 | + auth_module := cyrsasl:sasl_module(), |
| 22 | + creds := mongoose_credentials:t()}. |
22 | 23 | -type continue() :: #{server_out := binary()}.
|
23 | 24 | -type failure() :: #{server_out := binary() | {binary(), undefined | iodata()},
|
24 | 25 | maybe_username := maybe_username()}.
|
@@ -48,7 +49,10 @@ start(C2SData, SaslAcc, Mech, ClientIn) ->
|
48 | 49 | {error, SaslAcc, #{type => policy_violation, text => <<"Use of STARTTLS required">>}};
|
49 | 50 | _ ->
|
50 | 51 | AuthMech = mongoose_c2s:get_auth_mechs(C2SData),
|
51 |
| - SocketData = #{socket => Socket, auth_mech => AuthMech, listener_opts => LOpts}, |
| 52 | + %% Provide SaslAcc for readonly access, so the cyrsasl mechanism |
| 53 | + %% has more visibility to initialize the mechanism state. |
| 54 | + SocketData = #{socket => Socket, auth_mech => AuthMech, listener_opts => LOpts, |
| 55 | + sasl_state => SaslAcc}, |
52 | 56 | CyrSaslState = get_cyrsasl_state_from_acc(SaslAcc),
|
53 | 57 | CyrSaslResult = cyrsasl:server_start(CyrSaslState, Mech, ClientIn, SocketData),
|
54 | 58 | handle_sasl_step(C2SData, CyrSaslResult, SaslAcc)
|
@@ -78,7 +82,7 @@ handle_sasl_success(C2SData, Creds, SaslAcc) ->
|
78 | 82 | User = mongoose_credentials:get(Creds, username),
|
79 | 83 | LServer = mongoose_c2s:get_lserver(C2SData),
|
80 | 84 | Jid = jid:make_bare(User, LServer),
|
81 |
| - Ret = #{server_out => ServerOut, jid => Jid, auth_module => AuthModule}, |
| 85 | + Ret = #{server_out => ServerOut, jid => Jid, auth_module => AuthModule, creds => Creds}, |
82 | 86 | {success, SaslAcc, Ret}.
|
83 | 87 |
|
84 | 88 | -spec handle_sasl_continue(
|
|
0 commit comments