I have WSO2 API Manager 4.0.0 running on kubernetes. I need to be able to configure CORS on the oauth2 endpoint. Following the documentation I've tried this one and this other one.
When I use the second one outside a container it works. In kubernetes I've tried to mount a ConfigMap with web.xml
in wso2-config-volume/repository/deployment/server/webapps/oauth2/WEB-INF/
I've also tried mounting it in ${WSO2_SERVER_HOME}/repository/deployment/server/webapps/oauth2/WEB-INF/
Both cause the following error on startup.
[/oauth2] Servlet [OAuth2Endpoints] in web application [/oauth2] threw load() exception
java.lang.ClassNotFoundException: org.apache.cxf.transport.servlet.CXFServlet
I thought that there was a problem with the oauth2.war deployment if the file web.xml already existed so I created a container with the oauth2 folder already created and a web.xml already configured. However, it gets overwritten. Finally, I tried to delete the oauth2.war so that the file won't be overwritten. The oauth2 webapp won't work, it returns 404 errors.
Is there any way to configure CORS for the oauth2 endpoints while running on kubernetes?
Can you try the following in your dockerfile?
ARG WSO2_SERVER_NAME=wso2am
ARG WSO2_SERVER_VERSION=4.0.0
ARG USER=wso2carbon
ARG USER_HOME=/home/${USER}
ARG WSO2_SERVER=${WSO2_SERVER_NAME}-${WSO2_SERVER_VERSION}
ARG WSO2_SERVER_HOME=${USER_HOME}/${WSO2_SERVER}
ARG WEB_APP_DIR=${WSO2_SERVER_HOME}/repository/deployment/server/webapps
COPY oauth2-web.xml ${WSO2_SERVER_HOME}/
RUN mkdir ${WEB_APP_DIR}/oauth2 \
&& unzip -q ${WEB_APP_DIR}/oauth2.war -d ${WEB_APP_DIR}/oauth2 \
&& cp ${WSO2_SERVER_HOME}/oauth2-web.xml ${WEB_APP_DIR}/oauth2/WEB-INF/web.xml \
&& rm ${WEB_APP_DIR}/oauth2.war \
&& rm ${WSO2_SERVER_HOME}/oauth2-web.xml \
&& chown wso2carbon:wso2 -R ${WEB_APP_DIR}/oauth2