camunda-excamad icon indicating copy to clipboard operation
camunda-excamad copied to clipboard

No access ! CORS error

Open getsueineko opened this issue 2 years ago • 16 comments

I ran excamad via docker and added section

  <filter>
  <filter-name>CorsFilter</filter-name>
  <filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
  <init-param>
    <param-name>cors.allowed.origins</param-name>
    <param-value>*</param-value>
  </init-param>
  </filter>
  <filter-mapping>
      <filter-name>CorsFilter</filter-name>
      <url-pattern>/*</url-pattern>
  </filter-mapping>

in files /camunda/conf/web.xml and /camunda/webapps/engine-rest/WEB-INF/web.xml

But I am getting access error. No access ! Check: CORS enabled. URL Camunda REST EndPoint is ok. You have network access to Camunda server.

Although U got 200 status code and CORS error. What am I doing wrong?

error1

error2

getsueineko avatar May 17 '22 11:05 getsueineko

Hi! Somebody had same issue - https://github.com/KotskinKotskin/camunda-excamad/issues/25, maybe their thougs will be helpfull

KotskinKotskin avatar May 17 '22 11:05 KotskinKotskin

I've got the same issue. Camunda(7.16.0) + modyfied /camunda/conf/web.xml and /camunda/webapps/engine-rest/WEB-INF/web.xml with the same CORS XML blocks.

Zl0n1k avatar May 17 '22 12:05 Zl0n1k

@KotskinKotskin nope. I made changes like in issue - https://github.com/KotskinKotskin/camunda-excamad/issues/25 but I haven't success. Just I got new header and nothing more =(

error3

getsueineko avatar May 17 '22 12:05 getsueineko

Can you please specify used docker image, i will be checking evening

KotskinKotskin avatar May 17 '22 12:05 KotskinKotskin

I used image from https://hub.docker.com/r/kotovdenis/excamad Today setup

P.S By the way https://cadmin.bpmn2.ru/ is not available

getsueineko avatar May 17 '22 13:05 getsueineko

I mean camunda docker :) Excamad image is fine, 146% guaranteed

KotskinKotskin avatar May 18 '22 20:05 KotskinKotskin

I mean camunda docker :) Excamad image is fine, 146% guaranteed

Oh I see =) Below dockerfile of my camunda. Yeah, I know it's not best practice style, but it's gold legacy. The web.xml is here https://pastebin.com/2kv2Lvae

FROM alpine:3.12 as builder

ARG VERSION=7.16.0
ARG DISTRO=tomcat
ARG SNAPSHOT=true

ARG EE=false
ARG USER
ARG PASSWORD

ARG MAVEN_PROXY_HOST
ARG MAVEN_PROXY_PORT
ARG MAVEN_PROXY_USER
ARG MAVEN_PROXY_PASSWORD

ARG JMX_PROMETHEUS_VERSION=0.12.0

RUN apk add --no-cache \
        bash \
        ca-certificates \
        maven \
        tar \
        wget \
        xmlstarlet

COPY ./deploy/camunda/settings.xml ./deploy/camunda/download.sh ./deploy/camunda/camunda-run.sh ./deploy/camunda/camunda-tomcat.sh ./deploy/camunda/camunda-wildfly.sh  /tmp/

RUN /tmp/download.sh


##### FINAL IMAGE #####

FROM alpine:3.12

ARG VERSION=7.16.0

ENV CAMUNDA_VERSION=${VERSION}
ENV DB_DRIVER=
ENV DB_URL=
ENV DB_USERNAME=
ENV DB_PASSWORD=
ENV DB_CONN_MAXACTIVE=20
ENV DB_CONN_MINIDLE=5
ENV DB_CONN_MAXIDLE=20
ENV DB_VALIDATE_ON_BORROW=false
ENV DB_VALIDATION_QUERY="SELECT 1"
ENV SKIP_DB_CONFIG=
ENV WAIT_FOR=
ENV WAIT_FOR_TIMEOUT=30
ENV TZ=UTC
ENV DEBUG=false
ENV JAVA_OPTS="-Xmx1024m -XX:MaxMetaspaceSize=256m"
ENV JMX_PROMETHEUS=false
ENV JMX_PROMETHEUS_CONF=/camunda/javaagent/prometheus-jmx.yml
ENV JMX_PROMETHEUS_PORT=9404

EXPOSE 8080 8000 9404

# Downgrading wait-for-it is necessary until this PR is merged
# https://github.com/vishnubob/wait-for-it/pull/68
RUN apk add --no-cache \
        bash \
        ca-certificates \
        curl \
        openjdk11-jre-headless \
        tzdata \
        tini \
        xmlstarlet \
  && curl -o /usr/local/bin/wait-for-it.sh "https://raw.githubusercontent.com/vishnubob/wait-for-it/a454892f3c2ebbc22bd15e446415b8fcb7c1cfa4/wait-for-it.sh" \
  && chmod +x /usr/local/bin/wait-for-it.sh

RUN addgroup -g 1520 -S camunda \
  && adduser -u 1520 -S camunda -G camunda -h /camunda -s /bin/bash -D camunda \

WORKDIR /camunda

COPY --chown=camunda:camunda --from=builder /camunda .
COPY ./deploy/camunda/conf/bpm-platform.xml  /camunda/conf/
COPY ./deploy/camunda/postgresql-42.2.23.jar /camunda/lib/postgresql-42.1.0.jar
COPY ./deploy/camunda/web.xml /camunda/webapps/engine-rest/WEB-INF/web.xml

# openshift fix
RUN chgrp -R 0 /camunda \
  && chmod -R g=u /camunda

USER 1520

ENTRYPOINT ["/sbin/tini", "--"]
CMD ["./camunda.sh"]

getsueineko avatar May 20 '22 13:05 getsueineko

Any news?

getsueineko avatar May 25 '22 08:05 getsueineko

I simplified my dockerfile a lot and update version of camunda, but still no success with excamad =(

FROM camunda/camunda-bpm-platform:7.17.0

# Change historyLevel
COPY --chown=camunda:camunda ./deploy/camunda/conf/bpm-platform.xml  /camunda/conf/bpm-platform.xml

# Enable CORS
COPY --chown=camunda:camunda ./deploy/camunda/web.xml /camunda/webapps/engine-rest/WEB-INF/web.xml

USER root

# Openshift fix
RUN chgrp -R 0 /camunda \
  && chmod -R g+rwX /camunda

USER camunda

getsueineko avatar Jun 02 '22 11:06 getsueineko

No chance for current version?

getsueineko avatar Jun 29 '22 12:06 getsueineko

Hi, idk whats wrong, becouse i use embedded engine. As workaround you can use cors clearing proxy like https://www.npmjs.com/package/cors-anywhere , it helps me a lot in some cases.

I shall check your setup in future, 100% garanted reason for that kind problem is tomcat config files.

KotskinKotskin avatar Jun 29 '22 13:06 KotskinKotskin

Hi, idk whats wrong, becouse i use embedded engine. As workaround you can use cors clearing proxy like https://www.npmjs.com/package/cors-anywhere , it helps me a lot in some cases.

I shall check your setup in future, 100% garanted reason for that kind problem is tomcat config files.

Yeah. I think the same. But I couldn't find a working config for that =( Thank you. I hope for help. I'll check cors-anywhere in my free time.

getsueineko avatar Jul 07 '22 06:07 getsueineko

No luck with cors-anywhere too :(

getsueineko avatar Aug 06 '22 21:08 getsueineko

Hello! I'm use Camunda downloaded from official site: image I use the following settings for origin in the default.yml file:

cat default.yml

# Find more available configuration properties on the following pages of the documentation.
# https://docs.camunda.org/manual/latest/user-guide/camunda-bpm-run/#configure-camunda-bpm-run
# https://docs.camunda.org/manual/latest/user-guide/spring-boot-integration/configuration/#camunda-engine-properties

camunda.bpm:
  admin-user:
    id: demo
    password: demo
  run:
# https://docs.camunda.org/manual/latest/user-guide/camunda-bpm-run/#cross-origin-resource-sharing
    cors:
      enabled: true
      allowed-origins: "http://172.31.*.*:8080,http://172.31.*.*:8090,http://192.168.88.173:8090"
# https://docs.camunda.org/manual/latest/user-guide/camunda-bpm-run/#example-application
    example:
      enabled: true

# datasource configuration is required
spring.datasource:
  url: jdbc:h2:./camunda-h2-default/process-engine;TRACE_LEVEL_FILE=0;DB_CLOSE_ON_EXIT=FALSE
  driver-class-name: org.h2.Driver
  username: sa
  password: sa

# By default, Spring Boot serves static content from any directories called /static or /public or /resources or
# /META-INF/resources in the classpath. To prevent users from accidentally sharing files, this is disabled here by setting static locations to NULL.
# https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-spring-mvc-static-content
spring.web.resources:
  static-locations: NULL

In allowed-origins I have listed possible origins. The error in the browser has changed and now looks like this:

image

Access to XMLHttpRequest at 'http://172.31.22.84:8080/engine-rest/engine' from origin 'http://192.168.88.173:8090' has been blocked by CORS policy: The value of the 'Access-Control-Allow-Credentials' header in the response is '' which must be 'true' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.

I have not been able to solve this problem....

torquemada163 avatar Aug 18 '22 08:08 torquemada163

Sorry, but it's all about cors and tomcat config. I never use tomcat and standalone camunda, so you need to find a way to configure it by yourself. Maybe some closed issues can be helpful.

KotskinKotskin avatar Aug 20 '22 18:08 KotskinKotskin

Sadly story :( Can you describe how you use your own product? What is algorithm?

getsueineko avatar Aug 21 '22 15:08 getsueineko