keycloak-angular
keycloak-angular copied to clipboard
KeycloakAuthGuard example
Bug Report or Feature Request (mark with an x
)
- [ ] bug report
- [x] feature request
Versions.
- keycloak-angular: 15.0.0
- angular: 17.0.7
- keycloak: 23.0.4
Desired functionality.
Would be really nice to have the KeycloakAuthGuard being integrated into the example. Not just in the readme.
Just copy the AuthGuard found on the readme and then use it in the routes (app-routing.module.ts) in the following way
{ path: 'mypath', component: MyComponent , canActivate: [AuthGuard], data: { roles: ['user']}}
Are you experiencing any difficulties?
See https://github.com/mauriciovigolo/keycloak-angular/issues/526#issuecomment-1914140746 if you want to use Angular v14.2+ functional guards.
Thanks for the replies. I tried out the module with a project with Angular 17 and with standalone modules, and would have found an example for the AuthGuard pretty cool in the example application. As an Angular newbie, I still struggle a bit with a lot of resources using only NgModules, but v17 and the new Angular.dev site convinced me to start a new project with the standalone modules.
I selected "feature request" from the list, because it was the closest to "enhancement/wish".
me too same issue