Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
638 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 Reply

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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...