Skip to content

Instantly share code, notes, and snippets.

@ackerleytng
Last active April 24, 2020 05:04
Show Gist options
  • Save ackerleytng/985786675341e7f938224cdc0871a2ea to your computer and use it in GitHub Desktop.
Save ackerleytng/985786675341e7f938224cdc0871a2ea to your computer and use it in GitHub Desktop.
Vagrantfile for trying out keycloak-quickstarts/app-authz-photoz

Try app-authz-photoz

Note, this is different from app-authz-uma-photoz

Quickstart

vagrant up

And your vm should start. After it boots, in two separate terminals

$ vagrant ssh
vagrant@vagrant:~$ ./start-wildfly.sh

and

$ vagrant ssh
vagrant@vagrant:~$ ./start-keycloak.sh

Then on your host, point your browser to

http://localhost:8080/photoz-html5-client/

Follow demo readme at https://github.com/ackerleytng/keycloak-quickstarts/tree/latest/app-authz-photoz#creating-and-sharing-resources

My fork is slightly different from upstream in that there are some fixes and extra debugging printouts

Troubleshooting

My setup, in case you need to troubleshoot:

  • Using virtualbox for vagrant
  • My uname -a: Linux ackerleytng 5.6.6-arch1-1 #1 SMP PREEMPT Tue, 21 Apr 2020 10:35:16 +0000 x86_64 GNU/Linux
  • vagrant will be using ports 8080, 8180, and 9990, so don't listen on those on your host

Enabling debug logs

The idea here is that you'll have to change live config in the wildfly server.

$ $WILDFLY_HOME/bin/jboss-cli.sh --connect
[standalone@localhost:9990 /] # Let the console print up to DEBUG
[standalone@localhost:9990 /] /subsystem=logging/console-handler=CONSOLE:write-attribute(name=level, value=DEBUG)
{"outcome" => "success"}
[standalone@localhost:9990 /] # Specify log level = DEBUG for keycloak adapters only
[standalone@localhost:9990 /] /subsystem=logging/logger=org.keycloak.adapters:add(level=DEBUG)
{"outcome" => "success"}
[standalone@localhost:9990 /] # Also enable access logs in undertow
[standalone@localhost:9990 /] /subsystem=undertow/server=default-server/host=default-host/setting=access-log:add(pattern="%h %t \"%r\" %s \"%{i,User-Agent}\"",use-server-log=true)
{"outcome" => "success"}
[standalone@localhost:9990 /]

To remove

$ $WILDFLY_HOME/bin/jboss-cli.sh --connect
[standalone@localhost:9990 /] /subsystem=logging/console-handler=CONSOLE:write-attribute(name=level, value=INFO)
{"outcome" => "success"}
[standalone@localhost:9990 /] /subsystem=logging/logger=org.keycloak.adapters:remove()
{"outcome" => "success"}
[standalone@localhost:9990 /] /subsystem=undertow/server=default-server/host=default-host/setting=access-log:remove()
{"outcome" => "success"}
[standalone@localhost:9990 /]

You can do the same on the keycloak server, which is also running on wildfly

$ $KEYCLOAK_HOME/bin/jboss-cli.sh --connect --controller=localhost:10090
[standalone@localhost:10090 /] # Let the console print up to DEBUG
[standalone@localhost:10090 /] /subsystem=logging/console-handler=CONSOLE:write-attribute(name=level, value=DEBUG)
{"outcome" => "success"}
[standalone@localhost:10090 /] # Specify log level = DEBUG for keycloak adapters only
[standalone@localhost:10090 /] /subsystem=logging/logger=org.keycloak.authorization:add(level=DEBUG)
{"outcome" => "success"}
[standalone@localhost:10090 /] # Also enable access logs in undertow
[standalone@localhost:10090 /] /subsystem=undertow/server=default-server/host=default-host/setting=access-log:add(pattern="%h %t \"%r\" %s \"%{i,Host}\"",use-server-log=true)
{"outcome" => "success"}
[standalone@localhost:10090 /]

If you want to dump EVERYTHING from undertow,

/subsystem=undertow/configuration=filter/custom-filter=request-dumper:add(class-name="io.undertow.server.handlers.RequestDumpingHandler",  module="io.undertow.core")
/subsystem=undertow/server=default-server/host=default-host/filter-ref=request-dumper:add
Vagrant.configure("2") do |config|
config.vm.box = "ackerleytng/kc-quickstart-photoz"
config.vm.box_version = "0.0.2"
config.vm.network "forwarded_port", guest: 8180, host: 8180
config.vm.network "forwarded_port", guest: 8080, host: 8080
config.vm.network "forwarded_port", guest: 9990, host: 9990
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment