Software /
code /
prosody
Annotate
util/sasl/external.lua @ 8069:8f5f197b139d
mod_register: Remove check for empty table (previous line sets a field)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 10 Apr 2017 10:28:05 +0200 |
parent | 6777:5de6b93d0190 |
child | 8555:4f0f5b49bb03 |
rev | line source |
---|---|
5687
e879b53e9df8
util.sasl.external: Add SASL EXTERNAL mechanism
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
1 local saslprep = require "util.encodings".stringprep.saslprep; |
e879b53e9df8
util.sasl.external: Add SASL EXTERNAL mechanism
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
2 |
6777
5de6b93d0190
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents:
5687
diff
changeset
|
3 local _ENV = nil; |
5687
e879b53e9df8
util.sasl.external: Add SASL EXTERNAL mechanism
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
4 |
e879b53e9df8
util.sasl.external: Add SASL EXTERNAL mechanism
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
5 local function external(self, message) |
e879b53e9df8
util.sasl.external: Add SASL EXTERNAL mechanism
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
6 message = saslprep(message); |
e879b53e9df8
util.sasl.external: Add SASL EXTERNAL mechanism
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
7 local state |
e879b53e9df8
util.sasl.external: Add SASL EXTERNAL mechanism
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
8 self.username, state = self.profile.external(message); |
e879b53e9df8
util.sasl.external: Add SASL EXTERNAL mechanism
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
9 |
e879b53e9df8
util.sasl.external: Add SASL EXTERNAL mechanism
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
10 if state == false then |
e879b53e9df8
util.sasl.external: Add SASL EXTERNAL mechanism
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
11 return "failure", "account-disabled"; |
e879b53e9df8
util.sasl.external: Add SASL EXTERNAL mechanism
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
12 elseif state == nil then |
e879b53e9df8
util.sasl.external: Add SASL EXTERNAL mechanism
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
13 return "failure", "not-authorized"; |
e879b53e9df8
util.sasl.external: Add SASL EXTERNAL mechanism
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
14 elseif state == "expired" then |
e879b53e9df8
util.sasl.external: Add SASL EXTERNAL mechanism
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
15 return "false", "credentials-expired"; |
e879b53e9df8
util.sasl.external: Add SASL EXTERNAL mechanism
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
16 end |
e879b53e9df8
util.sasl.external: Add SASL EXTERNAL mechanism
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
17 |
e879b53e9df8
util.sasl.external: Add SASL EXTERNAL mechanism
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
18 return "success"; |
e879b53e9df8
util.sasl.external: Add SASL EXTERNAL mechanism
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
19 end |
e879b53e9df8
util.sasl.external: Add SASL EXTERNAL mechanism
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
20 |
6777
5de6b93d0190
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents:
5687
diff
changeset
|
21 local function init(registerMechanism) |
5687
e879b53e9df8
util.sasl.external: Add SASL EXTERNAL mechanism
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
22 registerMechanism("EXTERNAL", {"external"}, external); |
e879b53e9df8
util.sasl.external: Add SASL EXTERNAL mechanism
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
23 end |
e879b53e9df8
util.sasl.external: Add SASL EXTERNAL mechanism
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
24 |
6777
5de6b93d0190
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents:
5687
diff
changeset
|
25 return { |
5de6b93d0190
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents:
5687
diff
changeset
|
26 init = init; |
5de6b93d0190
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents:
5687
diff
changeset
|
27 } |