 Welcome, everyone. In this screencast, I want to show you how easy it is to integrate keycloak into a Spring Boot project. So, keycloak is an identity management and authentication server. And during this screencast, I will really show you from scratch how you can use both of them. So, your journey starts on the keycloak.org site and there you simply go to the download section and you grab the latest server distribution. Then it's just a matter of unzipping it and starting it. In this screencast, I won't cover the full configuration of a keycloak server. It's pretty easy, but for that I will punch you to my blog post that comes with this screencast where I define all the steps to define your clients, your users, your walls and etc. I just want to focus here on the Spring Boot part. So, next step. What do you do when you start a new Spring Boot project? Of course, you go on start.spring.io and we will build a pretty simple web app. So, for that, we need the web starter. We need free marker because we will be building a Spring MVC app with some templates. And of course, we need keycloak. Let's call this Screencast. Let's call it product app. And let's generate this. Okay, we got here a zip file. Let's just extract that to our screencast folder here. Here we go. And then let's just open this project, which is here, Screencast product app. Okay, this window. Okay, we are ready to build our app. And it will be a really simple app just containing a home page, a landing page, which has one link, a product page, which will show us some product. And it's this product page that we want to secure. So, let's start by creating our landing page here in the static folder. I just create a new HTML file and I call it index.html. And here we keep it really simple. Let's create landing page. And here we just add a link to my products. Here we go, my products. Okay, next step is let's create a controller for our application. So, here I create a new controller and I call it class product, product controller. Here we go. I can make it a font bigger if you want. So, product controller. And what we want here is pretty simple mapping is when we go to products. Then, public string, get products here. We inject our SpringNVC model. And what we do here is pretty simple. We put our products in our model. So, let's call it products. And let's keep it simple here by doing arrays. Let's list and pass some products on iPad and iPhone and iPod. Okay, that's all. Let me move here to typo. And then we just returned the name of our template products. And that's all. Okay, so let's create this template here in templates. And I do a new file and I call it products.ftl because it's a free market template. So, here I need to do some imports. And my page will be pretty simple here. I call it my products. And what I will basically do is iterate between my products that are in my model. So, I do that with here. Here I iterate for my products. And one more thing that we want to add is a button to be able to log out. So, here I put a logout button. Let's call it logout. Let's make sure we have a break line here. Okay, so we're done. For logout, let's create logout controller. So, if I go here again, I do get mapping for the path. Sorry, logout. And that will be pretty simple string here. I call it logout. And I just inject my HTTP servlet request here. And what I do is request.logout. And I return the root path so I go back to the index. Okay, so that's all I need. Now I need to configure. Oh, I just need to add to throw an exception here. Okay, we are all good. Now I can configure my key cloak settings. And I don't need to touch the code at all. I just have to add some properties. And if I go here, key cloak, let me increase the font size. I have some mandatory fills. First one is where is my key cloak server running? Though in my case, it's running on the local host. But on port 8081 slash us. Okay, key cloak. On which realm is my app hosted? In this case, my app is hosted in a realm called spring demo resource. That's the name of my application on the key cloak site. So I keep it simple here. It's also product app. And I just need to mention if I'm using a public client. That's true. Okay, so for now, let's not add any security constraints. Let's just make sure that our app is running. So let me run that app now. So my app is running here. And if I go to my browser, let me open a new app. So I got here my landing page with just one link, my products. And when I click my products, I get my list of products. Great. So my app is running. Now I want to add some security constraints to be sure that this page right here is protected. How can I do that? It's pretty simple. I just need to define some security constraints. Just you will like do with the classic Java EE app in your web.xml. Well, here I do it here in the property style. Here I define a security constraint. And here I define a role. And what I want here is that only users with the role user can access the constraint that I will define. And here I just create a security collection. And I can pass some patterns, some URL patterns, meaning which patterns are asked to be protected. In my case, it's products slash star for a wild card. And that's it. Now if I run my app again, and that I go back to my application and I go back to the root path here, I click on my product. Oh, and here we see that I haven't defined a redirect wheel. Okay, that's not a big deal because I just have to go to my key cloak console, which is running here. And if I go to my product app, I just add here a valid redirect. Real well, in my case, 8080 slash star. I just save that. Okay, and let me go back to my product application here. And now I click on my products. And hey, you see, here I've been redirect to my key cloak server where I can log in. Here I've created a user SEBI with password SEBI, pretty simple. I log in and I'm redirected on my page. This page now is protected by key cloak. You cannot access it if you're not authenticated. Let's make sure the log out button is working. So here I press on log out and I go back to my product. And if I click on products again, you can see that I have my logging screen again. So let's just play a bit with this logging screen here. And if we go to our key cloak console, so my key cloak console is where I can control everything. My clients, my users, my walls, but also the behavior of my logging screen. And if I go to room settings, near login, I could say, well, I would like to have some user registration. I want to remember me, of course. I want to link if I have got my password. And I just click save. And again, if I go back to my app and I just refresh this page here. You can see that I got the remember me, the forget password. I can register a new user. So if I click here, I can just register as a new user. Last thing before, let's just add, for instance, you want to add some social login. You want to be able to log in with your Twitter account. So you click here on add identity provider. Here I put just dummy numbers. But here you should put your real client ID and client secret from the app that you have created in your Twitter desk console. I just do save here. Okay, again, let me refresh this page here. And you see, hey, I got a Twitter link. So here I can really log in with my Twitter account. This is the first part of the screencast. In the second part, we will show you how you can introduce some spring security. And after that, we will divide our spring app into two separate apps. One acting as a REST service. And we will see how a spring app can communicate with another spring app that is also secured by KeyCloud. Thank you.