Spring Boot Azure AD B2C User Management - spring-boot

I have a Spring Boot App (REST API only) which I want to connect to Azure AD B2C for the User Management. I created the Active Directory B2C, registered my app, and set up a Sign in and Aign up User Flow. I read a lot about how to connect that to Spring Security for authorization. Also, I saw those two endpoints that I can use:
https://<tenant-name>.b2clogin.com/<tenant-name>.onmicrosoft.com/<policy-name>/oauth2/v2.0/authorize
https://<tenant-name>.b2clogin.com/<tenant-name>.onmicrosoft.com/<policy-name>/oauth2/v2.0/token
But how can I actually CREATE a new User? Is there an endpoint for the sign up, that I can call with an email and password and that creates a User Account in my Azure AD B2C Tenant?

Related

Spring webapp with multiple auth type: basic and social login togheter

I wrote a spring boot webapp with spring security authentication over jpa. It uses jwt to grant access to a simple html/js application.
I'd like to add oauth2 flow in order to allow users to authenticate over github or google or whatever cloud system.
What kind of solution may I adopt to target it?
I see many applications like udemy, for example, or others. They allow multiple authentication types:
username and password
google account
facebook account
How may I replicate this behaviour in my webapp?

How to generate access token for testing with Azure AD

We have a spring boot REST API which will be used by mobile client. Azure AD is used for auth. We need to generate access token for initial testing spring boot REST API. What is the recommended option for this?
Basically we need to to generate access token using client credentials and call the REST API end point using the access token. Then on the REST API, validate access token and print the app roles assigned in Azure AD.
To get the access token from Azure AD to authenticate and authorize users from Azure AD.
First, you need to register both the application mobile client and spring boot applications in your Azure AD. Refer register your application in the Azure AD.
To generate access token using client credentials flow, there would be no user involvement, so your server application needs to create an appRole, and then grant the app Role as an application permission to the client application.
The administrator must grant the correct application permissions via a consent process to access the application.
Configure the application's details registered in Azure AD to your spring boot application.properties file with application id, tenant id, client-secret and scope.
Refer guide to configure client application to access a web API using spring boot step by step.

Custom Role Based Authorization in Spring Boot

I am developing a web application where I have React as my Frontend and Spring boot as the Backend REST API. I have authentication mechanism setup where user can login with email and password. My application will be used by a group of people for a company. The admin user will login initially and sends invites to other people in the group with predefined access privileges available in the application. How can I implement this type of role based access in spring boot.
I gone across Spring security for role based access, but I didn't find how to create custom fine grained roles based on our web application. Please someone help just to give me the path I need to go.
P.S: I want to implement the way AWS or other cloud providers implement there IAM roles to assign it to different users in their organization but not as complex but a similar functionality

How can I use Oracle SSO SAML in Azure API Management for Authentication

Our organization uses Oracle sso saml for all application authenticarion. We are planning to move our on prem to azure paas as APIs behind API Management.
Is there any reference document to how to setup SAML based auth provider in API Management.
Thanks,
Mahesh B
Here are some documents for your reference.
You can use Azure AD as the auth provider. Protect an API by using OAuth 2.0 with Azure Active Directory and API Management.
Single sign-on to applications in Azure Active Directory.
Oracle Cloud Infrastructure as a basic SAML single sign-on application in Azure AD.

Spring Boot REST service – End User Authentication vs APP (REST client) Authentication

I have gone through many posts and articles but didn't find a straightforward solution for the case below which I have to implement.
Platform: Spring Boot 2.x.x (Spring Security 5.x.x) with embed Tomcat
Solution: REST service that consume many client apps and many end users.
I have to implement a REST end point /api/search which accessible for many client application. As an example, web application APP-X (Angular), web application APP-Y(Jquery/Bootstrap) and mobile application APP-Z (IOS). All three clients are separate entities (both technical perspective and business perspective).
So I have to authenticate above application using onetime token. Therefore I planned to go for Spring OAuth2 by enabling #EnableAuthorizationServer and #EnableResourceServer. For each app client I’ll generate a token and they can use it when they connect with my REST service. Is this approach correct?
Apart from the app clients system has capability to register and login functionality for end users. Also my end point (/api/search) can access both anonymous users and users who registered under ROLE_REGUSER role. And through the security context, I need to access the user details as usual user authentication.
This is the place I got stuck. How can I handle the following points together using Spring Security 5.x.x (Spring Boot 2.x.x).
I. Both client apps and end users authentications.
II. Allow access for anonymous users and registered users for same end point.
I have attached small diagram to elaborate the above scenario.
Thanks
I found a solution when I upgraded my spring security version to 5.2. In version 5.2, they have depreciated #EnableAuthorizationServer and #EnableResourceServer. So I had to move with an external authorization provider who supports auth2. I chose AWS Cognito, and fulfill the above requirement, using the user pool option.
In AWS Cognito
I created a user pool.
Then created two app clients in the same user pool.
One app client configured as support to the client credentials flow.
The second app client configured as support to the user authentication flow.
In client applications
Retrieve access token directly from AWS Cognito using client credentials and used to secure all API calls.
If a user login at any stage, retrieve access token directly from AWS Cognito using the authorization code and replace any existing access token.
The advantage is, the resources server can validate any access token that generated related to the same user pool.
In resources server (backend API/Spring Boot)
Validate access token.

Resources