Anh ơi, có nhiều loại Authen như JWT, Basic auth… khi nào ta nên chọn loại authen nào ạ
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
1. JWT: sử dụng chữ ký số, ưu điểm là có thể lưu thông tin của user, chính vì vậy mà nó không cần phải query vào DB để lấy các thông tin như UserId chẳng hạn. Nhưng nhược điểm là nếu dev làm lộ private key thì đó là lỗi bào mật nghiệm trọng, thêm 1 điểm nữa là JWT không cập nhật được thời gian hết hạn, nên nó phù hợp với token dùng 1 lần.
2. Basic auth: Là dùng username, password, vậy chỉ dùng để login lần đầu sau đó lấy token thôi.