 Hello Java developers, my name is Matt Rabel. Today I'd like to show you how to build a secure REST API and native image with Quarkus. Let's get it up. I created a demo script for this screencast which you can find in this native Java examples repo demo-quarkus and it uses ASCII doctor so I have a handy-dandy ASCII doctor plugin I can use here and we'll just build a simple REST API that returns the user's information. We'll use a JWT or an access token to access it and then I'll compare its performance with other frameworks like Micronaut, Spring Boot, and Helodon. And we'll go ahead and ensure that we have SDKman from SDKman.io and then HTTPIE, HTTP is how you're supposed to say it and then the octa CLI. And if you don't have the octa CLI you can get it from cli.octa.com. Now as we're going through this there are some times when I will type a bit of code and it spits out a bunch of code so those are using IntelliJ Live templates you can find mine on GitHub at mrable slash ideolive templates and you'll need SDKman to install Java 17 with girlvm so SDK installed Java there and if you're using a different version and you're using SDKman you can just do SDK default Java and then that version number so 221 is the first version that works on the M1s and I'm using an M1 to record this. So then you need the octa CLI to create a new account so if you don't have an account you can do octa register. I already have one so I'm going to do octa apps create spa and this will be an app that we can use to actually get those access tokens so I'm going to use oidc debugger for this and that's at oidc debugger and the redirect is at debug and the logout will work just fine and then we can open up the oidc debugger website and it's got my information in here from the last time I used it my client id did change but you'll want to make sure and use your issuer that octa gives you plus v1 authorized here and then down in the token uri make sure and use v1 token right there check code check use pixie pkce proof key for code exchange and hit send request and then we get our access token back and we can go ahead and set that here in our terminal then back to our tutorial we'll go ahead and use maven in our downloads directory here and this maven command to create a brand new corkis app using small rye jwt and rest easy reactive and once we have that created we can cd into corkis and open it up in intelligent then we'll want to modify the hello resource and I have a quick shortcut qk hello and you can see it takes a get request to hello and it's authenticated so it requires that you authenticate and then we'll return the principal's name and now we can add our octa information for a micro profile and its jwt support and this will be our octa tenant back here so we should have that in our terminal and scroll up a bit grab it from right here paste it there and you can see the public key location which is at v1 keys and then the issuer itself and we can modify the test because that will fail now because it's looking for a 200 so we'll change that to a 401 and then there is no message so let's go ahead and set that and then we can build it and run it using corkis dev and we can open a new terminal window and hit it at 8080 hello we'll get a 401 right we're not authorized to do that reset our token and then hit it with an access token using http ie so we're passing in that token now and we get a 200 back and it returns my email address pretty slick huh now we can convert or first we want to kill you know that previous process on 8080 make sure it's down sure enough and then we can package as a native application so you can see that took about 50 seconds to build so not terrible but a lot longer than you know good old nvm package so now we could start it up using target and it'll be corkis 1.0.0 snapshot runner and that started in 21 milliseconds let's make that a bit bigger and 11 milliseconds wow try it again and 13 milliseconds so pretty quick right 11 13 like awesome we can look at the startup time comparisons for the various frameworks so what i did here is i started each one three times and then i ran it five more and i took the average of that so this is on a macbook pro intel which i think was from 2018 64 gigs around like you know as fast as they were on intel and you can see corkis starts in around 20 seconds so 19 seconds micronaut 30 seconds spring boot almost a minute or not a minute but 60 milliseconds so these are all milliseconds not seconds sorry about that and then i did some memory usage comparison then you'll see that you know corkis when it first starts up uses 23 megabytes after the first request it's 34 and then after five requests it only increases a couple megabytes so that's pretty awesome and then i also did it with my m1 max which i'm recording this on and you'll see corkis averages 12 milliseconds to start so so fast so fast you barely even notice right and then megabytes used on start it's a bit more than intel up here you know 23 versus 33 and then after five requests a bit more as well so i'm not sure you know what the difference is between intel and and m1 as far as it comes to memory but um you know really nice developer experience where it builds much faster and we've also built this into the octa cli so if we were to go to downloads here and just create a temp directory you can do octa start corkis and it'll create an app for you on octa and oidc web app and configure it to you know work with corkis and then tell you what to do so pretty slick right and then you can find all this example's code on github here you know it uses corkis 290 there and then of course the blog post that this originated from build native java apps with all these frameworks so i hope you've enjoyed this screencast today you can find me on twitter at mrable you can find my team on twitter at octa dev and subscribe to our youtube channel so you can get more cool content like this thanks have a great day