Web 共通のセキュリティ制約を使用して API に認証を追加していますが、CORS フィルターが壊れているようです。私は以前、フィルターのみで動作し、アプリサーバーレベルの認証はありませんでした。
基本的な考え方は、/rest/account エンドポイントを除くすべてのリクエストで認証を要求することです。これは、これらが最初のログインを処理するものであり、パブリックにアクセスできる必要があるためです。
Chrome と Postman の両方でテストすると、ログイン時に POST 要求の一部として OPTIONS 呼び出しが行われると、405 Method not allowed 応答が返されます。
以下に関連するすべてを提供できれば幸いですが、他に何か必要な場合はお知らせください。前もって感謝します!
私の CORS フィルター
<filter>
<filter-name>CORS</filter-name>
<filter-class>com.thetransactioncompany.cors.CORSFilter</filter-class>
<init-param>
<param-name>cors.supportedMethods</param-name>
<param-value>*</param-value>
</init-param>
<init-param>
<param-name>cors.supportedHeaders</param-name>
<param-value>*</param-value>
</init-param>
<init-param>
<param-name>cors.allowOrigin</param-name>
<param-value>*</param-value>
</init-param>
<init-param>
<param-name>cors.allowSubdomains</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>cors.supportsCredentials</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CORS</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
私のセキュリティ上の制約
<security-constraint>
<display-name>WebsiteUsers</display-name>
<web-resource-collection>
<web-resource-name>WebsiteAPI</web-resource-name>
<description/>
<url-pattern>/rest/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<description>Standard User authentication</description>
<role-name>Users</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>Public</web-resource-name>
<description>Matches a few special endpoints</description>
<url-pattern>/rest/account/*</url-pattern>
</web-resource-collection>
<!-- No auth-constraint means everybody has access! -->
</security-constraint>