限制seafile注册邮箱域名

seafile本身没有限制注册邮箱域名的功能,看社区里官方提到也不考虑增加这个功能,说实话挺遗憾,多么实用的功能。
既然是开源的,那就想办法改动下代码吧,以对接OAUTH的场景为例:
修改backends处理流程

vim <root of seafile>/seafile-server-latest/seahub/seahub/oauth/backends.py

需要用到正则表达式,在文件开头引入re模块

import re

在def authenticate(self, remote_user) 函数中,create user语句之前,增加以下内容:

        pattern = r'^(.)+@gmail\.com$'
        email_m = re.match(pattern, username)
        # 不允许匹配到的邮箱域名注册
        if email_m is not None:
            return

保存,重启seahub生效
用gmail.com邮箱登录的用户会提示没有该用户
更复杂的处理逻辑,自由发挥吧