OpenShiftDemos / openshift-tasks

Sample JBoss EAP (WildFly) App for OpenShift
47 stars 425 forks source link

Error - Unauthorized when accessing from curl #12

Open karstengresch opened 7 years ago

karstengresch commented 7 years ago

Followed the instructions from https://github.com/OpenShiftDemos/openshift-cd-demo which I finally got running locally with oc cluster up (setup and config see here: ).

Tried to create a task:

curl -i -u 'redhat:redhat1!' -H "Content-Length: 0" -X POST http://tasks-dev.apps.127.0.0.1.nip.io/ws/tasks/task1

Result:

HTTP/1.1 401 Unauthorized
Expires: 0
Cache-Control: no-cache, no-store, must-revalidate
X-Powered-By: Undertow/1
Server: JBoss-EAP/7
Pragma: no-cache
Date: Tue, 04 Apr 2017 18:37:18 GMT
WWW-Authenticate: Basic realm="RealmUsersRoles"
Content-Type: text/html;charset=UTF-8
Content-Length: 71
Set-Cookie: 5d1905427a4600d0082930fc85649db9=21c9d5dd6cefe390218571514e4c1701; path=/; HttpOnly

<html><head><title>Error</title></head><body>Unauthorized</body></html>

Just to let you know...

karstengresch commented 7 years ago

As the md5 of redhat1! is

c4df094e0bf5bc1c471423c4f356e902

on several *ix-systems tested, I assume the password in the documentation is not correct.

abessifi commented 7 years ago

Same issue here!

redlumxn commented 7 years ago

Found out the issue is related to the pipeline defined in cicd-template.yaml from https://github.com/OpenShiftDemos/openshift-cd-demo. The Jenkinsfile 'Deploy DEV' stage is not placing creating the configuration directory (containing the users/roles) into the right directory structure within the oc-build directory. This is where the WAR is copied to and the configuration directory needs to be at the same level for the binary build to work as expected and place the configuration files in the right EAP_HOME/standalone/configuration directory within the container.

oc-build ----ROOT.war ----configuration --------application-roles.properties --------application-users.properties

I simply changed the Jenkinsfile DEV stage from:

stage ('Deploy DEV') {
     sh "rm -rf oc-build && mkdir -p oc-build/deployments"
     sh "cp target/openshift-tasks.war oc-build/deployments/ROOT.war"
     sh "oc project ${DEV_PROJECT}"

to

stage ('Deploy DEV') {
     sh "rm -rf oc-build && mkdir -p oc-build/configuration"
     sh "cp target/openshift-tasks.war oc-build/ROOT.war"
     sh "cp configuration/*.properties oc-build/configuration"
     sh "oc project ${DEV_PROJECT}"

Hope this helps

rafaeltuelho commented 6 years ago

@redlumxn send a PR for this! ;-)