Running the generated backend
- How to run
- Open SecurityFilterChain class from Config package
- On corsFilter() config.setAllowedOrigins(Arrays.asList("http://localhost:5173"));//set in the place of"http://localhost:5173" where ever your fronted being running
- Run This class
C:\folder_name\generated_project_name\src\main\java\com\rasp\app\Application.java
- create roles ,role to resource mapping and users,users to role mapping .(by following this users and permissions to resource are defined
- save Role (by using this roles are stored in keycloak)
- Api EndPoint
- Save Role to Resource Mapping(by using this role to resource mapping is done
- Api EndPoint
- http://localhost:8082/api/role_resource_permission
- Body
- (In form data) resource:encoded json object
- Api EndPoint
{"role": "member", "resource": "project", "action": ["GET_BY_ID", "MODIFY"]}
encode this using base64
-
- Here send resource in encode format in that one
{"role":"member","resource":"project","action":\["GET_BY_ID","MODIFY"\]}
,this is the formate to save role to resource mapping menction role ,resource and actions action is nothing but apis ,this mapping is kind of this role has access to this particular resource and in that these particular apis
- Here send resource in encode format in that one
- Adduser
- Api endPoint
- http://localhost:8082/api/auth/add_user
- Body
{ "resourceName": "Users", "authMap": { "userName":"member2", "[email":"[email protected]](mailto:email%22:%[email protected])", "firstName":"u1", "lastName":"u1", "password":"123" }, "resourceMap": { "user_name":"member2", "[user_email":"[email protected]](mailto:user_email%22:%[email protected])" } }
- We have to mention resource type first ,user resource type can different for particular user ,for ex(Student type,staff type,security type,and provide auth details ,and at last provide resource details based on resource resource object can be different based on userType
- Api endPoint
- Save user to role mapping
- Here we are mapping user to role so that user will get some permissions based on role
- Api EndPoint
- http://localhost:8082/api/auth/user_role_mapping
- Body
{ "role":"member", "userName":"abhi" }
- Perform login with registered user
- Api
- http://localhost:8082/api/auth/login
- Body
{ "username":"darshu", "password":"123" }
- Get the access token from cookies and use this token to perform api’s
- Api