Skip to content

Instantly share code, notes, and snippets.

@sairamkrish
Created August 9, 2018 17:54
Show Gist options
  • Save sairamkrish/8d889f3478a4db0bc9ed9e8dfd748434 to your computer and use it in GitHub Desktop.
Save sairamkrish/8d889f3478a4db0bc9ed9e8dfd748434 to your computer and use it in GitHub Desktop.
Keycloak - angular - example routing
import { NgModule } from '@angular/core';
import { Routes, RouterModule, PreloadAllModules } from '@angular/router';
import { AppAuthGuard } from './app.authguard';
...
const appRoutes: Routes = [
{
path: 'some-path-only-super-user-can-access',
loadChildren: () => SomeModule ,
canActivate: [AppAuthGuard],
data: { roles: ['SuperUser'] }
},
{
path: 'some-other-path',
loadChildren: () => SomeOtherModule ,
canActivate: [AppAuthGuard],
data: { roles: ['SuperUser', 'NormalUser'] }
},
...
];
@NgModule({
...
providers: [AppAuthGuard]
})
export class AppRoutingModule {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment