Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keycloak integration #92

Closed
wants to merge 1 commit into from
Closed

Keycloak integration #92

wants to merge 1 commit into from

Conversation

jpkrohling
Copy link
Contributor

No description provided.

@jpkrohling
Copy link
Contributor Author

This PR is ready. Once the review is finished, it can be merged.

@@ -129,7 +129,7 @@
<goal>start</goal>
</goals>
<configuration>
<serverConfig>standalone-test.xml</serverConfig>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept, at least for now, the previous standalone-text.xml in the repository for reference.

@jsanda
Copy link
Contributor

jsanda commented Dec 17, 2014

I believe that the Maven WildFly plugin is deploying 8.2.0.Final, so we already have testing/running with it to some degree.

@tsegismont
Copy link
Contributor

Le 17/12/2014 17:28, jsanda a écrit :

I believe that the Maven WildFly plugin is deploying 8.2.0.Final, so we
already have testing/running with it to some degree.


Reply to this email directly or view it on GitHub
#92 (comment).

It deploys the latest released version by default.

But to avoid problems from changing containers, I configured it like
this some time ago:

https://github.com/rhq-project/rhq-metrics/blob/master/pom.xml#L257-L264

So it always starts Wildfly 8.1.0.Final.

I'll open a PR to check that all is fine with 8.2.

@@ -15,3 +15,6 @@ target/
*.DS_Store
nb-configuration.xml
*~
.keycloak
ui/console/src/main/webapp/keycloak*.json
rest-servlet/src/main/resources/keycloak*.json
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use nested gitignore files instead of adding entries to the root one?

@tsegismont
Copy link
Contributor

I need to try the changes to get a better idea of how things will work. I can't right now but will do later today or tomorrow.

@jpkrohling
Copy link
Contributor Author

Rebased and sent a couple of changes based on the review: fixed the typo on the readme and nested the .gitignore files.

@mtho11
Copy link
Member

mtho11 commented Dec 23, 2014

When I run the start.sh command I get a bunch of errors. Is there something I'm missing?

 ./start.sh mem
Cleaning previous realms directory
Cleaning previous build
Using Keycloak 1.1.0.Beta2 appliance distribution as application server.
Generating key pairs and application secrets for Keycloak integration
sed: 1: "s|PRIVATE_KEY_REALM_ACM ...": bad flag in substitute command: 'i'
sed: 1: "/Users/mtho11/projects/ ...": invalid command code m
sed: 1: "/Users/mtho11/projects/ ...": invalid command code m
sed: 1: "/Users/mtho11/projects/ ...": invalid command code m
sed: 1: "/Users/mtho11/projects/ ...": invalid command code m
sed: 1: "s|PRIVATE_KEY_REALM_ACM ...": bad flag in substitute command: 'i'
sed: 1: "/Users/mtho11/projects/ ...": invalid command code m
sed: 1: "/Users/mtho11/projects/ ...": invalid command code m
sed: 1: "/Users/mtho11/projects/ ...": invalid command code m
sed: 1: "/Users/mtho11/projects/ ...": invalid command code m
sed: 1: "s|PUBLIC_KEY_REALM_ACME ...": bad flag in substitute command: 'i'
sed: 1: "s|PUBLIC_KEY_REALM_ACME ...": bad flag in substitute command: 'i'
sed: 1: "s|PUBLIC_KEY_REALM_ACME ...": bad flag in substitute command: 'i'
sed: 1: "s|PUBLIC_KEY_REALM_ACME ...": bad flag in substitute command: 'i'
sed: 1: "/Users/mtho11/projects/ ...": invalid command code m
sed: 1: "/Users/mtho11/projects/ ...": invalid command code m
Copying the Keycloak's configuration files to the metrics console
Copying the Keycloak's configuration files to the REST API
Building rhq-metrics. This might take a while, specially if this is the first build.
You can follow the progress by issuing the following command on a new terminal window: tail -f /tmp/rhq-metrics-maven.log
Something went wrong on building rhq-metrics. Please, check the logs for the cause: /tmp/rhq-metrics-maven.log

The maven log looks like this:

