本文整理汇总了Python中pritunl.server.Server.get_org方法的典型用法代码示例。如果您正苦于以下问题:Python Server.get_org方法的具体用法?Python Server.get_org怎么用?Python Server.get_org使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pritunl.server.Server
的用法示例。
在下文中一共展示了Server.get_org方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: server_client_connect_post
# 需要导入模块: from pritunl.server import Server [as 别名]
# 或者: from pritunl.server.Server import get_org [as 别名]
def server_client_connect_post(server_id):
org_id = flask.request.json['org_id']
user_id = flask.request.json['user_id']
server = Server(server_id)
if not server:
return utils.jsonify({
'error': SERVER_INVALID,
'error_msg': SERVER_INVALID_MSG,
}, 401)
org = server.get_org(org_id)
if not org:
return utils.jsonify({
'error': ORG_INVALID,
'error_msg': ORG_INVALID_MSG,
}, 401)
user = org.get_user(user_id)
if not user:
return utils.jsonify({
'error': USER_INVALID,
'error_msg': USER_INVALID_MSG,
}, 401)
return utils.jsonify({
'client_conf': None,
})
示例2: server_tls_verify_post
# 需要导入模块: from pritunl.server import Server [as 别名]
# 或者: from pritunl.server.Server import get_org [as 别名]
def server_tls_verify_post(server_id):
org_id = flask.request.json['org_id']
user_id = flask.request.json['user_id']
server = Server(server_id)
if not server:
return utils.jsonify({
'error': SERVER_INVALID,
'error_msg': SERVER_INVALID_MSG,
}, 401)
org = server.get_org(org_id)
if not org:
LogEntry(message='User failed authentication, ' +
'invalid organization "%s".' % server.name)
return utils.jsonify({
'error': ORG_INVALID,
'error_msg': ORG_INVALID_MSG,
}, 401)
user = org.get_user(user_id)
if not user:
LogEntry(message='User failed authentication, ' +
'invalid user "%s".' % server.name)
return utils.jsonify({
'error': USER_INVALID,
'error_msg': USER_INVALID_MSG,
}, 401)
return utils.jsonify({
'authenticated': True,
})
示例3: server_client_disconnect_post
# 需要导入模块: from pritunl.server import Server [as 别名]
# 或者: from pritunl.server.Server import get_org [as 别名]
def server_client_disconnect_post(server_id):
org_id = flask.request.json["org_id"]
user_id = flask.request.json["user_id"]
server = Server(server_id)
if not server:
return utils.jsonify({"error": SERVER_INVALID, "error_msg": SERVER_INVALID_MSG}, 401)
org = server.get_org(org_id)
if not org:
return utils.jsonify({"error": ORG_INVALID, "error_msg": ORG_INVALID_MSG}, 401)
user = org.get_user(user_id)
if not user:
return utils.jsonify({"error": USER_INVALID, "error_msg": USER_INVALID_MSG}, 401)
return utils.jsonify({})
示例4: server_tls_verify_post
# 需要导入模块: from pritunl.server import Server [as 别名]
# 或者: from pritunl.server.Server import get_org [as 别名]
def server_tls_verify_post(server_id):
org_id = flask.request.json["org_id"]
user_id = flask.request.json["user_id"]
server = Server(server_id)
if not server:
return utils.jsonify({"error": SERVER_INVALID, "error_msg": SERVER_INVALID_MSG}, 401)
org = server.get_org(org_id)
if not org:
LogEntry(message="User failed authentication, " + 'invalid organization "%s".' % server.name)
return utils.jsonify({"error": ORG_INVALID, "error_msg": ORG_INVALID_MSG}, 401)
user = org.get_user(user_id)
if not user:
LogEntry(message="User failed authentication, " + 'invalid user "%s".' % server.name)
return utils.jsonify({"error": USER_INVALID, "error_msg": USER_INVALID_MSG}, 401)
if user.disabled:
LogEntry(message="User failed authentication, " + 'disabled user "%s".' % server.name)
return utils.jsonify({"error": USER_INVALID, "error_msg": USER_INVALID_MSG}, 401)
return utils.jsonify({"authenticated": True})
示例5: server_otp_verify_post
# 需要导入模块: from pritunl.server import Server [as 别名]
# 或者: from pritunl.server.Server import get_org [as 别名]
def server_otp_verify_post(server_id):
org_id = flask.request.json['org_id']
user_id = flask.request.json['user_id']
otp_code = flask.request.json['otp_code']
remote_ip = flask.request.json.get('remote_ip')
server = Server(server_id)
if not server:
return utils.jsonify({
'error': SERVER_INVALID,
'error_msg': SERVER_INVALID_MSG,
}, 401)
org = server.get_org(org_id)
if not org:
LogEntry(message='User failed authentication, ' +
'invalid organization "%s".' % server.name)
return utils.jsonify({
'error': ORG_INVALID,
'error_msg': ORG_INVALID_MSG,
}, 401)
user = org.get_user(user_id)
if not user:
LogEntry(message='User failed authentication, ' +
'invalid user "%s".' % server.name)
return utils.jsonify({
'error': USER_INVALID,
'error_msg': USER_INVALID_MSG,
}, 401)
if not user.verify_otp_code(otp_code, remote_ip):
LogEntry(message='User failed two-step authentication "%s".' % (
user.name))
return utils.jsonify({
'error': OTP_CODE_INVALID,
'error_msg': OTP_CODE_INVALID_MSG,
}, 401)
return utils.jsonify({
'authenticated': True,
})
示例6: server_otp_verify_post
# 需要导入模块: from pritunl.server import Server [as 别名]
# 或者: from pritunl.server.Server import get_org [as 别名]
def server_otp_verify_post(server_id):
org_id = flask.request.json["org_id"]
user_id = flask.request.json["user_id"]
otp_code = flask.request.json["otp_code"]
remote_ip = flask.request.json.get("remote_ip")
server = Server(server_id)
if not server:
return utils.jsonify({"error": SERVER_INVALID, "error_msg": SERVER_INVALID_MSG}, 401)
org = server.get_org(org_id)
if not org:
LogEntry(message="User failed authentication, " + 'invalid organization "%s".' % server.name)
return utils.jsonify({"error": ORG_INVALID, "error_msg": ORG_INVALID_MSG}, 401)
user = org.get_user(user_id)
if not user:
LogEntry(message="User failed authentication, " + 'invalid user "%s".' % server.name)
return utils.jsonify({"error": USER_INVALID, "error_msg": USER_INVALID_MSG}, 401)
if not user.verify_otp_code(otp_code, remote_ip):
LogEntry(message='User failed two-step authentication "%s".' % (user.name))
return utils.jsonify({"error": OTP_CODE_INVALID, "error_msg": OTP_CODE_INVALID_MSG}, 401)
return utils.jsonify({"authenticated": True})
示例7: server_client_connect_post
# 需要导入模块: from pritunl.server import Server [as 别名]
# 或者: from pritunl.server.Server import get_org [as 别名]
def server_client_connect_post(server_id):
org_id = flask.request.json["org_id"]
user_id = flask.request.json["user_id"]
server = Server(server_id)
if not server:
return utils.jsonify({"error": SERVER_INVALID, "error_msg": SERVER_INVALID_MSG}, 401)
org = server.get_org(org_id)
if not org:
return utils.jsonify({"error": ORG_INVALID, "error_msg": ORG_INVALID_MSG}, 401)
user = org.get_user(user_id)
if not user:
return utils.jsonify({"error": USER_INVALID, "error_msg": USER_INVALID_MSG}, 401)
if user.type != CERT_CLIENT:
return utils.jsonify({"error": USER_TYPE_INVALID, "error_msg": USER_TYPE_INVALID_MSG}, 401)
local_ip_addr, remote_ip_addr = server.get_ip_set(org.id, user_id)
if local_ip_addr and remote_ip_addr:
client_conf = "ifconfig-push %s %s" % (local_ip_addr, remote_ip_addr)
else:
client_conf = ""
return utils.jsonify({"client_conf": client_conf})
示例8: server_client_connect_post
# 需要导入模块: from pritunl.server import Server [as 别名]
# 或者: from pritunl.server.Server import get_org [as 别名]
def server_client_connect_post(server_id):
org_id = flask.request.json['org_id']
user_id = flask.request.json['user_id']
server = Server(server_id)
if not server:
return utils.jsonify({
'error': SERVER_INVALID,
'error_msg': SERVER_INVALID_MSG,
}, 401)
org = server.get_org(org_id)
if not org:
return utils.jsonify({
'error': ORG_INVALID,
'error_msg': ORG_INVALID_MSG,
}, 401)
user = org.get_user(user_id)
if not user:
return utils.jsonify({
'error': USER_INVALID,
'error_msg': USER_INVALID_MSG,
}, 401)
if user.type != CERT_CLIENT:
return utils.jsonify({
'error': USER_TYPE_INVALID,
'error_msg': USER_TYPE_INVALID_MSG,
}, 401)
local_ip_addr, remote_ip_addr = server.get_ip_set(org.id, user_id)
if local_ip_addr and remote_ip_addr:
client_conf = 'ifconfig-push %s %s' % (local_ip_addr, remote_ip_addr)
else:
client_conf = ''
return utils.jsonify({
'client_conf': client_conf,
})