You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: documentation/modules/ROOT/pages/metrics.adoc
+6-1Lines changed: 6 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -125,5 +125,10 @@ for i in {1..5}; do curl -w '\n' localhost:8080/time; done
125
125
126
126
== Check the metrics
127
127
128
-
By default the metrics are exposed in Prometheus format. You can check the output by pointing your browser to http://localhost:8080/q/metrics[window=_blank]
128
+
By default the metrics are exposed in Prometheus format. You can check the output by pointing your browser to http://localhost:8080/q/metrics[window=_blank]. See if you can find the TimeResource counter result.
NOTE: In this tutorial we consulted the results in raw format, however these metrics are meant to be consumed by a monitoring system such as Prometheus so you can produce meaningful dashboards or alerts instead of accessing the metrics endpoint directly.
Quarkus introduced an experimental *Dev Services For Keycloak* feature which is enabled by default when the `quarkus-oidc` extension is started in dev mode. It starts a Keycloak container and initializes it by registering the existing Keycloak realm or creating a new realm with the client and users for you to start developing your Quarkus application secured by Keycloak immediately.
39
39
40
-
When working in Dev Mode, you can use Dev Services for KeyCloak. This is the easy way to locally test your KeyCloak authentication.
40
+
When working in Dev Mode, you can use Dev Services for KeyCloak. This is an easy way to locally test your KeyCloak authentication.
41
41
42
-
Simply go to http://localhost:8080/q/dev/[Dev UI] and select the OpenId Connect Card linking to a Keycloak page.
42
+
Let's define a static port for the KeyCloak dev service so you can copy/paste the links further down in this section. Add the following line to your application.properties:
43
+
[.console-input]
44
+
[source,bash,subs="+macros,+attributes"]
45
+
----
46
+
quarkus.keycloak.devservices.port=34000
47
+
----
43
48
44
-
Click on the http://localhost:8080/q/dev/io.quarkus.quarkus-oidc/provider[Provider: Keycloak link] and you will see a Keycloak page which will be presented slightly differently depending on how Dev Services for Keycloak feature has been configured.
49
+
Now go to the http://localhost:8080/q/dev-ui/dev-services[Dev UI - Dev Services]. You will see a 'keycloak' section with information about the running Keycloak Dev Services container, including auth server url and some default oidc users.
45
50
46
51
TIP: By default, `alice` and `bob` users (with the passwords matching the names), and user and admin roles are created.
47
52
`alice` has both admin and user roles, and `bob` has just the user role.
48
53
49
-
However, we can add our own user, role and group by following these steps:
54
+
We can add our own user, role and group in KeyCloak by following these steps:
50
55
51
-
. Click on http://localhost:55105/auth[KeyCloak Admin link] in the left corner.
52
-
. Login using `admin' as user and password.
56
+
. Go to the http://localhost:34000/admin/master/console/[KeyCloak Administration console] and use `admin' as user and password.
53
57
. Go to https://raw.githubusercontent.com/redhat-developer-demos/quarkus-tutorial/master/jwt-token/quarkus-realm.json and save it on your local machine.
54
-
. Go to http://localhost:55105/auth/admin/master/console/#/realms/quarkus/partial-import[Import] in the KeyCloak Administration console and import `quarkus-realm.json`.
55
-
After this step you should have `Subscriber` Role and Group.
56
-
. Go to http://localhost:55105/auth/admin/master/console/#/realms/quarkus/users[Users] and check that `jdoe` user is mapped to the `Subscriber` role and group.
57
-
. Setup a password for `jdoe` user.
58
+
. Go to the http://localhost:34000/admin/master/console/#/quarkus/realm-settings['quarkus' Realm Settings]
59
+
. Click on 'Action' in the top right and select Partial Import.
60
+
. Browse to the `quarkus-realm.json` you downloaded and select all resources to import. Then also select "Overwrite" when it asks "If a resource already exists, specify what should be done:"
61
+
After this step you should have a `Subscriber` Role and Group.
62
+
. Go to 'Users' in the left menu and click on 'jdoe' and then on the 'Role Mapping' tab and check that the `jdoe` user is correctly mapped to the 'Subscriber' role.
63
+
. Reset the password for the 'jdoe' user in the Credentials settings to 'jdoepass'.
58
64
59
65
Congratulations! Now you can run this section in Dev Mode without starting the KeyCloak container nor adding the KeyCloak setup in `application.properties`.
60
66
[WARNING]
@@ -108,15 +114,17 @@ First you need a token valid to authenticate. Run the following command to obtai
108
114
[.console-input]
109
115
[source,bash]
110
116
----
111
-
curl -X POST 'http://localhost:56006/auth/realms/quarkus/protocol/openid-connect/token' \ #<1>
<1> If you are using KeyCloak Dev Services, you can get the KeyCloak port from Quarkus logs.
119
-
<2> Consider to replace the password here with the one you set in the beginning.
124
+
[IMPORTANT]
125
+
--
126
+
<1> Replace the KeyCloak port with the current value of the dev service container port (this is the same as the one in the url you were using to set up KeyCloak).
127
+
--
120
128
121
129
You should see an output similar to:
122
130
@@ -131,17 +139,16 @@ Below you can find details on how to do that using `curl` and `jq`:
131
139
[.console-input]
132
140
[source,bash]
133
141
----
134
-
token=$(curl -X POST 'http://localhost:56006/auth/realms/quarkus/protocol/openid-connect/token' \
0 commit comments