1
This commit is contained in:
parent
fc583312ca
commit
9673840fa3
62
server/mailsender/mailsender.py
Normal file
62
server/mailsender/mailsender.py
Normal file
@ -0,0 +1,62 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/python
|
||||
|
||||
import sys
|
||||
sys.path.append('../local_packages')
|
||||
import q7
|
||||
import f7
|
||||
|
||||
import os
|
||||
import json
|
||||
|
||||
from google.oauth2 import id_token
|
||||
from google.auth.transport import requests
|
||||
|
||||
CONFIG_DIR = '../config' if f7.isOnlineEnv() else '/var/data/conf_test/loginserver_be/config'
|
||||
|
||||
def __loginGoogleAuth(request):
|
||||
try:
|
||||
client_id = request('client_id', '')
|
||||
token = request('token', '')
|
||||
idinfo = id_token.verify_oauth2_token(token, requests.Request(), client_id)
|
||||
return json.dumps({
|
||||
'errcode': 0,
|
||||
'errmsg': '',
|
||||
'openid': idinfo['sub']
|
||||
})
|
||||
except Exception as e:
|
||||
return json.dumps({
|
||||
'errcode': 101,
|
||||
'errmsg': '认证失败' + str(e),
|
||||
})
|
||||
|
||||
def __loginAuth(request):
|
||||
gameid = request('gameid', '')
|
||||
channel = request('channel', '')
|
||||
if channel != '6512':
|
||||
return json.dumps({
|
||||
'errcode': 100,
|
||||
'errmsg': '不支持该渠道',
|
||||
})
|
||||
return __loginGoogleAuth(request)
|
||||
|
||||
def getConf():
|
||||
cluster_conf = json.loads(open(CONFIG_DIR + '/loginserver_be.cluster.json', 'r').read())
|
||||
for conf in cluster_conf:
|
||||
if conf['instance_id'] == f7.app.getInstanceId():
|
||||
return conf
|
||||
return None
|
||||
|
||||
if __name__ == "__main__":
|
||||
q7.xPrint('pid %d' % os.getpid())
|
||||
f7.app.init('/data/logs/loginserver_be/logs')
|
||||
f7.udplog.info('loginserver_be start pid:%d node_id:%d instance_id:%d' % (
|
||||
os.getpid(),
|
||||
f7.app.getNodeId(),
|
||||
f7.app.getInstanceId())
|
||||
)
|
||||
|
||||
conf = getConf()
|
||||
# f7.app.registerHandler('Login', 'auth', __loginAuth)
|
||||
f7.app.listen(conf['listen_port'])
|
||||
f7.app.start()
|
Loading…
x
Reference in New Issue
Block a user