355 [INFO] RHQ Metrics Test Utils ............................ SUCCESS [0.656s]
356 [INFO] RHQ Metrics API ................................... SUCCESS [0.980s]
357 [INFO] RHQ Metrics Core .................................. SUCCESS [0.621s]
358 [INFO] RHQ Metrics REST-api .............................. SUCCESS [3.881s]
359 [INFO] RHQ Metrics clients ............................... SUCCESS [0.195s]
360 [INFO] clients-common .................................... SUCCESS [0.208s]
361 [INFO] Protocol Translator ............................... SUCCESS [10.113s]
362 [INFO] RHQ Metrics Groovy Rest Tests ..................... FAILURE [0.496s]
363 [INFO] metrics-explorer .................................. SKIPPED
364 [INFO] RHQ Metrics Console ............................... SKIPPED
365 [INFO] ------------------------------------------------------------------------
366 [INFO] BUILD FAILURE
367 [INFO] ------------------------------------------------------------------------
368 [INFO] Total time: 20.246s
369 [INFO] Finished at: Tue Dec 23 10:29:56 PST 2014
370 [INFO] Final Memory: 76M/2971M
371 [INFO] ------------------------------------------------------------------------
372 Cleaning up unclosed ZipFile for archive /Users/mtho11/.m2/repository/org/keycloak/keycloak-appliance-dist-all/1.1.0.Beta2/keycloak-appliance-dist-all-1.1.0.Beta2.zip
373 Cleaning up unclosed ZipFile for archive /Users/mtho11/.m2/repository/org/keycloak/keycloak-jetty81-adapter-dist/1.1.0.Beta2/keycloak-jetty81-adapter-dist-1.1.0.Beta2.zip
374 Cleaning up unclosed ZipFile for archive /Users/mtho11/.m2/repository/org/keycloak/keycloak-tomcat8-adapter-dist/1.1.0.Beta2/keycloak-tomcat8-adapter-dist-1.1.0.Beta2.zip
375 Cleaning up unclosed ZipFile for archive /Users/mtho11/.m2/repository/org/keycloak/keycloak-tomcat7-adapter-dist/1.1.0.Beta2/keycloak-tomcat7-adapter-dist-1.1.0.Beta2.zip
376 [ERROR] Failed to execute goal org.wildfly.plugins:wildfly-maven-plugin:1.0.2.Final:start (start-wildfly) on project rhq-metrics-groovy-rest-tests: JBOSS_HOME '.keycloak/keyclo>
377 [ERROR].
378 [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
379 [ERROR] Re-run Maven using the -X switch to enable full debug logging.
380 [ERROR].
381 [ERROR] For more information about the errors and possible solutions, please read the following articles:
382 [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
383 [ERROR].
384 [ERROR] After correcting the problems, you can resume the build with the command
385 [ERROR]   mvn <goals> -rf :rhq-metrics-groovy-rest-tests

Some errors with tests.

@@ -0,0 +1,2 @@
<div ng-controller="SelectRealmCtrl">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use the ControllerAs syntax so we know what controller values come from.

@jpkrohling
Copy link
Contributor Author

@mtho11 , which OS do you use? I'm guessing I'm using some syntax that is not working for OSX, if that's the OS you use. Can you also send me the server's log to check what's the problem on the test's side? Thanks!

@jpkrohling
Copy link
Contributor Author

@mtho11 , I just added another commit that might fix the start.sh problem. I've removed the "i" flag (as we don't actually need it) and enclosed all paths with double quotes. Perhaps your path contains spaces? That might have been the problem. I'm not too concerned about the test failures at this point, as I think it's caused by the earlier errors.

If you still have problems, let me know.

@mtho11
Copy link
Member

mtho11 commented Dec 24, 2014

@jpkrohling Thanks for working on that! I'm on OS/X (as is more than half of rhq-metrics). I can fiddle with the sed script stuff for OS/X and make that work but in the long run it needs to work on Windows as well, so perhaps we should use a more platform agnostic approach (mvn token replacement?? or whatever).

Your fixes got rid of the 'i' sed issues but errors still exists (on OS/X):

./start.sh mem
Cleaning previous build
Using Keycloak 1.1.0.Beta2 appliance distribution as application server.
Generating key pairs and application secrets for Keycloak integration
sed: 1: "/Users/mtho11/projects/ ...": invalid command code m
sed: 1: "/Users/mtho11/projects/ ...": invalid command code m
sed: 1: "/Users/mtho11/projects/ ...": invalid command code m
sed: 1: "/Users/mtho11/projects/ ...": invalid command code m
sed: 1: "/Users/mtho11/projects/ ...": invalid command code m
sed: 1: "/Users/mtho11/projects/ ...": invalid command code m
sed: 1: "/Users/mtho11/projects/ ...": invalid command code m
sed: 1: "/Users/mtho11/projects/ ...": invalid command code m
sed: 1: "/Users/mtho11/projects/ ...": invalid command code m
sed: 1: "/Users/mtho11/projects/ ...": invalid command code m
Copying the Keycloak's configuration files to the metrics console
Copying the Keycloak's configuration files to the REST API
Building rhq-metrics. This might take a while, specially if this is the first build.
You can follow the progress by issuing the following command on a new terminal window: tail -f /tmp/rhq-metrics-maven.log
Something went wrong on building rhq-metrics. Please, check the logs for the cause: /tmp/rhq-metrics-maven.log

BTW, I don't have any spaces in paths

All of the other fixes look great.

@jpkrohling
Copy link
Contributor Author

I've just added a new commit with changes to the paths, so that the tenant ID is resolved from the URL, as discussed on the mailing list.

However, there was already an endpoint making use of the "/tenants" prefix: TenantHandler. As far as I could see, it's meant to be used by users on the admin realm, to create new tenants. As a temporary measure, I've renamed it to "tenant", but either a better name or a refactoring is needed. Perhaps all the "/tenants/" (and now "tenant") endpoints could be grouped into a single handler?

What's still missing after this change:

  • Rebasing (it seems there are conflicts)
  • Re-test of the UI, to see which changes are required there. I expect that only a couple of changes would be required though.

@mtho11 : About the sed script vs. Windows: what will be the strategy for the start.sh? If it's going to be replaced entirely by a Maven goal, then I'd wait until this is done and then adapt it with the Keycloak changes. The changes to the start.sh are not required by the Keycloak integration per se, and those particular sed commands are only to pre-configure some realms and other json files required by Keycloak, so, those can be removed for now.

@jpkrohling
Copy link
Contributor Author

@mtho11 By the way: I've just tried to rebase this branch and it seems it gets a lot of conflicts on the start.sh. So, depending on the approach to be taken with regards to replace it with a Maven goal, I'll either discard my changes or adapt it based on the latest start.sh

@mtho11
Copy link
Member

mtho11 commented Jan 6, 2015

@jpkrohling we can discuss the whole scripting/mvn strategies for other platforms (like Win/Mac) once @pilhuhn is back (Jan 6th). @stefannegrea may have some ideas on this as well.

@jpkrohling
Copy link
Contributor Author

Alright, sounds reasonable. The current state of the PR is:

  • REST endpoints have been changed, so that /tenants/{tenantId}/... is being used by MetricsHandler on tenant-specific operations
  • REST endpoint for TenantHandler have been changed to /tenant/
  • UI has been changed to reflect the changes: from what I could see, only metric-data-service was affected.

Still to discuss:

  • Refactor of the REST endpoints, to keep all /tenants/ (ie: tenant-specific endpoints for metrics + tenant operations from TenantHandler) in one handler
  • start.sh

Because of the start.sh, I'll not be rebasing this PR for now.

@pilhuhn
Copy link
Member

pilhuhn commented Jan 9, 2015

We would like to wait until after 0.2.6 -- and I personally would not want to wait on a final decision about start.sh

@jpkrohling
Copy link
Contributor Author

@pilhuhn , so, should I remove the changes related to the start.sh from the PR?

constructor(private $modalInstance:any, private Auth:Services.AuthService) {
}

realms = ['acme-other-affairs', 'acme-roadrunner-affairs'];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just realized that this wasn't removed/changed before sending the PR! This needs to be externalized.

@jpkrohling
Copy link
Contributor Author

I've rebased the branch, but there are two things missing:

  • Unprotected REST endpoint to query the possible realms (to use on the console's realm selector modal)
  • start.sh - I've stashed my changes and need to refactor it based on the new version

@jpkrohling
Copy link
Contributor Author

So, the last two points were done, but instead of having an unprotected REST endpoint, I'm adding a static realms.json file, created by start.sh . That's because I'm not sure if having it being served as a REST endpoint is the best option. This way, we have more time to discuss and improve this, if needed.

Also, it would be good to check the sed parts, as I'm not sure if OS X's sed would be happy with those. As I don't have an OS X, it's a bit hard for me try it out.

@mtho11
Copy link
Member

mtho11 commented Jan 20, 2015

I'm getting some compile errors this time.

INFO] RHQ Metrics ....................................... SUCCESS [2.215s]
[INFO] RHQ Metrics Test Utils ............................ SUCCESS [1.109s]
[INFO] RHQ Metrics API ................................... SUCCESS [1.945s]
[INFO] Embedded Cassandra for RHQ Metrics ................ SUCCESS [0.223s]
[INFO] Embedded Cassandra Service for RHQ Metrics ........ SUCCESS [0.720s]
[INFO] Embedded Cassandra EAR for RHQ Metrics ............ SUCCESS [1.816s]
[INFO] RHQ Metrics Core .................................. SUCCESS [5.849s]
[INFO] RHQ Metrics REST-api .............................. SUCCESS [3.967s]
[INFO] RHQ Metrics clients ............................... SUCCESS [0.195s]
[INFO] clients-common .................................... SUCCESS [0.556s]
[INFO] Protocol Translator ............................... SUCCESS [1.149s]
[INFO] RHQ Metrics Rest Tests ............................ FAILURE [1.601s]
[INFO] metrics-explorer .................................. SKIPPED
[INFO] RHQ Metrics Console ............................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 21.880s
[INFO] Finished at: Mon Jan 19 20:47:06 PST 2015
[INFO] Final Memory: 76M/3017M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.wildfly.plugins:wildfly-maven-plugin:1.0.2.Final:start (start-wildfly) on project rhq-metrics-rest-tests: JBOSS_HOME '.keycloak/keycloak-appliance-dist-all-1.1.0.Beta2/keycloak' is not a valid directory. -> [Help 1]

Not sure what I'm missing or what the completion criteria is here to merge.
Maybe @pilhuhn can try compiling on OS/X?

@jpkrohling
Copy link
Contributor Author

That's because the Keycloak used in the tests is not available. Similarly to the Cassandra setup, there's a .travis.install.keycloak.sh . Running it before performing the build should prepare the environment.

@mtho11
Copy link
Member

mtho11 commented Jan 20, 2015

@jpkrohling ok compile is fine. start.sh is complaining now.
./start.sh: line 422: unexpected EOF while looking for matching `''

Something like http://mojo.codehaus.org/versions-maven-plugin/set-mojo.html might work or just mvn writing to properties file that start.sh reads from would also remove the OS specific stuff. As we will soon needs a Windows version this might be the best route.

I know others use FreeBSD as a proxy for OS/X.

@jpkrohling
Copy link
Contributor Author

I was under the impression that non-Linux scripts would be worked out at a later time. Is this not true anymore? In any case, it's a bit hard to convert it entirely to Maven, as there are other tools than sed involved, like openssl and uuidgen. The output of those is what sed is using to replace the placeholders on the templates. Perhaps a better longer term solution is to create our own plugin that would create the certs and UUIDs, generating the files on demand. But again, these files are only for a "--dev" setup, so, not sure if it's worth the trouble.

By the way: I've just seen that Github says the PR has conflicts. I'll rebase it again and send an update to this PR tomorrow.

@pilhuhn
Copy link
Member

pilhuhn commented Jan 20, 2015

Creating a maven plugin to generate those sounds good for the whole keycloak project (?)

@jpkrohling
Copy link
Contributor Author

@mtho11 , I was just checking that line, to see if I could guess what could be done to get it working on OS X, but this seems strange. The original line from master looks like this:

https://github.com/rhq-project/rhq-metrics/blob/master/start.sh#L313

WFLY_VERSION=`grep "<version.wildfly>" pom.xml | sed -E 's/^.*y>(8.*l)<.*$/\1/'`

And the line from your message is:
https://github.com/jpkrohling/rhq-metrics/blob/JPK-KCAuthentication-Draft/start.sh#L422

KC_VERSION=`grep "<version.keycloak>" pom.xml | sed -E 's/^.*k>(1.*)<.*$/\1/'`

Can you confirm that the original one works?

@jpkrohling
Copy link
Contributor Author

Closing, as efforts on this PR are now on hold. See thread "Keycloak + Hawt.io" on the hawkular-dev mailing list.

@jpkrohling jpkrohling closed this Feb 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants