2

セキュリティのために Shiro を使用するサービスを作成しています。Guice も組み込みました。で GUICE インジェクターを作成しますGuiceServletContextListener

//Custom Shiro Web module with defined REALM
new MyShiroWebModule(this.servletContext, "/v1/*"),

//Shiro annotations
new MyAOPModule(),

また、Guice Container と GuiceShiroFilter を次のようにバインドしますJerseyServletModule

serve("/v1/*").with(GuiceContainer.class, params);                  
//Adds Shiro filtering  
MyShiroWebModule.bindGuiceFilter(binder());

しかし、Shiro からの注釈は機能していないようです。

でチェーンを構成しますMyShiroWebModule

addFilterChain("/v1/res/test", ANON);
addFilterChain("/v1/**", ROLES, AUTHC_BASIC);

したがって、「ROLES」フィルターを使用すると、次の AOP 方式でロールがスキャンされます。

@RolesAllowed("SomeFancyRole")(編集を参照)

しかし、GUICE Shiro AOP 機能を活用したいと考えています。私は自分自身の代わりにベースの ShiroAOPModule を試しました -> 私は構成が呼び出されているかどうかを確認するためのデバッグ用です。

@User, @Authenticated etc.

この機能をどのように組み込むことができますか? 前もって感謝します

編集:

@RolesAllowed以下を追加したおかげで、が機能していることがわかりました。

params.put(PackagesResourceConfig.PROPERTY_RESOURCE_FILTER_FACTORIES, "com.sun.jersey.api.container.filter.RolesAllowedResourceFilterFactory");

JerseyServletModule で

serve("/v1/*").with(GuiceContainer.class, params);

そのため、Shiro からの AOP はまだフィルタリングされていません。

4

1 に答える 1