1.租赁应用详情创建凭证,第一次没有显示api Secret ,使用密码框,请修正 2. 提供凭证删除功能。
This commit is contained in:
1 parent
6321cde4c0
commit
a83e1fef40
5 files changed
+94
-2
No files matched your search
@@ -131,6 +131,14 @@ public class RentalController {
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/** 删除未使用的本人应用凭证,不能绕过历史引用保护。 */
|
||||
@DeleteMapping("/credential/{id}")
|
||||
@PreAuthorize("@ss.hasPermi('rent:credential:issue')")
|
||||
public AjaxResult removeCredential(@PathVariable long id) {
|
||||
identity.deleteAppCredential(id, user());
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("/wallet/{id}/challenge")
|
||||
@PreAuthorize("@ss.hasPermi('rent:wallet:bind')")
|
||||
public AjaxResult challenge(@PathVariable long id) {
|
||||
|
||||
@@ -130,4 +130,32 @@ public class RentalIdentity {
|
||||
actor,
|
||||
"主动吊销凭证");
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅物理删除未产生业务引用的 APP 凭证。节点凭证必须保留用于原任务验签。
|
||||
* 先锁应用再锁凭证,与签发、下单及应用删除保持一致锁顺序。
|
||||
* 订单未保存请求凭证版本,因此存在任意应用订单时保守拒绝,不猜测密钥是否使用过。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int deleteAppCredential(long id, long actor) {
|
||||
Map<String, Object> snapshot = store.get("credential", id, false);
|
||||
require("APP".equals(text(snapshot, "owner_type")), "节点凭证请使用吊销,不能删除");
|
||||
long appId = number(snapshot, "owner_id");
|
||||
Map<String, Object> app = store.get("app", appId, true);
|
||||
require(number(app, "user_id") == actor, "无应用凭证删除权限");
|
||||
Map<String, Object> credential = store.get("credential", id, true);
|
||||
require("APP".equals(text(credential, "owner_type")) && number(credential, "owner_id") == appId,
|
||||
"凭证归属发生变化,请刷新重试");
|
||||
require(store.one("SELECT id FROM rent_order WHERE app_id=? LIMIT 1 FOR UPDATE", appId) == null,
|
||||
"应用存在历史或在途订单,请保留凭证或使用吊销");
|
||||
require(store.one("SELECT id FROM rent_task WHERE credential_id=? LIMIT 1 FOR UPDATE", id) == null,
|
||||
"凭证存在关联任务,不能删除");
|
||||
require(store.one("SELECT id FROM rent_webhook WHERE credential_id=? LIMIT 1 FOR UPDATE", id) == null,
|
||||
"凭证存在关联回调,不能删除");
|
||||
require(store.one("SELECT id FROM rent_nonce WHERE api_key=? AND expires_at>? LIMIT 1 FOR UPDATE",
|
||||
text(credential, "api_key"), now()) == null, "凭证近期仍在使用,请停止调用并等待认证记录过期后重试");
|
||||
require(store.execute("DELETE FROM rent_credential WHERE id=?", id) == 1, "凭证删除失败");
|
||||
store.event("APP", appId, "DELETE_CREDENTIAL", actor, "删除无业务引用的凭证,凭证ID=" + id);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user