# Using Keycloak Authorization Services and Policy Enforcer to Protect JAX-RS Applications
In this example, we build a very simple microservice which offers one endpoints:
In this example, we build a very simple microservice which offers endpoints for:
*`/accounts`
*`/account/*`
These endpoints are protected and can only be accessed if a client is sending a bearer token along with the request, which must be valid (e.g.: signature, expiration and audience) and trusted by the microservice.
The HTTP POST with path /accounts creates an new account. It can only run by users with admin role.
...
...
@@ -27,8 +28,9 @@ To compile and run this demo you will need:
Make sure that `JAVA_HOME` environment variables have been set, and that a JDK 11+ `java` command is on the path.
## Starting and Configuring the Keycloak Server ( see Part 1 )
Note: The docu below is a little bit outdated !
- For a full Keycloak Setup read [Part 1: Keycloak Setup ](https://www.helikube.de/part-1-setup-for-keycloak-authorization-sample)
- For a quick Keycloak setup read [Part 1: Quick Keycloak Setup via impport ](https://www.helikube.de/part-1-quick-keycloak-setup-for-running-keycloak-authorization-sample/)
- For a quick Keycloak setup read [Part 1: Quick Keycloak Setup via import ](https://www.helikube.de/part-1-quick-keycloak-setup-for-running-keycloak-authorization-sample/)
## Add. Info can be found at:
- For Quarkus Setup read [Part 2: Quarkus Setup ](https://www.helikube.de/part-2-running-fine-grained-keycloak-authorization-feature-with-quarkus/)
...
...
@@ -45,7 +47,8 @@ live coding. To try this out:
$ mvn compile quarkus:dev
Now open [OpenId Connect Dev UI](http://localhost:8080/q/dev). You will be asked to login into a _Single Page Application_.
Now open [OpenId Connect Dev UI](http://localhost:8080/q/dev).
You will be asked to login into a _Single Page Application_.
- Log in as `testuser` - accessing the `/accounts` will return `200`
- Log in as `testadmin` - accessing the `/accounts` will return `200`