let update.py add information of oauth2-authorizer

This commit is contained in:
B. Petersen
2020-06-19 16:37:43 +02:00
parent b6c0f44608
commit b91b88e11b
2 changed files with 17 additions and 5 deletions

View File

@@ -35,6 +35,13 @@ pub enum UsernamePattern {
EMAILLOCALPART = 2, EMAILLOCALPART = 2,
} }
#[derive(Debug, PartialEq)]
#[repr(u8)]
pub enum Oauth2Authorizer {
Yandex = 1,
Gmail = 2,
}
#[derive(Debug)] #[derive(Debug)]
pub struct Server { pub struct Server {
pub protocol: Protocol, pub protocol: Protocol,
@@ -73,6 +80,7 @@ pub struct Provider {
pub server: Vec<Server>, pub server: Vec<Server>,
pub config_defaults: Option<Vec<ConfigDefault>>, pub config_defaults: Option<Vec<ConfigDefault>>,
pub strict_tls: bool, pub strict_tls: bool,
pub oauth2_authorizer: Option<Oauth2Authorizer>,
} }
impl Provider { impl Provider {

View File

@@ -103,6 +103,9 @@ def process_data(data, file):
strict_tls = data.get("strict_tls", False) strict_tls = data.get("strict_tls", False)
strict_tls = "true" if strict_tls else "false" strict_tls = "true" if strict_tls else "false"
oauth2 = data.get("oauth2", "")
oauth2 = "Some(Oauth2Authorizer::" + camel(oauth2) + ")" if oauth2 != "" else "None"
provider = "" provider = ""
before_login_hint = cleanstr(data.get("before_login_hint", "")) before_login_hint = cleanstr(data.get("before_login_hint", ""))
after_login_hint = cleanstr(data.get("after_login_hint", "")) after_login_hint = cleanstr(data.get("after_login_hint", ""))
@@ -115,6 +118,7 @@ def process_data(data, file):
provider += " server: vec![\n" + server + " ],\n" provider += " server: vec![\n" + server + " ],\n"
provider += " config_defaults: " + config_defaults + ",\n" provider += " config_defaults: " + config_defaults + ",\n"
provider += " strict_tls: " + strict_tls + ",\n" provider += " strict_tls: " + strict_tls + ",\n"
provider += " oauth2_authorizer: " + oauth2 + ",\n"
provider += " };\n\n" provider += " };\n\n"
else: else:
raise TypeError("SMTP and IMAP must be specified together or left out both") raise TypeError("SMTP and IMAP must be specified together or left out both")
@@ -125,11 +129,11 @@ def process_data(data, file):
# finally, add the provider # finally, add the provider
global out_all, out_domains global out_all, out_domains
out_all += " // " + file[file.rindex("/")+1:] + ": " + comment.strip(", ") + "\n" out_all += " // " + file[file.rindex("/")+1:] + ": " + comment.strip(", ") + "\n"
if status == "OK" and before_login_hint == "" and after_login_hint == "" and server == "" and config_defaults == "None" and strict_tls == "false":
out_all += " // - skipping provider with status OK and no special things to do\n\n" # also add provider with no special things to do -
else: # eg. _not_ supporting oauth2 is also an information and we can skip the mx-lookup in this case
out_all += provider out_all += provider
out_domains += domains out_domains += domains
def process_file(file): def process_file(file):