Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
635 views
in Technique[技术] by (71.8m points)

authentication - Camunda 403 error when rest-api request sent from ui

I'm trying out Camunda with authentication filter. The same request works fine with basic auth from postman, but when i send it from the UI I get 403 error for the OPTIONS request and the POST request fails. PS: I have my cors filter set up, it works fine if I disable the authentication filter. This is the request in postman enter image description here

and this is the request in my code

await axios.post(`${process.env.REACT_APP_API}/process-definition/key/${process.env.REACT_APP_PROCESS}/start`, {}, {
            headers: { 'Authorization': 
                {username: "demo",
                password: "demo"}
            }
        })

I tried also this syntax:

await axios.post(`${process.env.REACT_APP_API}/process-definition/key/${process.env.REACT_APP_PROCESS}/start`, {}, {
            auth: 
                {username: "demo",
                password: "demo"}
        })
question from:https://stackoverflow.com/questions/65921007/camunda-403-error-when-rest-api-request-sent-from-ui

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

As mentionned in this post its a problem with cors.allowed.headers in the web.xml file. I added Authorization in the filter and no more 403 error:

<init-param>
            <param-name>cors.allowed.headers</param-name>
            <param-value>Content-Type,X-Requested-With,accept,Origin,Access-Control-Request-Method,Access-Control-Request-Headers,Authorization</param-value>
</init-param>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...