Пример #1
0
	def gen_session(self, username):
		token = Token()
		self.user = username

		hA1 = hash_all(self.user)
		hA2 = hash_all(token.ip, token.uri)

		session = digest(hA1, hA2, self.qop, self.realm)
		self.sessions[hA1] = session
		return session
Пример #2
0
	def gen_session(self, username):
		token = Token()
		self.user = username
		
		hA1 = hash_all(self.user)
		hA2 = hash_all(token.ip, token.uri)
		
		session = digest(hA1, hA2, self.qop, self.realm)
		self.sessions[hA1] = session
		return session
Пример #3
0
    def authenticate(self):
        auth = request.authorization
        if auth is None: raise Challenge(self)

        self.check_header(auth)
        self.check_nonce(auth)

        hA1 = self.get_key(auth.username)
        hA2 = hash_all(request.method, auth.uri)
        if hA1 is None: raise Unauthorized()

        if auth.response != digest(hA1, hA2):
            raise Unauthorized()
Пример #4
0
    def add_headers(self, response):
        response = make_response(response)
        auth = request.authorization

        hA1 = self.get_key(auth.username)
        hA2 = hash_all('', auth.uri)
        rspauth = digest(hA1, hA2)

        response.headers['Authentication-Info'] = dump_header({
            'rspauth': rspauth, 'qop': auth.qop,
            'cnonce': auth.cnonce, 'nc': auth.nc
        })

        return response
Пример #5
0
def singUp():
    data = request.json
    nome = data.get("nome")
    email = data.get("email")
    senha = data.get("senha")
    ddd = data.get("ddd")
    sexo = data.get("sexo")

    hashed_pwrd = hash_all(email, realm, senha)

    query = """INSERT INTO table_usuario (nome, email, senha, ddd, sexo) VALUES ('"""+\
            str(nome)+"""','"""+str(email)+"""','"""+str(hashed_pwrd)+"""',"""+ddd+""",'"""+str(sexo)+"""')"""
    print(query)
    response = json.dumps(consulta_db.update_BD(query))
    response = make_response(response)

    return response
Пример #6
0
 def wrapper(username, password, *args, **kargs):
     password = hash_all(username, self.realm, password)
     return func(username, password, *args, **kargs)
Пример #7
0
	def logout(self):
		hA1 = hash_all(auth.user)
		del self.sessions[hA1]
		self.user = ''
		return False
Пример #8
0
	def check_session(self):
		if self.user is None: return False

		hA1 = hash_all(self.user)
		return self.sessions.get(hA1, False)
Пример #9
0
	def check_password(self, hashed_password, user_pass, username):
		return hashed_password == hash_all(username, self.realm, user_pass)
Пример #10
0
	def logout(self):
		hA1 = hash_all(auth.user)
		del self.sessions[hA1]
		self.user = ''
		return False
Пример #11
0
	def check_session(self):
		if self.user is None: return False
		
		hA1 = hash_all(self.user)
		return self.sessions.get(hA1, False)
Пример #12
0
	def check_password(self, hashed_password, user_pass, username):
		return hashed_password == hash_all(username, self.realm, user_pass)