flytreeleft / nexus3-keycloak-plugin

Sonatype Nexus plugin for Keycloak integration
Apache License 2.0
106 stars 82 forks source link

Not able to set up Keycloak Authentication Realm #10

Closed faizanahmad055 closed 5 years ago

faizanahmad055 commented 5 years ago

Hi, I'm facing an issue, where I can't set up nexus3-keycloak-plugin. I'm using below-mentioned images Keycloak: fabric8/keycloak-postgres:v15751c8 Nexus: quay.io/travelaudience/docker-nexus:3.13.0_alpine_3.8.1 I'm using public nexus chart Steps that I've followed.

  1. Setup the nexus
  2. Exec nexus container via kubectl
  3. Run following commands
    
    PLUGIN_VERSION=0.3.2-SNAPSHOT
    install_dir=/opt/sonatype/nexus

cd /opt apk add --no-cache curl apk add maven apk fetch openjdk8 apk add openjdk8

cd $install_dir/system curl -L -O https://github.com/flytreeleft/nexus3-keycloak-plugin/releases/download/0.3.2-SNAPSHOT/nexus3-keycloak-plugin-0.3.2-SNAPSHOT.jar

echo "mvn\:org.github.flytreeleft/nexus3-keycloak-plugin/$PLUGIN_VERSION = 200" >> $install_dir/etc/karaf/startup.properties

cd $install_dir/etc echo '{ "realm": "fabric8", "auth-server-url": "https://keycloak.test.com/auth", "ssl-required": "external", "resource": "nexus3", "credentials": { "secret": "dummysecret" }, "policy-enforcer": {} }' > $install_dir/etc/keycloak.json

I've done that and also followed the instructions to setup keycloak. But when I login to nexus. I don't see `Keycloak Authentication Realm` in available realms.

I've also tried to add this in postStart
```yaml
          lifecycle:
            postStart:
              exec:
                command: ["/bin/sh", "-c", "/sonatype-nexus-conf/postStart.sh"]

And when I run this via post start script. I see this exception in logs

Error installing bundle listed in startup.properties with url: mvn:org.github.flytreeleft/nexus3-keycloak-plugin/0.3.2-SNAPSHOT and startlevel: 200
java.lang.NullPointerException
    at org.apache.karaf.main.Main.destroy(Main.java:634)
    at org.sonatype.nexus.karaf.NexusMain.main(NexusMain.java:56)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.exe4j.runtime.LauncherEngine.launch(LauncherEngine.java:62)
    at com.install4j.runtime.launcher.UnixLauncher.main(UnixLauncher.java:63)

Can you please help.

flytreeleft commented 5 years ago

@faizanahmad055 It seems that the plugin jar package should be put to $install_dir/system/org/github/flytreeleft/nexus3-keycloak-plugin/$PLUGIN_VERSION:

PLUGIN_DIR="$install_dir/system/org/github/flytreeleft/nexus3-keycloak-plugin/$PLUGIN_VERSION"
mkdir -p $PLUGIN_DIR
cd $PLUGIN_DIR
curl -L -O https://github.com/flytreeleft/nexus3-keycloak-plugin/releases/download/$PLUGIN_VERSION/nexus3-keycloak-plugin-$PLUGIN_VERSION.jar

You can see the Dockerfile for more details.

faizanahmad055 commented 5 years ago

Hi sure, I'll try it out today and update here. Thanks.

faizanahmad055 commented 5 years ago

Hi, thank you for help. It worked. You can close the issue.