本文整理匯總了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,
})