Giao diện
@digiforce-nc/plugin-idp-oauth
Plugin OAuth Identity Provider — biến ứng dụng Digiforce thành OAuth 2.0 provider, cho phép ứng dụng bên thứ ba đăng nhập qua Digiforce.
Plugin này làm gì?
Thông thường, Digiforce kết nối đến IdP bên ngoài (Google, GitHub...) để đăng nhập. Plugin này làm ngược lại: biến Digiforce thành IdP, cấp phát access token cho ứng dụng third-party theo chuẩn OAuth 2.0 (Authorization Code, Client Credentials).
Cơ chế hoạt động
Tính năng chính
| # | Tính năng | Mô tả |
|---|---|---|
| 1 | Authorization Code | Flow chuẩn cho web app |
| 2 | Client Credentials | Flow cho server-to-server |
| 3 | Consent screen | Hiển thị quyền app yêu cầu để user đồng ý |
| 4 | Token management | Access token, refresh token, revoke |
| 5 | Scopes | Giới hạn quyền truy cập (profile, email, read, write) |
| 6 | Client registry | Quản lý OAuth client (client_id, client_secret) |
API endpoints
| Endpoint | Mô tả |
|---|---|
GET /oauth/authorize | Authorization endpoint |
POST /oauth/token | Token endpoint (exchange code, refresh) |
POST /oauth/revoke | Thu hồi token |
GET /oauth/userinfo | Thông tin user (OpenID Connect) |
oauthClients CRUD | Quản lý OAuth client |
Database
| Bảng | Mô tả |
|---|---|
oauthClients | Đăng ký client (id, secret, redirect_uri, scopes) |
oauthAuthorizationCodes | Authorization codes (code, clientId, userId, expiresAt) |
oauthAccessTokens | Access tokens (token, clientId, userId, scopes) |
oauthRefreshTokens | Refresh tokens |
Thành phần client
| Thành phần | Mô tả |
|---|---|
OAuthClientList | Danh sách OAuth clients đã đăng ký |
OAuthClientForm | Form tạo/sửa OAuth client |
ConsentScreen | Giao diện đồng ý ủy quyền cho user |
TokenManager | Quản lý và thu hồi token |
Dependencies
| Package | Vai trò |
|---|---|
@digiforce-nc/server | Server framework |
@digiforce-nc/database | Database ORM |
@digiforce-nc/client | Client UI framework |
@digiforce-nc/auth | Auth framework |