Interface LoginPolicy

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface LoginPolicy

登入把關政策接點(ADR-018 決策五;宿主與簽章依 ADR-023 上收)

多前端共用單一 server 的專案以此裁決「此主體可否從指定前端登入」——這是「前門(login)」 層級控制:擋的是「能否從某前端取得 session」,非每請求的 API 授權(後者由 authority/role 承擔)。

框架不提供實作——無 bean 時放行(單前端專案零感知);多前端專案在自己的 package 提供政策 bean。政策實作與 principal adapter 同屬消費端,需要 per-project 欄位時 downcast 自己的 principal 型別即可。

falseLoginService 會建立帶 principal/app 脈絡的 LoginPolicyDeniedException; 政策也可自行拋其子類,加入產品特定診斷。兩者都保留到最終 response policy。

  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    allows(AuthPrincipal principal, String app)
    此主體可否從指定前端登入
  • Method Details

    • allows

      boolean allows(AuthPrincipal principal, String app)
      此主體可否從指定前端登入
      Parameters:
      principal - 已認證的主體(政策實作可 downcast 為自家 adapter 型別取用擴充欄位)
      app - 登入來源前端識別(wire 上為 LoginRequest.app;可為 null=未聲明來源,由政策決定寬嚴)
      Returns:
      true 放行;false 由 LoginService 轉為帶完整脈絡的拒絕例外
      Throws:
      LoginPolicyDeniedException - 政策需要提供自訂拒絕診斷時可直接拋出