From: Martin Stockhammer Date: Fri, 8 Jan 2021 21:18:14 +0000 (+0100) Subject: Adding base security config X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=cb3c2e2e041577df0de25f9c5b6c180cd58bc491;p=archiva.git Adding base security config --- diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/package-lock.json b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/package-lock.json index d214b092c..4c3d50efd 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/package-lock.json +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/package-lock.json @@ -177,6 +177,23 @@ "tslib": "^2.0.0" } }, + "@angular/cdk": { + "version": "11.0.3", + "resolved": "https://registry.npmjs.org/@angular/cdk/-/cdk-11.0.3.tgz", + "integrity": "sha512-hgbJXvZURKBnZawwxUrsZE/3a+HCJh2UhoLIng3cn5Q+WIW/4a37knDl8B9DYKBWrCqeINXNcUHVSKkWc/gjCA==", + "requires": { + "parse5": "^5.0.0", + "tslib": "^2.0.0" + }, + "dependencies": { + "parse5": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-5.1.1.tgz", + "integrity": "sha512-ugq4DFI0Ptb+WWjAdOK16+u/nHfiIrcE+sh8kZMaM0WllQKLI9rOUq6c2b7cwPkXdzfQESqvoqK6ug7U/Yyzug==", + "optional": true + } + } + }, "@angular/cli": { "version": "11.0.2", "resolved": "https://registry.npmjs.org/@angular/cli/-/cli-11.0.2.tgz", diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/package.json b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/package.json index 3f686c4d7..06b66662a 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/package.json +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/package.json @@ -12,6 +12,7 @@ "private": true, "dependencies": { "@angular/animations": "~11.0.2", + "@angular/cdk": "^11.0.3", "@angular/common": "~11.0.2", "@angular/compiler": "~11.0.2", "@angular/core": "~11.0.2", diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/app-routing.module.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/app-routing.module.ts index aa5083d6a..e3d9e88a6 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/app-routing.module.ts +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/app-routing.module.ts @@ -48,11 +48,11 @@ const routes: Routes = [ }, { - path: 'security', component: HomeComponent,canActivate:[Guard],data:{perm: 'menu.user.section'}, + path: 'security', component: HomeComponent,canActivate:[Guard],data:{perm: 'menu.security.section'}, children: [ - {path: 'users', loadChildren: () => import('./modules/security/user.module').then(m => m.UserModule)}, - {path: 'roles', loadChildren: () => import('./modules/security/role.module').then(m => m.RoleModule)}, - {path: 'config', component: SecurityConfigurationComponent}, + {path: 'users', loadChildren: () => import('@app/modules/security/user.module').then(m => m.UserModule)}, + {path: 'roles', loadChildren: () => import('@app/modules/security/role.module').then(m => m.RoleModule)}, + {path: 'config', loadChildren: () => import('@app/modules/security/security-configuration.module').then(m => m.SecurityConfigurationModule)}, ] }, {path: 'contact', component: ContactComponent}, diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/app.module.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/app.module.ts index d31202377..9cc81b621 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/app.module.ts +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/app.module.ts @@ -55,7 +55,6 @@ import {TranslateCompiler, TranslateLoader, TranslateModule} from "@ngx-translat SearchComponent, BrowseComponent, UploadComponent, - SecurityConfigurationComponent, ], imports: [ TranslateModule.forRoot({ diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/model/bean-information.spec.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/model/bean-information.spec.ts new file mode 100644 index 000000000..138cadce8 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/model/bean-information.spec.ts @@ -0,0 +1,7 @@ +import { BeanInformation } from './bean-information'; + +describe('BeanInformation', () => { + it('should create an instance', () => { + expect(new BeanInformation()).toBeTruthy(); + }); +}); diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/model/bean-information.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/model/bean-information.ts new file mode 100644 index 000000000..379262ab4 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/model/bean-information.ts @@ -0,0 +1,7 @@ +export class BeanInformation { + id: string; + display_name: string; + description_key: string; + default_description: string; + readonly: boolean; +} diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/model/error-result.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/model/error-result.ts index b54fa848f..4dd034822 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/model/error-result.ts +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/model/error-result.ts @@ -25,4 +25,32 @@ export class ErrorResult { constructor(errorMessages: Array) { this.error_messages = errorMessages; } + + hasMessages() :boolean { + return this.error_messages != null && this.error_messages.length > 0; + } + + public firstMessage() : ErrorMessage { + if (this.error_messages!=null && this.error_messages.length>0) { + return this.error_messages[0]; + } else { + return new ErrorMessage(); + } + } + + public firstMessageString() : string { + if (this.error_messages!=null && this.error_messages.length>0) { + return this.error_messages[0].message; + } else { + return ''; + } + } + + public toString() : string { + if (this.error_messages!=null && this.error_messages.length>0) { + return this.error_messages.join(','); + } else { + return 'status=' + this.status; + } + } } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/model/security-configuration.spec.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/model/security-configuration.spec.ts new file mode 100644 index 000000000..a02ee7af0 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/model/security-configuration.spec.ts @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { SecurityConfiguration } from './security-configuration'; + +describe('SecurityConfiguration', () => { + it('should create an instance', () => { + expect(new SecurityConfiguration()).toBeTruthy(); + }); +}); diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/model/security-configuration.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/model/security-configuration.ts new file mode 100644 index 000000000..5d9dc8e72 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/model/security-configuration.ts @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export class SecurityConfiguration { + + active_user_managers: string[]; + active_rbac_managers: string[]; + ldap_active: boolean; + user_cache_enabled: boolean; +} diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/role-routing.module.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/role-routing.module.ts index 1be49d717..05d926514 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/role-routing.module.ts +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/role-routing.module.ts @@ -31,7 +31,7 @@ import {ManageRolesEditComponent} from "@app/modules/security/roles/manage-roles const routes: Routes = [ { path: '', component: ManageRolesComponent, canActivate: [Guard], - data: {perm: 'menu.user.roles'}, + data: {perm: 'menu.security.roles'}, children: [ {path: 'list', component: ManageRolesListComponent}, {path: 'edit/:roleid', component: ManageRolesEditComponent}, diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration-routing.module.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration-routing.module.ts new file mode 100644 index 000000000..4b40ce41e --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration-routing.module.ts @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import {NgModule} from '@angular/core'; +import {RouterModule, Routes} from '@angular/router'; +import {RoutingGuardService as Guard} from "@app/services/routing-guard.service"; +import {SecurityConfigurationComponent} from "./security-configuration/security-configuration.component"; +import {BaseSecurityComponent} from "./security-configuration/base-security/base-security.component"; +import {LdapSecurityComponent} from "./security-configuration/ldap-security/ldap-security.component"; + + +/** + * You can use Guard (RoutingGuardService) for permission checking. The service needs data with one parameter 'perm', + * that gives the path of the uiPermission map of the user service. + */ + +const routes: Routes = [ + { path: '', component: SecurityConfigurationComponent,canActivate:[Guard], + data: { perm: 'menu.security.config' }, + children: [ + {path: 'base', component: BaseSecurityComponent}, + {path: 'ldap', component: LdapSecurityComponent}, + {path: '', redirectTo:'base',pathMatch:'full'} + ] + } +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [], + declarations: [] +}) +export class SecurityConfigurationRoutingModule { } + diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration.module.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration.module.ts new file mode 100644 index 000000000..e5ee11504 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration.module.ts @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import {NgModule} from '@angular/core'; +import {CommonModule} from '@angular/common'; +import {SharedModule} from "@app/modules/shared/shared.module"; +import {FormsModule, ReactiveFormsModule} from "@angular/forms"; +import {SecurityConfigurationComponent} from "./security-configuration/security-configuration.component"; +import {SecurityConfigurationRoutingModule} from "@app/modules/security/security-configuration-routing.module"; +import { BaseSecurityComponent } from './security-configuration/base-security/base-security.component'; +import { LdapSecurityComponent } from './security-configuration/ldap-security/ldap-security.component'; + + +@NgModule({ + declarations: [ + SecurityConfigurationComponent, + BaseSecurityComponent, + LdapSecurityComponent + ], + exports: [ + SecurityConfigurationComponent + ], + imports: [ + CommonModule, + SharedModule, + FormsModule, + ReactiveFormsModule, + SecurityConfigurationRoutingModule + ] +}) +export class SecurityConfigurationModule { +} diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/base-security/base-security.component.html b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/base-security/base-security.component.html new file mode 100644 index 000000000..fcf545f2a --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/base-security/base-security.component.html @@ -0,0 +1,83 @@ + + +
+
+
+
+
{{'security.config.base.user_manager.active_list'|translate}}
+
+
{{item.id}} - {{item.display_name}}
+
+
+
+
+
+
{{'security.config.base.user_manager.available_list' |translate}}
+
+
{{item.id}} - {{item.display_name}}
+
+
+
+
+ +
+
+
+
{{'security.config.base.rbac_manager.active_list'|translate}}
+
+
{{item.id}} - {{item.display_name}}
+
+
+
+
+
+
{{'security.config.base.rbac_manager.available_list' |translate}}
+
+
{{item.id}} - {{item.display_name}}
+
+
+
+
+
+
{{'security.config.base.flags'|translate}}
+
+
+ + +
+
+ + +
+ +
+
+ +
+
+ +
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/base-security/base-security.component.scss b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/base-security/base-security.component.scss new file mode 100644 index 000000000..1517b3948 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/base-security/base-security.component.scss @@ -0,0 +1,53 @@ +/*! + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +.drag-container { + width: 400px; + max-width: 100%; + margin: 0 25px 25px 0; + display: inline-block; + vertical-align: top; + background-color: #E9ECEF; + padding: 15px; + border-radius: 5px; +} + +.drop-list-group { + @extend .list-group; + background: white; + min-height: 50px; +} + +.cdk-drag-preview { + @extend .list-group-item; +} + +.cdk-drag-placeholder { + opacity: 0; +} + +.cdk-drag-animating { + transition: transform 250ms cubic-bezier(0, 0, 0.2, 1); +} + +.cdk-drop-list-receiving extends list-group-item { +} + +.list-group.cdk-drop-list-dragging .list-group-item:not(.cdk-drag-placeholder) { + transition: transform 250ms cubic-bezier(0, 0, 0.2, 1); +} \ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/base-security/base-security.component.spec.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/base-security/base-security.component.spec.ts new file mode 100644 index 000000000..2487b3255 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/base-security/base-security.component.spec.ts @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { BaseSecurityComponent } from './base-security.component'; + +describe('BaseSecurityComponent', () => { + let component: BaseSecurityComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ BaseSecurityComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(BaseSecurityComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/base-security/base-security.component.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/base-security/base-security.component.ts new file mode 100644 index 000000000..4b3acf521 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/base-security/base-security.component.ts @@ -0,0 +1,136 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import {AfterContentInit, Component, OnInit} from '@angular/core'; +import {ActivatedRoute} from "@angular/router"; +import {RoleService} from "@app/services/role.service"; +import {UserService} from "@app/services/user.service"; +import {FormBuilder} from "@angular/forms"; +import {ToastService} from "@app/services/toast.service"; +import {EditBaseComponent} from "@app/modules/shared/edit-base.component"; +import {SecurityConfiguration} from "@app/model/security-configuration"; +import { CdkDragDrop, moveItemInArray, transferArrayItem } from '@angular/cdk/drag-drop'; +import {SecurityService} from "@app/services/security.service"; +import {switchMap, tap, withLatestFrom} from 'rxjs/operators'; +import {BeanInformation} from "@app/model/bean-information"; +import {zip} from "rxjs"; +import {ErrorResult} from "@app/model/error-result"; + +@Component({ + selector: 'app-base-security', + templateUrl: './base-security.component.html', + styleUrls: ['./base-security.component.scss'] +}) +export class BaseSecurityComponent extends EditBaseComponent implements OnInit, AfterContentInit { + + activeUserManagers : BeanInformation[] = []; + availableUserManagers: BeanInformation[] = []; + activeRbacManagers: BeanInformation[] = []; + availableRbacManagers: BeanInformation[] = []; + + submitting: boolean = false; + + rbacInfo: Map = new Map(); + userInfo: Map = new Map(); + + drop(event: CdkDragDrop) { + console.log("Drop " + event); + if (event.previousContainer === event.container) { + moveItemInArray(event.container.data, event.previousIndex, event.currentIndex); + } else { + transferArrayItem(event.previousContainer.data, + event.container.data, + event.previousIndex, + event.currentIndex); + } + } + + constructor(private route: ActivatedRoute, + public fb: FormBuilder, private securityService: SecurityService, private toastService: ToastService) { + super(fb); + super.init(fb.group({ + user_cache_enabled:[''], + }, {})); + + + + } + + ngOnInit(): void { + zip(this.securityService.getRbacManagers(),this.securityService.getUserManagers()).pipe(tap(([rbacInfo,userInfo])=>{ + rbacInfo.forEach(info => this.rbacInfo.set(info.id, info)); + userInfo.forEach(info => this.userInfo.set(info.id, info)); + console.log("Rbac info " + JSON.stringify(this.rbacInfo)); + console.log("User info " + JSON.stringify(this.userInfo)); + }),switchMap(()=>this.securityService.getConfiguration())).subscribe(userConfig=>{ + this.activeRbacManagers=[]; + this.activeUserManagers=[]; + this.availableRbacManagers=[]; + this.availableUserManagers=[]; + this.userForm.get('user_cache_enabled').setValue(userConfig.user_cache_enabled); + let availableRbacManagers : string[] = Array.from(this.rbacInfo.keys()) + let availableUserManagers : string[] = Array.from(this.userInfo.keys()); + userConfig.active_rbac_managers.forEach(rbacId=>{ + this.activeRbacManagers.push(this.rbacInfo.get(rbacId)); + availableRbacManagers = availableRbacManagers.filter(item => item != rbacId); + }); + userConfig.active_user_managers.forEach(userId=>{ + this.activeUserManagers.push(this.userInfo.get(userId)); + availableUserManagers = availableUserManagers.filter(item => item != userId); + }); + availableRbacManagers.forEach(rbacId => this.availableRbacManagers.push(this.rbacInfo.get(rbacId))); + availableUserManagers.forEach(userId => this.availableUserManagers.push(this.userInfo.get(userId))); + }) + } + + createEntity(): SecurityConfiguration { + return undefined; + } + + onSubmit() { + if (this.activeUserManagers.length>0 && this.activeRbacManagers.length>0) { + this.submitting=true; + let sConfig = new SecurityConfiguration() + sConfig.active_user_managers = []; + sConfig.active_user_managers = this.activeUserManagers.map(uInfo => uInfo.id); + sConfig.active_rbac_managers = this.activeRbacManagers.map(rInfo => rInfo.id); + sConfig.user_cache_enabled = this.userForm.get('user_cache_enabled').value; + this.securityService.updateConfiguration(sConfig).subscribe(()=> + { + this.toastService.showSuccessByKey('base-security','security.config.base.submit_success') + this.submitting = false; + }, ( error :ErrorResult) => { + this.toastService.showErrorByKey('base-security','security.config.base.submit_error', + {'error':error.toString()}) + this.submitting = false; + } + ); + } else { + this.toastService.showErrorByKey('base-security','security.config.base.submit_active_empty') + } + + } + + ngAfterContentInit(): void { + } + + enableSubmit() : boolean { + return !this.submitting && this.activeUserManagers.length>0 && this.activeRbacManagers.length>0 && this.userForm.valid; + } + +} diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/ldap-security/ldap-security.component.html b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/ldap-security/ldap-security.component.html new file mode 100644 index 000000000..55895d827 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/ldap-security/ldap-security.component.html @@ -0,0 +1,19 @@ + + +

ldap-security works!

diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/ldap-security/ldap-security.component.scss b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/ldap-security/ldap-security.component.scss new file mode 100644 index 000000000..343c3b1c0 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/ldap-security/ldap-security.component.scss @@ -0,0 +1,18 @@ +/*! + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/ldap-security/ldap-security.component.spec.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/ldap-security/ldap-security.component.spec.ts new file mode 100644 index 000000000..7de23ee3f --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/ldap-security/ldap-security.component.spec.ts @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { LdapSecurityComponent } from './ldap-security.component'; + +describe('LdapSecurityComponent', () => { + let component: LdapSecurityComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ LdapSecurityComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(LdapSecurityComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/ldap-security/ldap-security.component.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/ldap-security/ldap-security.component.ts new file mode 100644 index 000000000..3c3b09588 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/ldap-security/ldap-security.component.ts @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'app-ldap-security', + templateUrl: './ldap-security.component.html', + styleUrls: ['./ldap-security.component.scss'] +}) +export class LdapSecurityComponent implements OnInit { + + constructor() { } + + ngOnInit(): void { + } + +} diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/security-configuration.component.html b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/security-configuration.component.html index ec4f0f99a..340af0734 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/security-configuration.component.html +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/security-configuration/security-configuration.component.html @@ -16,4 +16,13 @@ ~ under the License. --> -

security-configuration works!

+ + + diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/user-routing.module.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/user-routing.module.ts index c1cae57de..6f5f13acf 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/user-routing.module.ts +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/security/user-routing.module.ts @@ -33,7 +33,7 @@ import {RoutingGuardService as Guard} from "@app/services/routing-guard.service" const routes: Routes = [ { path: '', component: ManageUsersComponent,canActivate:[Guard], - data: { perm: 'menu.user.manage' }, + data: { perm: 'menu.security.users' }, children: [ {path: 'list', component: ManageUsersListComponent}, {path: 'add', component: ManageUsersAddComponent}, diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/shared/shared.module.ts b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/shared/shared.module.ts index 38fc25d71..ce7f45422 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/shared/shared.module.ts +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/shared/shared.module.ts @@ -39,6 +39,7 @@ import { StripLoadingPipe } from './strip-loading.pipe'; import { ToastComponent } from './toast/toast.component'; import { UserInfoComponent } from './user-info/user-info.component'; import {FormsModule} from "@angular/forms"; +import {DragDropModule} from "@angular/cdk/drag-drop"; export { LoadingValue } from './model/loading-value'; export { PageQuery } from './model/page-query'; @@ -68,9 +69,11 @@ export { PageQuery } from './model/page-query'; SortedTableHeaderRowComponent, WithLoadingPipe, StripLoadingPipe, - ToastComponent + ToastComponent, + DragDropModule ], imports: [ + DragDropModule, CommonModule, RouterModule, NgbPaginationModule, diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/shared/sidemenu/sidemenu.component.html b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/shared/sidemenu/sidemenu.component.html index cbded1e95..670074e17 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/shared/sidemenu/sidemenu.component.html +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/archiva-web/src/app/modules/shared/sidemenu/sidemenu.component.html @@ -52,15 +52,15 @@ {{'sidemenu.admin.reports'|translate}} -