示例#1
0
def send_cookie(login):
    session_ttl = int()
    session_ttl = sql.get_setting('session_ttl')
    session_ttl = int(session_ttl)
    expires = datetime.datetime.utcnow() + datetime.timedelta(days=session_ttl)
    user_uuid = str(uuid.uuid4())
    user_token = str(uuid.uuid4())

    c = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
    c["uuid"] = user_uuid
    c["uuid"]["path"] = "/app/"
    c["uuid"]["expires"] = expires.strftime("%a, %d %b %Y %H:%M:%S GMT")
    print(c)
    sql.write_user_uuid(login, user_uuid)
    sql.write_user_token(login, user_token)
    try:
        funct.logging('locahost',
                      sql.get_user_name_by_uuid(user_uuid) + ' log in',
                      haproxywi=1,
                      login=1)
    except:
        pass
    print("Content-type: text/html\n")
    print('ok')
    sys.exit()
示例#2
0
def send_cookie(login):
    session_ttl = int()
    session_ttl = sql.get_setting('session_ttl')
    session_ttl = int(session_ttl)
    expires = datetime.datetime.utcnow() + datetime.timedelta(days=session_ttl)
    user_uuid = str(uuid.uuid4())
    user_token = str(uuid.uuid4())
    sql.write_user_uuid(login, user_uuid)
    sql.write_user_token(login, user_token)

    id = sql.get_user_id_by_uuid(user_uuid)
    user_groups = sql.select_user_groups(id, limit=1)

    c = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
    c["uuid"] = user_uuid
    c["uuid"]["path"] = "/"
    # c["uuid"]["sameSite"] = "Strict"
    c["uuid"]["Secure"] = "True"
    c["uuid"]["expires"] = expires.strftime("%a, %d %b %Y %H:%M:%S GMT")
    c["group"] = user_groups
    c["group"]["path"] = "/"
    # c["group"]["sameSite"] = "Strict"
    c["group"]["Secure"] = "True"
    c["group"]["expires"] = expires.strftime("%a, %d %b %Y %H:%M:%S GMT")
    print(c)

    try:
        funct.logging('locahost',
                      ' ' + sql.get_user_name_by_uuid(user_uuid) + ' log in',
                      haproxywi=1)
    except:
        pass
    print("Content-type: text/html\n")
    print('ok')
    sys.exit()
示例#3
0
def send_cookie(login):
    session_ttl = sql.get_setting('session_ttl')
    session_ttl = int(session_ttl)
    expires = datetime.datetime.utcnow() + datetime.timedelta(days=session_ttl)
    user_uuid = str(uuid.uuid4())
    user_token = str(uuid.uuid4())
    sql.write_user_uuid(login, user_uuid)
    sql.write_user_token(login, user_token)

    id = sql.get_user_id_by_uuid(user_uuid)
    try:
        cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
        user_group_id = cookie.get('group')
        user_group_id = user_group_id.value
        if sql.check_user_group(id, user_group_id):
            user_groups = user_group_id
        else:
            user_groups = sql.select_user_groups(id, limit=1)
    except:
        user_groups = sql.select_user_groups(id, limit=1)

    c = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
    c["uuid"] = user_uuid
    c["uuid"]["path"] = "/app"
    # c["uuid"]["samesite"] = "Strict"
    c["uuid"]["Secure"] = "True"
    c["uuid"]["expires"] = expires.strftime("%a, %d %b %Y %H:%M:%S GMT")
    c["group"] = user_groups
    c["group"]["path"] = "/app"
    # c["group"]["samesite"] = "Strict"
    c["group"]["Secure"] = "True"
    c["group"]["expires"] = expires.strftime("%a, %d %b %Y %H:%M:%S GMT")
    print(c.output())

    try:
        groups = sql.select_groups(id=user_groups)
        for g in groups:
            if g[0] == int(user_groups):
                user_group = g[1]
    except:
        user_group = ''

    try:
        user_name = sql.get_user_name_by_uuid(user_uuid)
        funct.logging('localhost',
                      ' user: '******', group: ' + user_group +
                      ' log in',
                      haproxywi=1)
    except:
        pass
    print("Content-type: text/html\n")
    print('ok')
    sys.exit()
示例#4
0
	session_ttl = sql.get_setting('session_ttl')
	session_ttl = int(session_ttl)
	
	expires = datetime.datetime.utcnow() + datetime.timedelta(days=session_ttl) 
	user_uuid = str(uuid.uuid4())
	user_token = str(uuid.uuid4())
	
	for users in USERS:	
		if login in users[1] and password == users[3]:
			c = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
			c["uuid"] = user_uuid
			c["uuid"]["path"] = "/app/"
			c["uuid"]["expires"] = expires.strftime("%a, %d %b %Y %H:%M:%S GMT")
			print(c)
			sql.write_user_uuid(login, user_uuid)
			sql.write_user_token(login, user_token)
			funct.logging('locahost', sql.get_user_name_by_uuid(user_uuid)+' log in')
			print("Content-type: text/html\n")			
			print('ok')
			sys.exit()	
		
	print("Content-type: text/html\n")	
	print('<center><div class="alert alert-danger">Somthing wrong :( I\'m sad about this, but try again!</div><br /><br />')
	sys.exit()
			
if login is None:
	print("Content-type: text/html\n")	
	if create_db.check_db():
		if create_db.create_table():	
			create_db.update_all()
			db_create = '<div class="alert alert-success">DB was created<br /><br />Now you can login, default: admin/admin</div>'