セッションの開始時にセッション変数を取得し、結果に基づいて特定のページへのアクセスのみを許可する単純な使用例があります。bindInterceptor を使用して任意のページの @Get メソッドまたは @Post メソッドをインターセプトするのが最善なのか、それともフィルターを使用する方が良いのか、はっきりしていません。これは私がやりたいことのスケッチですが、代替手段を受け入れています:
At the start of a new session (@SessionScoped ?), check a session variable authentication token
If (authentication == admin) {
serveRegex("admin/(jsp|html)/.*").with(GuiceContainer.class); //only allow /admin subpages
req.getRequestDispatcher("/admin").forward(req, res); //fwd all initial page requests to /admin
}
else If (authentication == user) {
serveRegex("user/(jsp|html)/.*").with(GuiceContainer.class); //only allow /user subpages
req.getRequestDispatcher("/user").forward(req, res); //fwd all initial page requests to /user
}
else {
serveRegex("signin/(jsp|html)/.*").with(GuiceContainer.class); //only allow /signin subpages
req.getRequestDispatcher("/signin").forward(req, res); //fwd all initial page requests to /signin
}
このセキュリティ モデルを管理するための推奨される手法 (最小コード、最速など) はどれですか? サンプルプロジェクトを見てみたいです。
ご協力いただきありがとうございます!
-ジョン