is there a smaple quarkus project with multiple named OidcClients to call multiple service calls? - quarkus

am looking for a sample quarkus reactive project with multiple OidcClients to make multiple service calls?
Eg: DemoProject wants to call service A, B, C, D.
DemoProject used keycloak authorization with grant type as password.
Service A has OidcClientA, service B has OidcClientB, service C has OidcClientC, Service D has OidcClientD.
How can we simply inject OidcClient into a specific service and fetching the specific token, authorization header to a specific service automatically?
Quarkus Documentation: https://quarkus.io/guides/security-openid-connect-client

This is completely possible, and actually very easy.
The problem is that is not properly documented; i had to dig into quarkus source code to find it.
In your application.properties, just add the client-name you want after quarkus.oidc-client.
For example, before named client:
quarkus.oidc-client.auth-server-url=<url>
Will then become
quarkus.oidc-client.<client-name>.auth-server-url=<url>
Then in the code, where Tokens or OidcClient is injected, just add #NamedOidcClient("").
And that's it!
I will post with a working git later.

I couldn't find any sample project, but i think that you just need to configure the named clients in your properties files and they will be accesible through the OidcClients class.
Here you can find more information.
If you are going to consume each service individually I would suggest you create a facade or a service in front of the rest client to deal with this complexity or maybe a filter for each service rest-client

Related

Add authentication to wsdl service in Genexus

I'm studying how to create a web service with Genexus 17U10. The first part looks very simple, following this https://wiki.genexus.com/commwiki/servlet/wiki?4210,Web+Services+with+GeneXus I can expose the service and consume it in another project. Now I want to add some kind of authorization but I can't find how to set it. Does genexus manage it somehow? I can't find informations about this
It is easier and recommended to use REST services and authenticate using GAM.
For SOAP services you have to add extra programming.

Custom Spring Actuator Endpoint which has subsystem and can be added dynamically

I'm looking for a way to implement custom endpoints for a reactive application using Spring Boot 2.2.
The endpoints have some subsystems and perform specific resource operations on the subsystems. The URL paths look like:
/actuator/system1/subsystem_a
/actuator/system1/subsystem_b
/actuator/system2/subsystem_c
Furthermore, system1 and system2 are not both always deployed, so I'd like to add dynamically the endpoints of the deployed system only.
I know I can use ReactiveHealthContributorRegistry to add custom health check endpoints dynamically. Is there a similar way for a fully custom endpoint?
Thanks in advance.
It seems there is no way to construct such complex endpoints like what I asked in Spring Boot Actuator.
I finally decided to use RouterFunction and HandlerFunction referring to the following websites.
https://www.baeldung.com/spring-5-functional-web
https://spring.io/blog/2016/09/22/new-in-spring-5-functional-web-framework

Maintaining multiple API representations in an API Gateway for a set of Spring Boot Microservices

I am using AWS API Gateway and would like to construct multiple API's for a set of Spring Boot micro-services that exist behind the scenes, but do so automatically.
For example, lets say I have a User and Contract Micro-service and they expose a simple CRUD, I would like to make 2 API representations inside the API Gateway for these 2 micro-services however they will be in the context of an Admin and a User.
The Admin API would have full access to all operations (CRUD) of both micro-services, however, the User API would only allow Read from both micro-services.
My question is about maintaining the representation of these 2 API contexts (Admin and User) is there any way to easily generate the swagger(s) that I would need that I can synchronize the API Gateway with without having to manually maintain this? Or is there a better approach that others are doing that im missing?
I have found spring fox which I was able to use and generate the swagger defs for the API at the microservice levels, but this only satisfies the Admin Use case and not the User one from what I can tell.
Has anyone found an elegant solution to this?

Listing all deployed rest endpoints (spring-boot, tomcat)

I know there is a similar kind of question exist but if works only for glassfish server.
Listing all deployed rest endpoints (spring-boot, jersey)
Is it possible to list all my configured rest-endpoints with spring boot? The actuator lists all existing paths on startup, I want something similar for my custom services, so I can check on startup if all paths are configured correctly and use this info for client calls.
How do I do this? I use #Path/#GET annotations on my service beans and register them via ResourceConfig#registerClasses.
Is there a way to query the Config for all Paths?
Update2: I want to have something like
GET /rest/mycontroller/info
POST /res/mycontroller/update
...
In my opinion, you are already using the right tool (actuator) to answer to your request.
Actuator gives you all the rest method running and you can configure it on your own, by disabling/enabling specific endpoints
If you have a look on the documentationprobably it can help you.
In any case, the default configuration of actuator display the endpoints (built-in in Intellij for your development).

how to make spring mvc functions available for rest calls

I have a spring mvc application which runs correctly,now another colleague wants to call the same functions from another application but he needs REST URL of my functions.
how is it possible to provide the same functionality through spring REST?
is it just with new annotations .please provide some resource to show me how to do it.
when server has a service, only legal clients which had any contracts with server can access it. And clients can use service by the way such as: use RestTemplate to get/post request to URL of service, and clients can get data as JSON, or XML type if you have an equivalent object as this image:
Also, a service can be support as a interface, ex: google search is a service supported by google, but it's not rest service.
If you know each other URL address you can consume each other REST API from java code by using RestTemplate object.
I would advise you to go over the Spring starter guide which deals with that issue, here is the link (Consuming a RESTful Web Service):
https://spring.io/guides/gs/consuming-rest/

Resources