<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	
	xmlns:georss="http://www.georss.org/georss"
	xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
	>

<channel>
	<title>Role-Based Access Control - Inero Software - Software Consulting</title>
	<atom:link href="https://inero-software.com/tag/role-based-access-control/feed/" rel="self" type="application/rss+xml" />
	<link>https://inero-software.com/tag/role-based-access-control/</link>
	<description>We unleash innovations using cutting-edge technologies, modern design and AI</description>
	<lastBuildDate>Thu, 06 Mar 2025 09:33:14 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>

<image>
	<url>https://inero-software.com/wp-content/uploads/2018/11/inero-logo-favicon.png</url>
	<title>Role-Based Access Control - Inero Software - Software Consulting</title>
	<link>https://inero-software.com/tag/role-based-access-control/</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">153509928</site>	<item>
		<title>Keycloak Integration Guide: Securing Java Spring Endpoints with Keycloak</title>
		<link>https://inero-software.com/securing-java-spring-endpoints-with-keycloak/</link>
		
		<dc:creator><![CDATA[Marceli Formela]]></dc:creator>
		<pubDate>Mon, 27 May 2024 13:19:53 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Company]]></category>
		<category><![CDATA[Keycloak]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[Java Spring]]></category>
		<category><![CDATA[keycloak]]></category>
		<category><![CDATA[RBAC]]></category>
		<category><![CDATA[Role-Based Access Control]]></category>
		<category><![CDATA[Spring Boot]]></category>
		<guid isPermaLink="false">https://inero-software.com/?p=5759</guid>

					<description><![CDATA[<p>&#160; &#160;</p>
<p>Artykuł <a href="https://inero-software.com/securing-java-spring-endpoints-with-keycloak/">Keycloak Integration Guide: Securing Java Spring Endpoints with Keycloak</a> pochodzi z serwisu <a href="https://inero-software.com">Inero Software - Software Consulting</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>&nbsp;</p>
<div class="row"><div class="col-sm-1"></div><div class="col-sm-10">
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><span style="font-weight: 400;">In the world of web application development, securing endpoints is a critical task to ensure that only authorized users can access certain resources. One of the most robust ways to handle authentication and authorization in Java Spring applications is by integrating with Keycloak, an open-source identity and access management solution.</span></p>
<p><span style="font-weight: 400;">Spring Security is a powerful and customizable authentication and access-control framework for the Java Spring ecosystem. However, managing and implementing security policies and authentication mechanisms from scratch can be cumbersome and error-prone. By integrating Keycloak, developers can offload many of these responsibilities to a robust, external system. Keycloak handles user management, roles, and permissions, and provides an easy-to-use interface for administrators.</span></p>
<p><span style="font-weight: 400;">In this article, we will demonstrate how to seamlessly integrate Keycloak with Spring Boot and secure endpoints based on Role-Based Access Control (RBAC). We&#8217;ll guide you through the necessary steps to configure Keycloak, set up roles, and apply security constraints to your application. By the end of this tutorial, you will have authentication and authorization system implemented in your Spring Boot project.</span></p>
<p>&nbsp;</p>
<h3><b>Setting Up Keycloak</b></h3>
<p><span style="font-weight: 400;">Before integrating Keycloak with a Spring Boot application, you need to set up a Keycloak server. Here&#8217;s a quick guide to getting started:</span></p>
<ol>
<li><b></b><span style="font-weight: 400;">   </span> <b>Download and Install Keycloak</b></li>
</ol>
<p><span style="font-weight: 400;">Download the latest version of <a href="https://www.keycloak.org/">Keycloak from the official website</a>. Extract the downloaded archive and start the server by navigating to the bin directory and executing:</span></p>
<pre><i><span style="font-weight: 400;">bin/kc.sh start-dev</span></i>
<i><span style="font-weight: 400;">2024-05-23 06:59:48,625 INFO  [io.quarkus] (main) Keycloak 24.0.4 on JVM (powered by Quarkus 3.8.4) started in 5.096s. Listening on: http://0.0.0.0:8080</span></i></pre>
<p>&nbsp;</p>
<ol start="2">
<li><b></b><span style="font-weight: 400;">   </span> <b>Access the Admin Console</b></li>
</ol>
<p><span style="font-weight: 400;">Open a browser and navigate to</span><a href="http://localhost:8080"> <span style="font-weight: 400;">http://localhost:8080</span></a><span style="font-weight: 400;">. After creating admin account and logging in you should be redirected to /admin/master/console/.</span></p>
<p><img fetchpriority="high" decoding="async" data-attachment-id="5769" data-permalink="https://inero-software.com/securing-java-spring-endpoints-with-keycloak/keyclock1-2/" data-orig-file="https://inero-software.com/wp-content/uploads/2024/05/KEYCLOCK1-2.png" data-orig-size="1920,1080" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="KEYCLOCK1 (2)" data-image-description="" data-image-caption="" data-medium-file="https://inero-software.com/wp-content/uploads/2024/05/KEYCLOCK1-2-300x169.png" data-large-file="https://inero-software.com/wp-content/uploads/2024/05/KEYCLOCK1-2-1030x579.png" tabindex="0" role="button" class="wp-image-5769 aligncenter" src="https://inero-software.com/wp-content/uploads/2024/05/KEYCLOCK1-2-300x169.png" alt="" width="500" height="282" srcset="https://inero-software.com/wp-content/uploads/2024/05/KEYCLOCK1-2-300x169.png 300w, https://inero-software.com/wp-content/uploads/2024/05/KEYCLOCK1-2-1030x579.png 1030w, https://inero-software.com/wp-content/uploads/2024/05/KEYCLOCK1-2-768x432.png 768w, https://inero-software.com/wp-content/uploads/2024/05/KEYCLOCK1-2-1536x864.png 1536w, https://inero-software.com/wp-content/uploads/2024/05/KEYCLOCK1-2-533x300.png 533w, https://inero-software.com/wp-content/uploads/2024/05/KEYCLOCK1-2.png 1920w" sizes="(max-width: 500px) 100vw, 500px" /></p>
<ol start="3">
<li><b></b><span style="font-weight: 400;">   </span> <b>Create a Realm</b></li>
</ol>
<p><span style="font-weight: 400;">A successful login will take us to the console and open up the default Master realm for us. In this scenario we will create a custom realm. Create a new realm by clicking on the &#8220;Add Realm&#8221; button. After clicking the </span><i><span style="font-weight: 400;">Create</span></i><span style="font-weight: 400;"> button, a new realm will be created and we’ll be redirected to it. All the operations in the next sections will be performed in this new </span><i><span style="font-weight: 400;">custom</span></i><span style="font-weight: 400;"> realm.</span></p>
<p><span style="font-weight: 400;">A realm represents a logical grouping of users, credentials, roles, and configurations. It basicly acts as an isolated environment within the Keycloak server where you can manage users and define security policies independently from other realms. This separation allows for enabling different applications or organizations to have their own distinct security domains within a single Keycloak instance. Realms provide the flexibility to customize authentication and authorization settings to meet the specific needs of different projects or clients.</span></p>
<p><img decoding="async" data-attachment-id="5774" data-permalink="https://inero-software.com/securing-java-spring-endpoints-with-keycloak/keycloak-blog-1/" data-orig-file="https://inero-software.com/wp-content/uploads/2024/05/Keycloak-blog-1.png" data-orig-size="3600,2025" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="Keycloak blog 1" data-image-description="" data-image-caption="" data-medium-file="https://inero-software.com/wp-content/uploads/2024/05/Keycloak-blog-1-300x169.png" data-large-file="https://inero-software.com/wp-content/uploads/2024/05/Keycloak-blog-1-1030x579.png" tabindex="0" role="button" class="wp-image-5774 aligncenter" src="https://inero-software.com/wp-content/uploads/2024/05/Keycloak-blog-1-300x169.png" alt="" width="730" height="411" srcset="https://inero-software.com/wp-content/uploads/2024/05/Keycloak-blog-1-300x169.png 300w, https://inero-software.com/wp-content/uploads/2024/05/Keycloak-blog-1-1030x579.png 1030w, https://inero-software.com/wp-content/uploads/2024/05/Keycloak-blog-1-768x432.png 768w, https://inero-software.com/wp-content/uploads/2024/05/Keycloak-blog-1-1536x864.png 1536w, https://inero-software.com/wp-content/uploads/2024/05/Keycloak-blog-1-2048x1152.png 2048w, https://inero-software.com/wp-content/uploads/2024/05/Keycloak-blog-1-533x300.png 533w" sizes="(max-width: 730px) 100vw, 730px" /></p>
<ol start="4">
<li><b></b><span style="font-weight: 400;">   </span> <b>Create a Client</b></li>
</ol>
<p><span style="font-weight: 400;">Now we’ll navigate to the Clients page. As we can see in the image below, Keycloak comes with Clients that are already built-in. We still need to add a new client to our application, so we’ll click </span><i><span style="font-weight: 400;">Create</span></i><span style="font-weight: 400;">.</span></p>
<p><span style="font-weight: 400;">A client in Keycloak represents an application or service that requests authentication and authorization from the Keycloak server. Clients are configured within a realm and can have specific roles, credentials, and access policies. They can be web applications, mobile apps, or other types of services that require secure access control. By defining clients, Keycloak can manage how different applications interact with the authentication server, ensuring that each client follows the appropriate security protocols and has the necessary permissions to access protected resources.</span></p>
<p><img decoding="async" data-attachment-id="5775" data-permalink="https://inero-software.com/securing-java-spring-endpoints-with-keycloak/keycloak-blog-1-1/" data-orig-file="https://inero-software.com/wp-content/uploads/2024/05/Keycloak-blog-1-1.png" data-orig-size="3600,2025" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="Keycloak blog 1 (1)" data-image-description="" data-image-caption="" data-medium-file="https://inero-software.com/wp-content/uploads/2024/05/Keycloak-blog-1-1-300x169.png" data-large-file="https://inero-software.com/wp-content/uploads/2024/05/Keycloak-blog-1-1-1030x579.png" tabindex="0" role="button" class="wp-image-5775 aligncenter" src="https://inero-software.com/wp-content/uploads/2024/05/Keycloak-blog-1-1-300x169.png" alt="" width="731" height="412" srcset="https://inero-software.com/wp-content/uploads/2024/05/Keycloak-blog-1-1-300x169.png 300w, https://inero-software.com/wp-content/uploads/2024/05/Keycloak-blog-1-1-1030x579.png 1030w, https://inero-software.com/wp-content/uploads/2024/05/Keycloak-blog-1-1-768x432.png 768w, https://inero-software.com/wp-content/uploads/2024/05/Keycloak-blog-1-1-1536x864.png 1536w, https://inero-software.com/wp-content/uploads/2024/05/Keycloak-blog-1-1-2048x1152.png 2048w, https://inero-software.com/wp-content/uploads/2024/05/Keycloak-blog-1-1-533x300.png 533w" sizes="(max-width: 731px) 100vw, 731px" /></p>
<ol start="5">
<li><b></b><span style="font-weight: 400;">   </span> <b>Creating Roles and Users</b></li>
</ol>
<p><span style="font-weight: 400;">Define roles and users for your application. Navigate to the Roles and Users sections to add and configure them accordingly.</span></p>
<p>&nbsp;</p>
<h3><b>Integrating Keycloak with Spring Boot</b></h3>
<p>&nbsp;</p>
<ol>
<li><b></b><strong>       Add dependencies</strong></li>
</ol>
<p><span style="font-weight: 400;">We use the Spring Security OAuth2.0 Client to connect to the Keycloak server.</span></p>
<p><span style="font-weight: 400;">Let’s start by declaring spring-boot-starter-oauth2-client dependency in a Spring Boot application in the pom.xml:</span></p>
<pre><span style="font-weight: 400;">&lt;dependency&gt;</span>
<span style="font-weight: 400;">    &lt;groupId&gt;</span><span style="font-weight: 400;">org.springframework.boot</span><span style="font-weight: 400;">&lt;/groupId&gt;</span>
<span style="font-weight: 400;">        &lt;artifactId&gt;</span><span style="font-weight: 400;">spring-boot-starter-oauth2-client</span><span style="font-weight: 400;">&lt;/artifactId&gt;</span>
<span style="font-weight: 400;">&lt;/dependency&gt;</span></pre>
<p><span style="font-weight: 400;">Also, as we need to use Spring Security with Spring Boot, we must add this dependency:</span></p>
<pre><span style="font-weight: 400;">&lt;dependency&gt;</span>
<span style="font-weight: 400;">    &lt;groupId&gt;</span><span style="font-weight: 400;">org.springframework.boot</span><span style="font-weight: 400;">&lt;/groupId&gt;</span>
<span style="font-weight: 400;">    &lt;artifactId&gt;</span><span style="font-weight: 400;">spring-boot-starter-security</span><span style="font-weight: 400;">&lt;/artifactId&gt;</span>
<span style="font-weight: 400;">&lt;/dependency&gt;</span></pre>
<p><span style="font-weight: 400;">In order to delegate the identification control to a Keycloak server, we’ll use the spring-boot-starter-oauth2-resource-server library. This library facilitates the validation of a JWT token with the Keycloak server. Therefore, let&#8217;s include it in our project&#8217;s pom.xml file.</span></p>
<pre><span style="font-weight: 400;">&lt;dependency&gt;</span>
<span style="font-weight: 400;">    &lt;groupId&gt;</span><span style="font-weight: 400;">org.springframework.boot</span><span style="font-weight: 400;">&lt;/groupId&gt;</span>
<span style="font-weight: 400;">    &lt;artifactId&gt;</span><span style="font-weight: 400;">spring-boot-starter-oauth2-resource-server</span><span style="font-weight: 400;">&lt;/artifactId&gt;</span>
<span style="font-weight: 400;">&lt;/dependency&gt;</span></pre>
<p>&nbsp;</p>
<ol start="2">
<li><strong>      Configure Keycloak in application.properties</strong></li>
</ol>
<p><span style="font-weight: 400;">This grant type is suitable for server-to-server communication, where the client application itself is considered the resource owner. It involves exchanging the client’s credentials (client ID and client secret) for an access token.</span></p>
<pre style="padding-left: 40px;"><b>spring.security.oauth2.client.registration.keycloak.authorization-grant-type=client_credentials</b></pre>
<p>&nbsp;</p>
<p><span style="font-weight: 400;">These properties define the client ID and secret that the application will use to authenticate with Keycloak. In this example, the secret is set to placeholder value.</span></p>
<pre style="padding-left: 40px;"><b>spring.security.oauth2.client.registration.keycloak.client-id=back-end-resource-server</b>

<b>spring.security.oauth2.client.registration.keycloak.client-secret=test-secret</b></pre>
<p>&nbsp;</p>
<p><span style="font-weight: 400;">Finally, let’s add the configuration needed for validating JWT token against our Keycloak server:</span></p>
<pre style="padding-left: 40px;"><b>spring.security.oauth2.client.provider.keycloak.token-uri=${test.keycloak-base-url}/realms/test/protocol/openid-connect/token</b>

<b>spring.security.oauth2.resourceserver.jwt.issuer-uri=${app.keycloak-base-url}/realms/test-realm</b></pre>
<p><span style="font-weight: 400;">By combining these configurations, your Spring Boot application will be able to authenticate itself to Keycloak using the client credentials flow and validate JWTs issued by Keycloak, ensuring secure access to its endpoints.</span></p>
<p><span style="font-weight: 400;">Now, the Spring Boot application can interact with Keycloak.</span></p>
<p><a href="https://inero-software.com/keycloak-services/"><img loading="lazy" decoding="async" data-attachment-id="5752" data-permalink="https://inero-software.com/best-keycloak-practices/_baner-en-300x60-1/" data-orig-file="https://inero-software.com/wp-content/uploads/2024/05/baner-en-300x60-1-1.png" data-orig-size="825,165" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="_baner en 300&amp;#215;60 (1)" data-image-description="" data-image-caption="" data-medium-file="https://inero-software.com/wp-content/uploads/2024/05/baner-en-300x60-1-1-300x60.png" data-large-file="https://inero-software.com/wp-content/uploads/2024/05/baner-en-300x60-1-1.png" tabindex="0" role="button" class="wp-image-5752 aligncenter" src="https://inero-software.com/wp-content/uploads/2024/05/baner-en-300x60-1-1-300x60.png" alt="" width="755" height="151" srcset="https://inero-software.com/wp-content/uploads/2024/05/baner-en-300x60-1-1-300x60.png 300w, https://inero-software.com/wp-content/uploads/2024/05/baner-en-300x60-1-1-768x154.png 768w, https://inero-software.com/wp-content/uploads/2024/05/baner-en-300x60-1-1.png 825w" sizes="(max-width: 755px) 100vw, 755px" /></a></p>
<ol start="3">
<li><b></b><strong>       Spring Security configuration</strong></li>
</ol>
<p><span style="font-weight: 400;">Now, let&#8217;s examine the resource server configuration. We need to extract Keycloak-specific information from the JWT. All requests with an Authorization header must include a user&#8217;s token with the necessary scope.</span></p>
<p><span style="font-weight: 400;">In this example CORS is enabled and session management is set to stateless, which is typial for APIs to ensure each request is independently authenticated. We’ve also disabled CSRF protection since our API is stateless.</span></p>
<p><span style="font-weight: 400;">The application is set up as an OAuth 2 resource server that uses JWT for authentication and jwtAuthenticationConverter is specified to handle the conversion of JWT claims into authorities.</span></p>
<pre><span style="font-weight: 400;">@Bean</span>
<span style="font-weight: 400;">public </span><span style="font-weight: 400;">SecurityFilterChain </span><span style="font-weight: 400;">setupOAuth</span><span style="font-weight: 400;">(HttpSecurity http) </span><span style="font-weight: 400;">throws </span><span style="font-weight: 400;">Exception {</span>
<span style="font-weight: 400;">          http.cors().and()</span>
<span style="font-weight: 400;">        </span> <span style="font-weight: 400;">.sessionManagement().sessionCreationPolicy(</span><i><span style="font-weight: 400;">STATELESS</span></i><span style="font-weight: 400;">).and()</span>
<span style="font-weight: 400;">        </span> <span style="font-weight: 400;">.csrf().disable()
</span>  <span style="font-weight: 400;">.oauth2ResourceServer().jwt().jwtAuthenticationConverter(getJwtAuthenticationConverter()).and().and()</span>
<span style="font-weight: 400;">        </span> <span style="font-weight: 400;">.authorizeHttpRequests(authz -&gt; authz</span>
<span style="font-weight: 400;">                </span> <span style="font-weight: 400;">.dispatcherTypeMatchers(DispatcherType.</span><i><span style="font-weight: 400;">ERROR</span></i><span style="font-weight: 400;">).permitAll()</span>
<span style="font-weight: 400;">                </span> <span style="font-weight: 400;">.anyRequest().hasAnyAuthority(</span><span style="font-weight: 400;">"SCOPE_back-end-resource-server"</span><span style="font-weight: 400;">)</span>
<span style="font-weight: 400;">        </span> <span style="font-weight: 400;">)</span><span style="font-weight: 400;">;</span>
<span style="font-weight: 400;">    return </span><span style="font-weight: 400;">http.build()</span><span style="font-weight: 400;">;</span>
<span style="font-weight: 400;">}</span>
<span style="font-weight: 400;">private </span><span style="font-weight: 400;">CompositeJwtAuthenticationConverter </span><span style="font-weight: 400;">getJwtAuthenticationConverter</span><span style="font-weight: 400;">() {</span>
<span style="font-weight: 400;">    </span><span style="font-weight: 400;">return new </span><span style="font-weight: 400;">CompositeJwtAuthenticationConverter()</span>
<span style="font-weight: 400;">        </span> <span style="font-weight: 400;">.extractAuthorities(</span><span style="font-weight: 400;">"ROLE_"</span><span style="font-weight: 400;">, </span><span style="font-weight: 400;">"realm_access"</span><span style="font-weight: 400;">, </span><span style="font-weight: 400;">"roles"</span><span style="font-weight: 400;">)</span>
<span style="font-weight: 400;">        </span> <span style="font-weight: 400;">.extractAuthorities(</span><span style="font-weight: 400;">"SCOPE_"</span><span style="font-weight: 400;">, </span><span style="font-weight: 400;">"scope"</span><span style="font-weight: 400;">)</span><span style="font-weight: 400;">;</span>
<span style="font-weight: 400;">}</span></pre>
<h3><b>Securing REST API</b></h3>
<p><span style="font-weight: 400;">This specific configuration guarantees that only verified users possessing the correct roles can reach secured content. Suppose there&#8217;s a role named ADMIN established, and we aim to restrict access to the list of entities exclusively to users assigned to this role.</span></p>
<pre><span style="font-weight: 400;">@RolesAllowed</span><span style="font-weight: 400;">({Roles.</span><i><span style="font-weight: 400;">ADMIN</span></i><span style="font-weight: 400;">})</span>
<span style="font-weight: 400;">@GetMapping</span><span style="font-weight: 400;">(</span><span style="font-weight: 400;">"/vehicles"</span><span style="font-weight: 400;">)</span>
<span style="font-weight: 400;">public </span><span style="font-weight: 400;">ResponseEntity&lt;?&gt; </span><span style="font-weight: 400;">getVehicles</span><span style="font-weight: 400;">() {</span>
<span style="font-weight: 400;">return </span><span style="font-weight: 400;">vehicleRepository.findAll()</span><span style="font-weight: 400;">;</span>
<span style="font-weight: 400;">}</span></pre>
<p><span style="font-weight: 400;">One way to obtain the JWT token in a user-friendly way is to integrate Keycloak in the front-end client, e.g. using appropriate Angular libraries, but this will be probably the subject of another post, so let&#8217;s take a quick look at initializing KeycloakService (from keycloak-angular library) and move on.</span></p>
<pre><span style="font-weight: 400;">function </span><span style="font-weight: 400;">initializeKeycloak</span><span style="font-weight: 400;">(keycloak: KeycloakService) {</span>
<span style="font-weight: 400;">return </span><span style="font-weight: 400;">() =&gt;</span>
<span style="font-weight: 400;">    </span> <span style="font-weight: 400;">keycloak.</span><span style="font-weight: 400;">init</span><span style="font-weight: 400;">({</span>
<span style="font-weight: 400;">        </span> <span style="font-weight: 400;">config</span><span style="font-weight: 400;">: {</span>
<span style="font-weight: 400;">            </span> <span style="font-weight: 400;">url</span><span style="font-weight: 400;">: </span><b><i>environment</i></b><span style="font-weight: 400;">.</span><span style="font-weight: 400;">keycloakUrl</span><span style="font-weight: 400;">,</span>
<span style="font-weight: 400;">            </span> <span style="font-weight: 400;">realm</span><span style="font-weight: 400;">: </span><span style="font-weight: 400;">'test'</span><span style="font-weight: 400;">,</span>
<span style="font-weight: 400;">    </span> <span style="font-weight: 400;">        </span><span style="font-weight: 400;">clientId</span><span style="font-weight: 400;">: </span><span style="font-weight: 400;">'front-end'</span><span style="font-weight: 400;">,</span>
<span style="font-weight: 400;">        </span> <span style="font-weight: 400;">}</span><span style="font-weight: 400;">,</span>
<span style="font-weight: 400;">        </span> <span style="font-weight: 400;">initOptions</span><span style="font-weight: 400;">: {</span>
<span style="font-weight: 400;">            </span> <span style="font-weight: 400;">checkLoginIframe</span><span style="font-weight: 400;">: </span><span style="font-weight: 400;">false,</span>
<span style="font-weight: 400;">            </span> <span style="font-weight: 400;">scope</span><span style="font-weight: 400;">: </span><span style="font-weight: 400;">'back-end-resource-server'</span>
<span style="font-weight: 400;">        </span> <span style="font-weight: 400;">}</span>
<span style="font-weight: 400;">    </span> <span style="font-weight: 400;">})</span><span style="font-weight: 400;">;</span>
<span style="font-weight: 400;">}</span></pre>
<p><span style="font-weight: 400;">After successful authentication, we should receive a JWT token with similar structure.</span></p>
<pre><span style="font-weight: 400;">"realm_access"</span><span style="font-weight: 400;">: {</span>
<span style="font-weight: 400;">"roles"</span><span style="font-weight: 400;">: [</span>
<span style="font-weight: 400;">    </span> <span style="font-weight: 400;">"offline_access"</span><span style="font-weight: 400;">,</span>
<span style="font-weight: 400;">    </span> <span style="font-weight: 400;">"default-roles-test"</span><span style="font-weight: 400;">,</span>
<span style="font-weight: 400;">    </span> <span style="font-weight: 400;">"uma_authorization"</span><span style="font-weight: 400;">,</span>
<span style="font-weight: 400;"> </span> <span style="font-weight: 400;">   </span><span style="font-weight: 400;">"ADMIN"</span>
<span style="font-weight: 400;">]</span>
<span style="font-weight: 400;">}</span><span style="font-weight: 400;">,</span>
<span style="font-weight: 400;">"scope"</span><span style="font-weight: 400;">: </span><span style="font-weight: 400;">"openid profile email back-end-resource-server"</span></pre>
<p><span style="font-weight: 400;">While running a local server, we could use cURL to test our new endpoint:</span></p>
<pre><span style="font-weight: 400;">curl -H "Authorization: Bearer {valid_jwt_token}"</span><a href="http://localhost:4200/api/vehicles"> <span style="font-weight: 400;">http://localhost:4200/api/vehicles</span></a></pre>
<p><span style="font-weight: 400;">Even if we have the JWT token, the lack of the admin role will result in 403 response.</span></p>
<pre><i><span style="font-weight: 400;">StatusCode: 403</span></i>
<i><span style="font-weight: 400;">StatusDescription: Forbidden</span></i></pre>
<p><span style="font-weight: 400;">Let&#8217;s consider a scenario where the user logged in to the admin account:</span></p>
<pre><i><span style="font-weight: 400;">StatusCode: 200</span></i>
<i><span style="font-weight: 400;">StatusDescription: OK</span></i></pre>
<p><span style="font-weight: 400;">As we can see using Keycloak Role-Based Access Control (RBAC) in web applications offers several advantages. Firstly, it provides a robust and scalable solution for managing access to resources based on user roles and permissions. By defining roles within Keycloak and assigning them to users or groups, administrators can easily control who can access specific functionalities or data in the application. This granular access control enhances security by ensuring that only authorized users can perform certain actions or view sensitive information.</span></p>
<p><span style="font-weight: 400;">Moreover, Keycloak RBAC simplifies the management of access control policies across multiple applications or microservices. Centralizing user roles and permissions in Keycloak eliminates the need to implement and maintain separate authorization mechanisms in each application. This centralization streamlines administration tasks, reduces development overhead, and ensures consistency in access control policies across the entire ecosystem of applications.</span></p>
<p><span style="font-weight: 400;">In summary, leveraging Keycloak RBAC in web applications brings about enhanced security, modularity, centralization, and adaptability in access control management. These benefits contribute to building more secure, maintainable, and scalable web applications while simplifying administration tasks and ensuring consistent access control policies across the application ecosystem.</span></p>
<p>&nbsp;</p>
<p></p></div><div class="col-sm-1"></div></div>
<p>&nbsp;</p>
<p>Artykuł <a href="https://inero-software.com/securing-java-spring-endpoints-with-keycloak/">Keycloak Integration Guide: Securing Java Spring Endpoints with Keycloak</a> pochodzi z serwisu <a href="https://inero-software.com">Inero Software - Software Consulting</a>.</p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">5759</post-id>	</item>
		<item>
		<title>Best Practices in Keycloak: Secure Your System in 5 Steps</title>
		<link>https://inero-software.com/best-keycloak-practices/</link>
		
		<dc:creator><![CDATA[Marta Kuprasz]]></dc:creator>
		<pubDate>Mon, 13 May 2024 13:55:51 +0000</pubDate>
				<category><![CDATA[Company]]></category>
		<category><![CDATA[Keycloak]]></category>
		<category><![CDATA[SOLUTIONS]]></category>
		<category><![CDATA[BusinessProcessesOptimization]]></category>
		<category><![CDATA[HTTPS]]></category>
		<category><![CDATA[IAM]]></category>
		<category><![CDATA[keycloak]]></category>
		<category><![CDATA[MFA]]></category>
		<category><![CDATA[Multi-Factor Authentication]]></category>
		<category><![CDATA[password policies]]></category>
		<category><![CDATA[RBAC]]></category>
		<category><![CDATA[Role-Based Access Control]]></category>
		<category><![CDATA[SSO]]></category>
		<guid isPermaLink="false">https://inero-software.com/?p=5732</guid>

					<description><![CDATA[<p>Keycloak is a tool for managing identity and access that ensures the security of applications and web services. To maximally secure your environment using it, it&#8217;s important to implement best practices. Here are 5 key steps that will help you in this process. Enable HTTPS and Use Strong Certificates The&#8230;</p>
<p>Artykuł <a href="https://inero-software.com/best-keycloak-practices/">Best Practices in Keycloak: Secure Your System in 5 Steps</a> pochodzi z serwisu <a href="https://inero-software.com">Inero Software - Software Consulting</a>.</p>
]]></description>
										<content:encoded><![CDATA[		<div data-elementor-type="wp-post" data-elementor-id="5732" class="elementor elementor-5732" data-elementor-post-type="post">
				<div class="elementor-element elementor-element-4e9a5df1 e-flex e-con-boxed e-con e-parent" data-id="4e9a5df1" data-element_type="container">
					<div class="e-con-inner">
				<div class="elementor-element elementor-element-33821c92 elementor-widget elementor-widget-html" data-id="33821c92" data-element_type="widget" data-widget_type="html.default">
				<div class="elementor-widget-container">
					</div>
				</div>
				<div class="elementor-element elementor-element-7c928cdb elementor-widget elementor-widget-text-editor" data-id="7c928cdb" data-element_type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
							<h4>Keycloak is a tool for managing identity and access that ensures the security of applications and web services. To maximally secure your environment using it, it&#8217;s important to implement best practices. Here are 5 key steps that will help you in this process.</h4>						</div>
				</div>
				<div class="elementor-element elementor-element-640efc79 elementor-widget elementor-widget-heading" data-id="640efc79" data-element_type="widget" data-widget_type="heading.default">
				<div class="elementor-widget-container">
			<h3 class="elementor-heading-title elementor-size-default">Enable HTTPS and Use Strong Certificates
</h3>		</div>
				</div>
					</div>
				</div>
		<div class="elementor-element elementor-element-3e2e44d7 e-flex e-con-boxed e-con e-parent" data-id="3e2e44d7" data-element_type="container">
					<div class="e-con-inner">
		<div class="elementor-element elementor-element-6ff80538 e-con-full e-flex e-con e-child" data-id="6ff80538" data-element_type="container">
				<div class="elementor-element elementor-element-48cb0587 elementor-widget elementor-widget-image" data-id="48cb0587" data-element_type="widget" data-widget_type="image.default">
				<div class="elementor-widget-container">
													<img loading="lazy" decoding="async" data-attachment-id="5733" data-permalink="https://inero-software.com/best-keycloak-practices/a-2/" data-orig-file="https://inero-software.com/wp-content/uploads/2024/05/A-1.png" data-orig-size="300,300" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="A" data-image-description="" data-image-caption="" data-medium-file="https://inero-software.com/wp-content/uploads/2024/05/A-1.png" data-large-file="https://inero-software.com/wp-content/uploads/2024/05/A-1.png" tabindex="0" role="button" width="300" height="300" src="https://inero-software.com/wp-content/uploads/2024/05/A-1.png" class="attachment-large size-large wp-image-5733" alt="" srcset="https://inero-software.com/wp-content/uploads/2024/05/A-1.png 300w, https://inero-software.com/wp-content/uploads/2024/05/A-1-80x80.png 80w, https://inero-software.com/wp-content/uploads/2024/05/A-1-75x75.png 75w, https://inero-software.com/wp-content/uploads/2024/05/A-1-50x50.png 50w" sizes="(max-width: 300px) 100vw, 300px" data-attachment-id="5733" data-permalink="https://inero-software.com/best-keycloak-practices/a-2/" data-orig-file="https://inero-software.com/wp-content/uploads/2024/05/A-1.png" data-orig-size="300,300" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="A" data-image-description="" data-image-caption="" data-medium-file="https://inero-software.com/wp-content/uploads/2024/05/A-1.png" data-large-file="https://inero-software.com/wp-content/uploads/2024/05/A-1.png" role="button" />													</div>
				</div>
				</div>
		<div class="elementor-element elementor-element-66669028 e-con-full e-flex e-con e-child" data-id="66669028" data-element_type="container">
				<div class="elementor-element elementor-element-1143e95c elementor-widget elementor-widget-text-editor" data-id="1143e95c" data-element_type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
							<p>The first and most crucial step is to ensure all communication with the Keycloak server is done through the secure HTTPS protocol. Using SSL/TLS certificates from trusted providers protects against data interception and manipulation.</p><p><strong>In this step:</strong></p><ul><li style="list-style-type: none;"><ul><li>Configure the Keycloak Server: Set the server to use only HTTPS, rejecting all unencrypted HTTP requests.</li><li>Update Certificates: Regularly renew and update SSL/TLS certificates to avoid the risk of exploiting outdated keys.</li></ul></li></ul>						</div>
				</div>
				</div>
					</div>
				</div>
		<div class="elementor-element elementor-element-279981c2 e-flex e-con-boxed e-con e-parent" data-id="279981c2" data-element_type="container">
					<div class="e-con-inner">
				<div class="elementor-element elementor-element-68fbf093 elementor-widget elementor-widget-heading" data-id="68fbf093" data-element_type="widget" data-widget_type="heading.default">
				<div class="elementor-widget-container">
			<h3 class="elementor-heading-title elementor-size-default">Implement Multi-Factor Authentication (MFA)</h3>		</div>
				</div>
					</div>
				</div>
		<div class="elementor-element elementor-element-1f058e7f e-flex e-con-boxed e-con e-parent" data-id="1f058e7f" data-element_type="container">
					<div class="e-con-inner">
		<div class="elementor-element elementor-element-7650b8d8 e-con-full e-flex e-con e-child" data-id="7650b8d8" data-element_type="container">
				<div class="elementor-element elementor-element-3955e36d elementor-widget elementor-widget-image" data-id="3955e36d" data-element_type="widget" data-widget_type="image.default">
				<div class="elementor-widget-container">
													<img loading="lazy" decoding="async" data-attachment-id="5734" data-permalink="https://inero-software.com/best-keycloak-practices/b-2/" data-orig-file="https://inero-software.com/wp-content/uploads/2024/05/B-1.png" data-orig-size="300,300" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="B" data-image-description="" data-image-caption="" data-medium-file="https://inero-software.com/wp-content/uploads/2024/05/B-1.png" data-large-file="https://inero-software.com/wp-content/uploads/2024/05/B-1.png" tabindex="0" role="button" width="300" height="300" src="https://inero-software.com/wp-content/uploads/2024/05/B-1.png" class="attachment-large size-large wp-image-5734" alt="" srcset="https://inero-software.com/wp-content/uploads/2024/05/B-1.png 300w, https://inero-software.com/wp-content/uploads/2024/05/B-1-80x80.png 80w, https://inero-software.com/wp-content/uploads/2024/05/B-1-75x75.png 75w, https://inero-software.com/wp-content/uploads/2024/05/B-1-50x50.png 50w" sizes="(max-width: 300px) 100vw, 300px" data-attachment-id="5734" data-permalink="https://inero-software.com/best-keycloak-practices/b-2/" data-orig-file="https://inero-software.com/wp-content/uploads/2024/05/B-1.png" data-orig-size="300,300" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="B" data-image-description="" data-image-caption="" data-medium-file="https://inero-software.com/wp-content/uploads/2024/05/B-1.png" data-large-file="https://inero-software.com/wp-content/uploads/2024/05/B-1.png" role="button" />													</div>
				</div>
				</div>
		<div class="elementor-element elementor-element-20d76839 e-con-full e-flex e-con e-child" data-id="20d76839" data-element_type="container">
				<div class="elementor-element elementor-element-75519313 elementor-widget elementor-widget-text-editor" data-id="75519313" data-element_type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
							<p>This feature adds a layer of security by simultaneously using multiple methods to verify a user&#8217;s identity. 2FA (Two-Factor Authentication) is a popular form of MFA that often requires users to enter a password and confirm their identity with a second factor, such as a code from an authentication app.</p><p><strong>In this step:</strong></p><ul><li style="list-style-type: none;"><ul><li>Activate Multi-Factor Authentication in Keycloak: Enable MFA for all users, especially those with administrative access and access to sensitive data.</li><li>Choose Authentication Methods: Keycloak supports various MFA methods; commonly used ones include authentication apps (e.g., Microsoft Authenticator).</li></ul></li></ul>						</div>
				</div>
				</div>
					</div>
				</div>
		<div class="elementor-element elementor-element-6be692a3 e-flex e-con-boxed e-con e-parent" data-id="6be692a3" data-element_type="container">
					<div class="e-con-inner">
				<div class="elementor-element elementor-element-6fcbca49 elementor-widget elementor-widget-text-editor" data-id="6fcbca49" data-element_type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
							<p><strong>Read also:</strong></p><ul><li style="list-style-type: none;"><ul><li><p><a href="https://inero-software.com/custom-sms-authenticator-with-keycloak/">Behind the Scenes: Custom SMS Authenticator with Keycloak</a></p></li><li><p><a href="https://inero-software.com/behind-the-scenes-2-implementing-email-based-mfa-in-keycloak/">Behind the Scenes #2: Implementing email-based MFA in Keycloak</a></p></li><li><p><a href="https://inero-software.com/multi-factor-authentication-in-keycloak/">Step-by-Step Guide to Enabling Multi-Factor Authentication (MFA) in Keycloak</a></p></li></ul></li></ul>						</div>
				</div>
				<div class="elementor-element elementor-element-7426ce1d elementor-widget elementor-widget-heading" data-id="7426ce1d" data-element_type="widget" data-widget_type="heading.default">
				<div class="elementor-widget-container">
			<h3 class="elementor-heading-title elementor-size-default">Implement strong password policies and session management</h3>		</div>
				</div>
					</div>
				</div>
		<div class="elementor-element elementor-element-5451df16 e-flex e-con-boxed e-con e-parent" data-id="5451df16" data-element_type="container">
					<div class="e-con-inner">
		<div class="elementor-element elementor-element-aa76bd2 e-con-full e-flex e-con e-child" data-id="aa76bd2" data-element_type="container">
				<div class="elementor-element elementor-element-2843e4f7 elementor-widget elementor-widget-image" data-id="2843e4f7" data-element_type="widget" data-widget_type="image.default">
				<div class="elementor-widget-container">
													<img loading="lazy" decoding="async" data-attachment-id="5735" data-permalink="https://inero-software.com/best-keycloak-practices/c-2/" data-orig-file="https://inero-software.com/wp-content/uploads/2024/05/C-1.png" data-orig-size="300,300" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="C" data-image-description="" data-image-caption="" data-medium-file="https://inero-software.com/wp-content/uploads/2024/05/C-1.png" data-large-file="https://inero-software.com/wp-content/uploads/2024/05/C-1.png" tabindex="0" role="button" width="300" height="300" src="https://inero-software.com/wp-content/uploads/2024/05/C-1.png" class="attachment-large size-large wp-image-5735" alt="" srcset="https://inero-software.com/wp-content/uploads/2024/05/C-1.png 300w, https://inero-software.com/wp-content/uploads/2024/05/C-1-80x80.png 80w, https://inero-software.com/wp-content/uploads/2024/05/C-1-75x75.png 75w, https://inero-software.com/wp-content/uploads/2024/05/C-1-50x50.png 50w" sizes="(max-width: 300px) 100vw, 300px" data-attachment-id="5735" data-permalink="https://inero-software.com/best-keycloak-practices/c-2/" data-orig-file="https://inero-software.com/wp-content/uploads/2024/05/C-1.png" data-orig-size="300,300" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="C" data-image-description="" data-image-caption="" data-medium-file="https://inero-software.com/wp-content/uploads/2024/05/C-1.png" data-large-file="https://inero-software.com/wp-content/uploads/2024/05/C-1.png" role="button" />													</div>
				</div>
				</div>
		<div class="elementor-element elementor-element-2b5cbff9 e-con-full e-flex e-con e-child" data-id="2b5cbff9" data-element_type="container">
				<div class="elementor-element elementor-element-1290ccc4 elementor-widget elementor-widget-text-editor" data-id="1290ccc4" data-element_type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
							<p>Password and session management are key to protecting user identities and preventing unauthorized access. They are the first line of defense against attacks such as brute force or phishing. Keycloak provides a wide range of configurable password policy settings from the administrative console.</p><p><strong>In this step:</strong></p><ul><li style="list-style-type: none;"><ul><li>Configure the password policy: Set precise rules for password selection to require specific lengths, complexity (e.g., the presence of special characters, uppercase and lowercase letters), and define the password&#8217;s lifespan and history.</li><li>Limit session lifespan: Set short but practical session and token lifespan to minimize the window for potential attacks. Automatically logging out users after a specified period of inactivity is important for preventing accidentally leaving sessions open on shared or public devices.</li></ul></li></ul>						</div>
				</div>
				</div>
					</div>
				</div>
		<div class="elementor-element elementor-element-e707ac4 e-flex e-con-boxed e-con e-parent" data-id="e707ac4" data-element_type="container">
					<div class="e-con-inner">
				<div class="elementor-element elementor-element-56e0aecf elementor-widget elementor-widget-text-editor" data-id="56e0aecf" data-element_type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
							<p><strong>Read also:</strong></p><ul><li style="list-style-type: none;"><ul><li><p><a href="https://inero-software.com/an-introduction-to-passkey-with-keycloak/">An introduction to Passkey with Keycloak</a></p></li><li><p><a href="https://inero-software.com/hands-on-keycloak-sso-from-setup-to-integration/">Hands-On Keycloak SSO: From Setup to Integration</a></p></li></ul></li></ul>						</div>
				</div>
				<div class="elementor-element elementor-element-550fb0e5 elementor-widget elementor-widget-heading" data-id="550fb0e5" data-element_type="widget" data-widget_type="heading.default">
				<div class="elementor-widget-container">
			<h3 class="elementor-heading-title elementor-size-default">Secure API endpoints and use Role-Based Access Control (RBAC)</h3>		</div>
				</div>
					</div>
				</div>
		<div class="elementor-element elementor-element-6a6f7976 e-flex e-con-boxed e-con e-parent" data-id="6a6f7976" data-element_type="container">
					<div class="e-con-inner">
		<div class="elementor-element elementor-element-6209077a e-con-full e-flex e-con e-child" data-id="6209077a" data-element_type="container">
				<div class="elementor-element elementor-element-365ac0a5 elementor-widget elementor-widget-image" data-id="365ac0a5" data-element_type="widget" data-widget_type="image.default">
				<div class="elementor-widget-container">
													<img loading="lazy" decoding="async" data-attachment-id="5736" data-permalink="https://inero-software.com/best-keycloak-practices/d-2/" data-orig-file="https://inero-software.com/wp-content/uploads/2024/05/D-1.png" data-orig-size="300,300" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="D" data-image-description="" data-image-caption="" data-medium-file="https://inero-software.com/wp-content/uploads/2024/05/D-1.png" data-large-file="https://inero-software.com/wp-content/uploads/2024/05/D-1.png" tabindex="0" role="button" width="300" height="300" src="https://inero-software.com/wp-content/uploads/2024/05/D-1.png" class="attachment-large size-large wp-image-5736" alt="" srcset="https://inero-software.com/wp-content/uploads/2024/05/D-1.png 300w, https://inero-software.com/wp-content/uploads/2024/05/D-1-80x80.png 80w, https://inero-software.com/wp-content/uploads/2024/05/D-1-75x75.png 75w, https://inero-software.com/wp-content/uploads/2024/05/D-1-50x50.png 50w" sizes="(max-width: 300px) 100vw, 300px" data-attachment-id="5736" data-permalink="https://inero-software.com/best-keycloak-practices/d-2/" data-orig-file="https://inero-software.com/wp-content/uploads/2024/05/D-1.png" data-orig-size="300,300" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="D" data-image-description="" data-image-caption="" data-medium-file="https://inero-software.com/wp-content/uploads/2024/05/D-1.png" data-large-file="https://inero-software.com/wp-content/uploads/2024/05/D-1.png" role="button" />													</div>
				</div>
				</div>
		<div class="elementor-element elementor-element-74f10df2 e-con-full e-flex e-con e-child" data-id="74f10df2" data-element_type="container">
				<div class="elementor-element elementor-element-1d5e23e elementor-widget elementor-widget-text-editor" data-id="1d5e23e" data-element_type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
							<p>Role-Based Access Control (RBAC) allows for defining roles, assigning them to users, and managing permissions, enabling control over API operations depending on the role.</p><p><strong>In this step:</strong></p><ul><li style="list-style-type: none;"><ul><li>Securing API endpoints: To secure API endpoints, it is crucial to apply appropriate authorization and authentication mechanisms:</li><li>Authentication: Implement authentication protocols such as OAuth 2.0 and OpenID Connect, so users and applications must prove their identity before gaining access to the API. Access tokens: Use access tokens, which contain information about user permissions, to verify access rights to various API resources. HTTPS: Ensure that all requests to the API are sent over HTTPS, protecting data from interception and modification. Role-Based Access Control (RBAC): Role-Based Access Control allows for managing user permissions based on their roles in the organization:</li><li>Defining roles: Establish roles that reflect different access levels in the application, e.g., administrator, user, guest, etc. Assigning roles: Assign roles to users that specify which resources and operations they can access. Managing permissions: Configure access policies in Keycloak to control which operations can be performed by users with a given role at specific API endpoints.</li></ul></li></ul>						</div>
				</div>
				</div>
					</div>
				</div>
		<div class="elementor-element elementor-element-4202f6c3 e-flex e-con-boxed e-con e-parent" data-id="4202f6c3" data-element_type="container">
					<div class="e-con-inner">
				<div class="elementor-element elementor-element-56b07dfe elementor-widget elementor-widget-text-editor" data-id="56b07dfe" data-element_type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
							<p><strong>Read also:</strong> </p><ul><li style="list-style-type: none;"><ul><li><p><a href="https://inero-software.com/exporting-accounts-to-federated-realms/">Exporting accounts to federated realms: A guide to Keycloak and LDAP Integration</a></p></li><li><p><a href="https://inero-software.com/organizations-in-keycloak-management-and-customization-of-authentication/">Organizations in Keycloak: Management and Customization of Authentication</a></p></li><li><p><a href="https://inero-software.com/keycloak-integration-guide-enabling-social-login-with-multiple-platforms-like-google/">Keycloak Integration Guide: Enabling Social Login with Multiple Platforms like Google</a></p></li><li><p><a href="https://inero-software.com/securing-java-spring-endpoints-with-keycloak/">Keycloak Integration Guide: Securing Java Spring Endpoints with Keycloak</a></p></li></ul></li></ul>						</div>
				</div>
				<div class="elementor-element elementor-element-7e2f75bc elementor-widget elementor-widget-heading" data-id="7e2f75bc" data-element_type="widget" data-widget_type="heading.default">
				<div class="elementor-widget-container">
			<h3 class="elementor-heading-title elementor-size-default">Regularly update and monitor the environment</h3>		</div>
				</div>
					</div>
				</div>
		<div class="elementor-element elementor-element-604a8f95 e-flex e-con-boxed e-con e-parent" data-id="604a8f95" data-element_type="container">
					<div class="e-con-inner">
		<div class="elementor-element elementor-element-aa37f1d e-con-full e-flex e-con e-child" data-id="aa37f1d" data-element_type="container">
				<div class="elementor-element elementor-element-32c70947 elementor-widget elementor-widget-image" data-id="32c70947" data-element_type="widget" data-widget_type="image.default">
				<div class="elementor-widget-container">
													<img loading="lazy" decoding="async" data-attachment-id="5737" data-permalink="https://inero-software.com/best-keycloak-practices/e-2/" data-orig-file="https://inero-software.com/wp-content/uploads/2024/05/E-1.png" data-orig-size="300,300" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="E" data-image-description="" data-image-caption="" data-medium-file="https://inero-software.com/wp-content/uploads/2024/05/E-1.png" data-large-file="https://inero-software.com/wp-content/uploads/2024/05/E-1.png" tabindex="0" role="button" width="300" height="300" src="https://inero-software.com/wp-content/uploads/2024/05/E-1.png" class="attachment-large size-large wp-image-5737" alt="" srcset="https://inero-software.com/wp-content/uploads/2024/05/E-1.png 300w, https://inero-software.com/wp-content/uploads/2024/05/E-1-80x80.png 80w, https://inero-software.com/wp-content/uploads/2024/05/E-1-75x75.png 75w, https://inero-software.com/wp-content/uploads/2024/05/E-1-50x50.png 50w" sizes="(max-width: 300px) 100vw, 300px" data-attachment-id="5737" data-permalink="https://inero-software.com/best-keycloak-practices/e-2/" data-orig-file="https://inero-software.com/wp-content/uploads/2024/05/E-1.png" data-orig-size="300,300" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="E" data-image-description="" data-image-caption="" data-medium-file="https://inero-software.com/wp-content/uploads/2024/05/E-1.png" data-large-file="https://inero-software.com/wp-content/uploads/2024/05/E-1.png" role="button" />													</div>
				</div>
				</div>
		<div class="elementor-element elementor-element-30809f8e e-con-full e-flex e-con e-child" data-id="30809f8e" data-element_type="container">
				<div class="elementor-element elementor-element-551283d9 elementor-widget elementor-widget-text-editor" data-id="551283d9" data-element_type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
							<p>Updating and continuously monitoring the Keycloak environment is essential to maintain high protection against new threats and security vulnerabilities. Keycloak updates appear every few months, and <a href="https://www.keycloak.org/">information about them can be found on the official project website or in the Keycloak documentation.</a></p><p><strong>In this step:</strong></p><ul><li style="list-style-type: none;"><ul><li>Updates: Regularly update Keycloak to the latest stable versions.</li><li>Monitoring and logging: Use monitoring tools to track any unusual behavior and respond quickly to potential security incidents. Set up logging systems to collect key information about system operation. For example, using Kubernetes, you can efficiently manage and scale monitoring and logging tools such as Prometheus and ELK Stack. Kubernetes facilitates the deployment and management of containers with these tools, automating their deployment, scaling, and repair, which is crucial for maintaining continuity of operation and security in distributed systems.</li><li>Choose a proven partner: If implementing Keycloak best practices seems like a labor-intensive process that will heavily burden your team at this stage, seek help from specialists in this field.</li></ul></li></ul>						</div>
				</div>
				</div>
					</div>
				</div>
		<div class="elementor-element elementor-element-120f3af2 e-flex e-con-boxed e-con e-parent" data-id="120f3af2" data-element_type="container">
					<div class="e-con-inner">
				<div class="elementor-element elementor-element-28f8a86 elementor-widget elementor-widget-text-editor" data-id="28f8a86" data-element_type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
							<p><strong>Read also:</strong></p><ul><li style="list-style-type: none;"><ul><li><p><a href="https://inero-software.com/how-to-create-and-apply-custom-themes-in-keycloak/">Customizing Your User Experience: How to Create and Apply Custom Themes in Keycloak</a></p></li><li><p><a href="https://inero-software.com/monitoring-and-securing-keycloak-performance-and-phishing-attack-protection/">Keycloak: Smart Tips for Monitoring and Protection with Built-in Configuration Tools</a></p></li><li><p><a href="https://inero-software.com/keycloak-migration-made-easy-tips-and-best-practices/">Keycloak Migration Made Easy: Tips and Best Practices</a></p></li></ul></li></ul>						</div>
				</div>
				<div class="elementor-element elementor-element-6ad5e2ef elementor-widget elementor-widget-text-editor" data-id="6ad5e2ef" data-element_type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
							<p>Inero Software has extensive experience in implementing advanced cybersecurity solutions. We create comprehensive systems for managing users and their roles, tailored to complex IT infrastructures and meeting high corporate standards. Our team, consisting of cybersecurity experts, implements advanced authorization schemes in accordance with renowned security standards. Thanks to our knowledge and experience, we provide effective protection against threats and compliance with corporate security policies.</p>						</div>
				</div>
					</div>
				</div>
				</div>
		<p>Artykuł <a href="https://inero-software.com/best-keycloak-practices/">Best Practices in Keycloak: Secure Your System in 5 Steps</a> pochodzi z serwisu <a href="https://inero-software.com">Inero Software - Software Consulting</a>.</p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">5732</post-id>	</item>
	</channel>
</rss>
