承認されていないアクセスからの GAE アプリケーションのセキュリティー保護は、Google App Engine ドキュメントの Security and Authentication セクションを参照してください。承認制約は web.xml ファイルで宣言されます( 「web.xml」を参照してください)。これは Apache Camel アプリケーションにも適用されます。以下の例では、アプリケーションは、認証されたユーザー(任意のロール)のみがアプリケーションにアクセスできるように設定されます。さらに、/worker/\* URL へのアクセスは、admin ロールを持つユーザーのみが実行できます。デフォルトでは、gtask コンポーネントによってインストールされた Web フック URL は /worker/\* パターンに一致し、通常のユーザーがアクセスすることはできません。この認可制約では、タスクキューイングサービス(常に admin ロール)のみが Web フックにアクセスできます。カスタムで宣言的ではない承認ロジックを実装するには、Apache Camel GAE アプリケーションは Google Accounts Java API を使用する必要があります。
例54.1 web.xml (承認制約あり)
<web-app
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<servlet>
<servlet-name>CamelServlet</servlet-name>
<servlet-class>org.apache.camel.component.servlet.CamelHttpTransportServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>appctx.xml</param-value>
</init-param>
</servlet>
<!--
Mapping used for external requests
-->
<servlet-mapping>
<servlet-name>CamelServlet</servlet-name>
<url-pattern>/camel/*</url-pattern>
</servlet-mapping>
<!--
Mapping used for web hooks accessed by task queueing service.
-->
<servlet-mapping>
<servlet-name>CamelServlet</servlet-name>
<url-pattern>/worker/*</url-pattern>
</servlet-mapping>
<!--
By default allow any user who is logged in to access the whole
application.
-->
<security-constraint>
<web-resource-collection>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>*</role-name>
</auth-constraint>
</security-constraint>
<!--
Allow only admin users to access /worker/* URLs e.g. to prevent
normal user to access gtask web hooks.
-->
<security-constraint>
<web-resource-collection>
<url-pattern>/worker/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>admin</role-name>
</auth-constraint>
</security-constraint>
</web-app>
<web-app
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<servlet>
<servlet-name>CamelServlet</servlet-name>
<servlet-class>org.apache.camel.component.servlet.CamelHttpTransportServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>appctx.xml</param-value>
</init-param>
</servlet>
<!--
Mapping used for external requests
-->
<servlet-mapping>
<servlet-name>CamelServlet</servlet-name>
<url-pattern>/camel/*</url-pattern>
</servlet-mapping>
<!--
Mapping used for web hooks accessed by task queueing service.
-->
<servlet-mapping>
<servlet-name>CamelServlet</servlet-name>
<url-pattern>/worker/*</url-pattern>
</servlet-mapping>
<!--
By default allow any user who is logged in to access the whole
application.
-->
<security-constraint>
<web-resource-collection>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>*</role-name>
</auth-constraint>
</security-constraint>
<!--
Allow only admin users to access /worker/* URLs e.g. to prevent
normal user to access gtask web hooks.
-->
<security-constraint>
<web-resource-collection>
<url-pattern>/worker/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>admin</role-name>
</auth-constraint>
</security-constraint>
</web-app>
Copy to ClipboardCopied!Toggle word wrapToggle overflow