feat(console): identity providers and login policies (#722)

* idp list, idp create route

* idp modules, lazy import, i18n, routing

* generic service, i18n

* seperate lockout, age policy component

* seperate component modules

* routing

* enum class

* login policy

* iam policy grid

* login policy providers

* idps login policy

* add idp dialog component

* add idp to loginpolicy

* delete idp config, iam policy grid

* remove idp from loginpolicy

* idp detail component, generic idp create

* lint

* idp detail clientid-secrets, issuer, scopes

* hide clientsecret on update

* rm background style, idp config

* app tooltip fix

* lint

* dont refresh on idp select

* Update console/src/app/modules/idp-create/idp-create.component.html

Co-authored-by: Fabiennne <[email protected]>
Co-authored-by: Fabi <[email protected]>
This commit is contained in:
Max Peintner
2020-09-17 10:22:41 +02:00
committed by GitHub
co-authored by Fabiennne Fabi
parent 845026e43f
commit 58b01cdf3f
96 changed files with 3401 additions and 735 deletions
@@ -2,7 +2,7 @@
<app-refresh-table *ngIf="eventDataSource" (refreshed)="loadEvents()" [dataSize]="eventDataSource.data.length"
[loading]="loading$ | async">
<table [dataSource]="eventDataSource" mat-table class="table background-style" aria-label="Elements">
<table [dataSource]="eventDataSource" mat-table class="table " aria-label="Elements">
<ng-container matColumnDef="viewName">
<th mat-header-cell *matHeaderCellDef> {{ 'IAM.FAILEDEVENTS.VIEWNAME' | translate }} </th>
<td mat-cell *matCellDef="let event"> {{event.viewName}} </td>
@@ -47,8 +47,7 @@
<tr mat-header-row *matHeaderRowDef="eventDisplayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: eventDisplayedColumns;"></tr>
</table>
<mat-paginator class="paginator background-style" [pageSize]="10" #paginator
[pageSizeOptions]="[10, 20, 100, 250]">
<mat-paginator class="paginator" [pageSize]="10" #paginator [pageSizeOptions]="[10, 20, 100, 250]">
</mat-paginator>
</app-refresh-table>
</div>
@@ -19,7 +19,7 @@
</ng-template>
<div class="table-wrapper">
<table mat-table class="background-style table" aria-label="Elements" [dataSource]="dataSource">
<table mat-table class="table" aria-label="Elements" [dataSource]="dataSource">
<ng-container matColumnDef="select">
<th class="selection" mat-header-cell *matHeaderCellDef>
<mat-checkbox color="primary" (change)="$event ? masterToggle() : null"
@@ -80,8 +80,7 @@
</tr>
</table>
<mat-paginator class="background-style paginator" #paginator [pageSize]="50"
[pageSizeOptions]="[25, 50, 100, 250]">
<mat-paginator class="paginator" #paginator [pageSize]="50" [pageSizeOptions]="[25, 50, 100, 250]">
</mat-paginator>
</div>
</app-refresh-table>
@@ -0,0 +1,30 @@
<h1>{{'ORG.POLICY.TITLE' | translate}}</h1>
<p class="top-desc">{{'ORG.POLICY.DESCRIPTION' | translate}}</p>
<div class="row-lyt">
<ng-template appHasRole [appHasRole]="['policy.read']">
<div class="p-item card">
<div class="avatar">
<i class="icon las la-gem"></i>
</div>
<div class="title">
<span>{{'ORG.POLICY.LOGIN_POLICY.TITLE' | translate}}</span>
<button mat-icon-button disabled>
<i *ngIf="loginPolicy" class="icon las la-check-circle"></i>
</button>
</div>
<p class="desc">
{{'ORG.POLICY.LOGIN_POLICY.DESCRIPTION' | translate}}</p>
<span class="fill-space"></span>
<div class="btn-wrapper">
<ng-template appHasRole [appHasRole]="['iam.policy.write']">
<button [disabled]="!loginPolicy" [routerLink]="[ 'policy', PolicyComponentType.LOGIN ]"
mat-stroked-button>{{'ORG.POLICY.BTN_EDIT' | translate}}</button>
</ng-template>
</div>
</div>
</ng-template>
</div>
@@ -0,0 +1,76 @@
h1 {
font-size: 1.2rem;
}
.top-desc {
color: #8795a1;
}
.row-lyt {
display: flex;
flex-wrap: wrap;
margin: 0 -1rem;
.p-item {
flex-basis: 300px;
margin: 1rem;
display: flex;
flex-direction: column;
min-height: 200px;
padding: 1rem;
@media only screen and (max-width: 450px) {
flex-basis: 100%;
}
.avatar {
height: 60px;
width: 60px;
border-radius: 50%;
background: linear-gradient(40deg, rgb(129, 85, 185) 30%, #8983f7);
display: flex;
align-items: center;
justify-content: center;
margin-bottom: .5rem;
.icon,
i {
font-size: 2.5rem;
height: 2.5rem;
line-height: 2.5rem;
}
}
.title {
display: flex;
align-items: center;
span {
font-size: 1.2rem;
}
.icon {
margin-left: 1rem;
margin-right: 1rem;
}
}
.desc {
font-size: .9rem;
color: #8795a1;
}
.fill-space {
flex: 1;
}
.btn-wrapper {
display: flex;
}
button {
margin-right: 1rem;
border-radius: .5rem;
}
}
}
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { IamPolicyGridComponent } from './iam-policy-grid.component';
describe('IamPolicyGridComponent', () => {
let component: IamPolicyGridComponent;
let fixture: ComponentFixture<IamPolicyGridComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [IamPolicyGridComponent],
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(IamPolicyGridComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,27 @@
import { Component } from '@angular/core';
import { PolicyComponentType } from 'src/app/modules/policies/policy-component-types.enum';
import { DefaultLoginPolicy } from 'src/app/proto/generated/admin_pb';
import { PolicyState } from 'src/app/proto/generated/management_pb';
import { AdminService } from 'src/app/services/admin.service';
@Component({
selector: 'app-iam-policy-grid',
templateUrl: './iam-policy-grid.component.html',
styleUrls: ['./iam-policy-grid.component.scss'],
})
export class IamPolicyGridComponent {
public loginPolicy!: DefaultLoginPolicy.AsObject;
public PolicyState: any = PolicyState;
public PolicyComponentType: any = PolicyComponentType;
constructor(
private adminService: AdminService,
) {
this.getData();
}
private getData(): void {
this.adminService.GetDefaultLoginPolicy().then(data => this.loginPolicy = data.toObject());
}
}
@@ -2,6 +2,7 @@ import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { AuthGuard } from 'src/app/guards/auth.guard';
import { RoleGuard } from 'src/app/guards/role.guard';
import { PolicyComponentServiceType, PolicyComponentType } from 'src/app/modules/policies/policy-component-types.enum';
import { IamComponent } from './iam.component';
@@ -22,6 +23,32 @@ const routes: Routes = [
roles: ['iam.member.read'],
},
},
{
path: 'idp/create',
loadChildren: () => import('src/app/modules/idp-create/idp-create.module').then(m => m.IdpCreateModule),
canActivate: [AuthGuard, RoleGuard],
data: {
roles: ['iam.idp.write'],
serviceType: PolicyComponentServiceType.ADMIN,
},
},
{
path: 'idp/:id',
loadChildren: () => import('src/app/modules/idp/idp.module').then(m => m.IdpModule),
canActivate: [AuthGuard, RoleGuard],
data: {
roles: ['iam.idp.read'],
serviceType: PolicyComponentServiceType.ADMIN,
},
},
{
path: `policy/${PolicyComponentType.LOGIN}`,
data: {
serviceType: PolicyComponentServiceType.ADMIN,
},
loadChildren: () => import('src/app/modules/policies/login-policy/login-policy.module')
.then(m => m.LoginPolicyModule),
},
];
@NgModule({
@@ -2,7 +2,7 @@
<app-refresh-table *ngIf="dataSource" (refreshed)="loadViews()" [dataSize]="dataSource.data.length"
[loading]="loading$ | async">
<table [dataSource]="dataSource" mat-table class="table background-style" aria-label="Elements">
<table [dataSource]="dataSource" mat-table class="table" aria-label="Elements">
<ng-container matColumnDef="viewName">
<th mat-header-cell *matHeaderCellDef> {{ 'IAM.VIEWS.VIEWNAME' | translate }} </th>
<td mat-cell *matCellDef="let view"> {{view.viewName}} </td>
@@ -40,8 +40,7 @@
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table>
<mat-paginator class="paginator background-style" [pageSize]="10" #paginator
[pageSizeOptions]="[10, 20, 100, 250]">
<mat-paginator class="paginator" [pageSize]="10" #paginator [pageSizeOptions]="[10, 20, 100, 250]">
</mat-paginator>
</app-refresh-table>
</div>
@@ -3,6 +3,16 @@
<h1 class="h1">{{'IAM.DETAIL.TITLE' | translate}}</h1>
<p class="sub">{{'IAM.DETAIL.DESCRIPTION' | translate}} </p>
<app-iam-policy-grid></app-iam-policy-grid>
<ng-template appHasRole [appHasRole]="['iam.idp.read']">
<app-card title="{{ 'IDP.LIST.TITLE' | translate }}" description="{{ 'IDP.LIST.DESCRIPTION' | translate }}">
<app-idp-table [service]="adminService" [serviceType]="PolicyComponentServiceType.ADMIN"
[disabled]="(['org.idp.write'] | hasRole | async) == false">
</app-idp-table>
</app-card>
</ng-template>
<app-card title="{{ 'IAM.VIEWS.TITLE' | translate }}" description="{{ 'IAM.VIEWS.DESCRIPTION' | translate }}">
<app-iam-views></app-iam-views>
</app-card>
+3 -1
View File
@@ -4,6 +4,7 @@ import { Router } from '@angular/router';
import { BehaviorSubject, from, Observable, of } from 'rxjs';
import { catchError, finalize, map } from 'rxjs/operators';
import { CreationType, MemberCreateDialogComponent } from 'src/app/modules/add-member-dialog/member-create-dialog.component';
import { PolicyComponentServiceType } from 'src/app/modules/policies/policy-component-types.enum';
import { OrgMemberView, UserView } from 'src/app/proto/generated/management_pb';
import { AdminService } from 'src/app/services/admin.service';
import { ToastService } from 'src/app/services/toast.service';
@@ -14,13 +15,14 @@ import { ToastService } from 'src/app/services/toast.service';
styleUrls: ['./iam.component.scss'],
})
export class IamComponent {
public PolicyComponentServiceType: any = PolicyComponentServiceType;
private loadingSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
public loading$: Observable<boolean> = this.loadingSubject.asObservable();
public totalMemberResult: number = 0;
public membersSubject: BehaviorSubject<OrgMemberView.AsObject[]>
= new BehaviorSubject<OrgMemberView.AsObject[]>([]);
constructor(private adminService: AdminService, private dialog: MatDialog, private toast: ToastService,
constructor(public adminService: AdminService, private dialog: MatDialog, private toast: ToastService,
private router: Router) {
this.loadMembers();
}
+6 -2
View File
@@ -22,20 +22,23 @@ import { ContributorsModule } from 'src/app/modules/contributors/contributors.mo
import { MetaLayoutModule } from 'src/app/modules/meta-layout/meta-layout.module';
import { RefreshTableModule } from 'src/app/modules/refresh-table/refresh-table.module';
import { SharedModule } from 'src/app/modules/shared/shared.module';
import { HasRolePipeModule } from 'src/app/pipes/has-role-pipe.module';
import { LocalizedDatePipeModule } from 'src/app/pipes/localized-date-pipe.module';
import { TimestampToDatePipeModule } from 'src/app/pipes/timestamp-to-date-pipe.module';
import { IdpTableModule } from '../../modules/idp-table/idp-table.module';
import { FailedEventsComponent } from './failed-events/failed-events.component';
import { IamPolicyGridComponent } from './iam-policy-grid/iam-policy-grid.component';
import { IamRoutingModule } from './iam-routing.module';
import { IamViewsComponent } from './iam-views/iam-views.component';
import { IamComponent } from './iam.component';
@NgModule({
declarations: [IamComponent, IamViewsComponent, FailedEventsComponent],
declarations: [IamComponent, IamViewsComponent, FailedEventsComponent, IamPolicyGridComponent],
imports: [
CommonModule,
IamRoutingModule,
IdpTableModule,
ChangesModule,
CardModule,
MatAutocompleteModule,
@@ -61,6 +64,7 @@ import { IamComponent } from './iam.component';
TimestampToDatePipeModule,
SharedModule,
RefreshTableModule,
HasRolePipeModule,
],
})
export class IamModule { }