Questo contenuto non è disponibile nella lingua selezionata.

Chapter 3. Using Red Hat Single Sign-On with Spring Boot


Red Hat Single Sign-On client adapters are libraries that make it very easy to secure applications and services with Red Hat Single Sign-On. You can use the Keycloak Spring Boot adapter to secure your Spring Boot project.

3.1. Build and deploy Spring Boot CXF JAXRS Keycloak quickStart

This example demonstrates how you can use Apache CXF JAXRS which is secured by Keycloak with Spring Boot. The quickstart uses Spring Boot to configure an application that includes a CXF JAXRS endpoint with Swagger enabled, which is secured by Keycloak. You can run this quickstart in the standalone mode.

Note

This is an upstream demo with no support from Red Hat. See section Using Spring Boot BOM in the Deploying into Spring Boot guide

Procedure

To run this quickstart as a standalone project on your local machine:

  1. Download the Spring Boot CXF JAXRS Keycloak quickstart[https://github.com/ffang/spring-boot-cxf-keycloak] and extract the archive on your local filesystem.
  2. Navigate to the quickstart directory and build the project.

    cd PROJECT_DIR
    mvn clean package
    Copy to Clipboard Toggle word wrap
  3. Run the following command to build and deploy the Spring Boot CXF JAXRS Keycloak quickstart.

    mvn spring-boot:run
    Copy to Clipboard Toggle word wrap

    This starts the Keycloak auth server with predefined configuration (./src/main/resources/keycloak-config/realm-export-new.json) along with CXF JAXRS SB2 endpoint.

  4. You can then access the CXF JAXRS endpoint directly from your web browser, for example, open http://localhost:8080/services/helloservice/sayHello/FIS to access the endpoint. Since the CXF JAXRS endpoint is secured by Keycloak, this will redirect request to Keycloak auth server.
  5. Enter admin as the username and passw0rd as the password. This fetches the OAuth2 JWT token and redirects to the CXF JAXRS endpoint. You can see Hello FIS, Welcome to CXF RS Spring Boot World!!! message on the browser.
Torna in cima
Red Hat logoGithubredditYoutubeTwitter

Formazione

Prova, acquista e vendi

Community

Informazioni sulla documentazione di Red Hat

Aiutiamo gli utenti Red Hat a innovarsi e raggiungere i propri obiettivi con i nostri prodotti e servizi grazie a contenuti di cui possono fidarsi. Esplora i nostri ultimi aggiornamenti.

Rendiamo l’open source più inclusivo

Red Hat si impegna a sostituire il linguaggio problematico nel codice, nella documentazione e nelle proprietà web. Per maggiori dettagli, visita il Blog di Red Hat.

Informazioni su Red Hat

Forniamo soluzioni consolidate che rendono più semplice per le aziende lavorare su piattaforme e ambienti diversi, dal datacenter centrale all'edge della rete.

Theme

© 2025 Red Hat