예제 #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)