租赁账户PROXY\_ACCOUNT中的rentApp租赁应用页面需要有引导用户创建应用功能,和应用详情,应用详情中需要能够创建对应的应用凭证,要求页面美观,用户交互友好。

This commit is contained in:
lu7213 committed 2026-10-25 01:47:02 -04:00
1 parent b3419aa389
commit 101140f3c2
4 files changed
+77 -2

No files matched your search

@@ -68,6 +68,20 @@ public class RentalController {
return AjaxResult.success(queries.list(resource, user(), page));
}
/** 本人应用详情;显式选列,禁止返回明文或加密 Secret。 */
@GetMapping("/app/{id}")
@PreAuthorize("@ss.hasPermi('rent:portal:view')")
public AjaxResult appDetail(@PathVariable long id) {
Map<String, Object> app = store.one(
"SELECT id,name,status,notify_url,created_at,updated_at FROM rent_app WHERE id=? AND user_id=?",
id, user());
require(app != null, "应用不存在或无权访问");
List<Map<String, Object>> credentials = store.rows(
"SELECT id,api_key,status,expires_at,created_at FROM rent_credential"
+ " WHERE owner_type='APP' AND owner_id=? ORDER BY id DESC", id);
return AjaxResult.success(map("app", app, "credentials", credentials));
}
@GetMapping("/manage/{resource}")
@PreAuthorize("@ss.hasPermi('rent:manage:list')")
public AjaxResult manage(
@@ -40,6 +40,36 @@ public class RentalBusinessTest {
private static final String OWNER = "TR7NHqjeKQxGTCi8q8ZY4pL8otgjLj6t";
private final ObjectMapper json = new ObjectMapper();
/** 真实查询验证应用隔离、节点凭证隔离与 Secret 不外泄。 */
@Test
public void appDetailIsOwnedAndNeverReturnsSecrets() {
com.ruoyi.common.core.domain.entity.SysUser user =
new com.ruoyi.common.core.domain.entity.SysUser();
user.setUserId(10L);
com.ruoyi.common.core.domain.model.LoginUser login =
new com.ruoyi.common.core.domain.model.LoginUser(user, Collections.emptySet());
org.springframework.security.core.context.SecurityContextHolder.getContext().setAuthentication(
new org.springframework.security.authentication.UsernamePasswordAuthenticationToken(
login, null, Collections.emptyList()));
try {
tx.execute(status -> identity.issue("APP", app, 10));
tx.execute(status -> identity.issue("NODE", node, 20));
RentalController controller = new RentalController(
store, null, identity, orders, funds, reviews, tasks, null, null);
Map<String, Object> result = (Map<String, Object>) controller.appDetail(app).get("data");
List<Map<String, Object>> credentials =
(List<Map<String, Object>>) result.get("credentials");
assertEquals(1, credentials.size());
assertTrue(credentials.get(0).containsKey("api_key"));
assertFalse(credentials.get(0).containsKey("api_secret"));
long foreign = store.insert("app", map("user_id", 20, "name", "foreign", "status", "ACTIVE"));
expectFailure(() -> controller.appDetail(foreign));
expectFailure(() -> controller.appDetail(Long.MAX_VALUE));
} finally {
org.springframework.security.core.context.SecurityContextHolder.clearContext();
}
}
@Before
public void setup() throws Exception {
JdbcDataSource source = new JdbcDataSource();