Basic Authentication là phương thức xác thực đơn giản nhất trong HTTP.
Cách hoạt động:
Authorization: Basic base64(username:password)Ưu điểm: Đơn giản, dễ triển khai
Nhược điểm: Không bảo mật cao nếu không dùng HTTPS, phải gửi credentials mỗi request
Endpoint:
https://material.playwrightvn.com/api/authentication/basic_auth.php
Method: GET
Credentials: bba / demo_password
Click "Test Basic Auth" to see response
JWT (JSON Web Token) là một chuẩn mở để truyền tải thông tin xác thực một cách an toàn.
Cách hoạt động:
Authorization: Bearer <token>Cấu trúc JWT: Header.Payload.Signature
Ưu điểm: Stateless, scalable, có thể chứa thông tin user
Nhược điểm: Token có thể bị đánh cắp, khó thu hồi token trước khi hết hạn
Endpoint Login:
https://material.playwrightvn.com/api/authentication/jwt_login.php
Method: POST
Credentials: bba / demo_password
Click "Test JWT Login" to see response
Endpoint:
https://material.playwrightvn.com/api/authentication/jwt_auth.php
Method: GET
Authentication type: Bearer token
Session Authentication sử dụng session được lưu trên server và cookie trên client.
Cách hoạt động:
Ưu điểm: An toàn, dễ quản lý và thu hồi session, phù hợp với web app
Nhược điểm: Stateful (lưu trữ trên server), khó scale với distributed systems
Endpoint Login:
https://material.playwrightvn.com/api/authentication/session_auth.php
Method: POST
Credentials: bba / demo_password
Click "Test Session Auth" to see response
Endpoint:
https://material.playwrightvn.com/api/authentication/session_test.php
Method: GET
Authentication type: COOKIE with returned header
SOAP (Simple Object Access Protocol) là một giao thức truyền thông dựa trên XML để trao đổi thông tin giữa các ứng dụng.
Cách hoạt động:
Cấu trúc SOAP Message:
Ưu điểm:
Nhược điểm:
So sánh SOAP vs REST:
| Tiêu chí | SOAP | REST |
|---|---|---|
| Kiểu | Giao thức (Protocol) | Kiến trúc (Architecture) |
| Format | Chỉ XML | JSON, XML, HTML... |
| Bảo mật | WS-Security (rất mạnh) | HTTPS, OAuth, JWT |
| Performance | Chậm hơn | Nhanh hơn |
| Sử dụng | Banking, Finance, Enterprise | Web, Mobile, Microservices |
SOAP Server Endpoint:
https://material.playwrightvn.com/api/authentication/soap/server.php
WSDL File:
https://material.playwrightvn.com/api/authentication/soap/authentication.wsdl
Method: POST
Content-Type: text/xml; charset=utf-8
Valid Credentials:
admin / Password: admin123user1 / Password: pass123testuser / Password: test456Click "Test SOAP Login" to see response
Click "Test SOAP Register" to see response
Click "Test Verify Token" to see response
Click "Test Get User Info" to see response
Click "Test Logout" to see response
Login Request:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tns="https://material.playwrightvn.com/api/authentication/soap/">
<soap:Body>
<tns:login>
<tns:username>admin</tns:username>
<tns:password>admin123</tns:password>
</tns:login>
</soap:Body>
</soap:Envelope>
Register Request:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tns="https://material.playwrightvn.com/api/authentication/soap/">
<soap:Body>
<tns:register>
<tns:username>newuser</tns:username>
<tns:password>newpass123</tns:password>
<tns:email>newuser@example.com</tns:email>
</tns:register>
</soap:Body>
</soap:Envelope>
Verify Token Request:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tns="https://material.playwrightvn.com/api/authentication/soap/">
<soap:Body>
<tns:verifyToken>
<tns:token>YOUR_TOKEN_HERE</tns:token>
</tns:verifyToken>
</soap:Body>
</soap:Envelope>