Keycloak Documentation
Keycloak Documentation
1 Download keycloak
3. Create realm
4. Create Client
5. Create Role
NOTE: To be continued . . .
1. Install dependencies
❖ @react-keycloak/web
❖ Keycloak-js
❖ Realm
❖ Client Id
❖ Server URL
❖ Secret, and more to be added if necessary
4. Create a login page component or Use built-in login page from keycloak
1. Install dependencies
❖ nest-keycloak-connect
❖ passport
❖ @nestjs/passport
❖ Passport-keycloak
❖ Both can be used to validate tokens and authentications with both having their pros and cons.
❖ Keycloak Strategy: You can create a custom strategy by extending the KeycloakStrategy class.
This approach provides more flexibility and allows you to implement a complex and flexible
authentication process.
❖ AuthGuard: provided by nestjs-keycloak. This approach offers simplicity, convenience, and
requires less code. The AuthGuard handles token validation and authentication automatically.
4. Protect Routes
Reference
• https://medium.com/devops-dudes/secure-nestjs-rest-api-with-keycloak-745ef32a2370
• https://www.javahabit.com/2023/03/14/Securing-react-app-keycloak/
• Github Repo: https://github.com/dasniko/keycloak-reactjs-demo