legacy-knowledge-base
公開されました Jul. 2, 2025

PortalSessionAuthVerifierが有効な場合、ゲストユーザーがエンドポイントにアクセスできる。

written-by

Jose L. Bango

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

legacy-article

learn-legacy-article-disclaimer-text

問題

  • このHow-To記事に従いました: How to add security, authentication to my REST service? (セクション5.1)に従いましたが、ゲストユーザーはまだブラウザから私たちのエンドポイントにアクセスすることができます。
  • PortalSessionAuthVerifierを有効にすると、アクティブなセッションを持たないユーザーもエンドポイントにアクセスできるようになります。

環境

  • Liferay DXP 7.0

解像度

  • DXP 7.0のAuthVerifiersレイヤーの設計により、ゲストユーザーがエンドポイントにアクセスするのを防ぐために余分なステップが必要になります。
  • RESTアプリケーションの内部にユーザーパーミッションレイヤーを実装し、以下のように追加することで、ユーザーがサインインしているかどうかをチェックします:
    PermissionChecker permissionChecker = PermissionThreadLocal.getPermissionChecker();

    if (!permissionChecker.isSignedIn()) {
    throw new WebApplicationException(Response.Status.FORBIDDEN);
    }

追加情報

did-this-article-resolve-your-issue

legacy-knowledge-base