mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
Merge pull request #2637 from DSpace/backport-2632-to-dspace-7_x
[Port dspace-7_x] Fixes "some item edit pages are accessible by anonymous users"
This commit is contained in:
@@ -38,6 +38,8 @@ import { ItemPageBitstreamsGuard } from './item-page-bitstreams.guard';
|
|||||||
import { ItemPageRelationshipsGuard } from './item-page-relationships.guard';
|
import { ItemPageRelationshipsGuard } from './item-page-relationships.guard';
|
||||||
import { ItemPageVersionHistoryGuard } from './item-page-version-history.guard';
|
import { ItemPageVersionHistoryGuard } from './item-page-version-history.guard';
|
||||||
import { ItemPageCollectionMapperGuard } from './item-page-collection-mapper.guard';
|
import { ItemPageCollectionMapperGuard } from './item-page-collection-mapper.guard';
|
||||||
|
import { ItemPageCurateGuard } from './item-page-curate.guard';
|
||||||
|
import { ItemPageAccessControlGuard } from './item-page-access-control.guard';
|
||||||
import { ThemedDsoEditMetadataComponent } from '../../dso-shared/dso-edit-metadata/themed-dso-edit-metadata.component';
|
import { ThemedDsoEditMetadataComponent } from '../../dso-shared/dso-edit-metadata/themed-dso-edit-metadata.component';
|
||||||
import { ItemPageRegisterDoiGuard } from './item-page-register-doi.guard';
|
import { ItemPageRegisterDoiGuard } from './item-page-register-doi.guard';
|
||||||
import { ItemCurateComponent } from './item-curate/item-curate.component';
|
import { ItemCurateComponent } from './item-curate/item-curate.component';
|
||||||
@@ -87,7 +89,8 @@ import { ItemAccessControlComponent } from './item-access-control/item-access-co
|
|||||||
{
|
{
|
||||||
path: 'curate',
|
path: 'curate',
|
||||||
component: ItemCurateComponent,
|
component: ItemCurateComponent,
|
||||||
data: { title: 'item.edit.tabs.curate.title', showBreadcrumbs: true }
|
data: { title: 'item.edit.tabs.curate.title', showBreadcrumbs: true },
|
||||||
|
canActivate: [ItemPageCurateGuard]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'relationships',
|
path: 'relationships',
|
||||||
@@ -116,7 +119,8 @@ import { ItemAccessControlComponent } from './item-access-control/item-access-co
|
|||||||
{
|
{
|
||||||
path: 'access-control',
|
path: 'access-control',
|
||||||
component: ItemAccessControlComponent,
|
component: ItemAccessControlComponent,
|
||||||
data: { title: 'item.edit.tabs.access-control.title', showBreadcrumbs: true }
|
data: { title: 'item.edit.tabs.access-control.title', showBreadcrumbs: true },
|
||||||
|
canActivate: [ItemPageAccessControlGuard]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'mapper',
|
path: 'mapper',
|
||||||
@@ -202,11 +206,13 @@ import { ItemAccessControlComponent } from './item-access-control/item-access-co
|
|||||||
ItemPageWithdrawGuard,
|
ItemPageWithdrawGuard,
|
||||||
ItemPageAdministratorGuard,
|
ItemPageAdministratorGuard,
|
||||||
ItemPageMetadataGuard,
|
ItemPageMetadataGuard,
|
||||||
|
ItemPageCurateGuard,
|
||||||
ItemPageStatusGuard,
|
ItemPageStatusGuard,
|
||||||
ItemPageBitstreamsGuard,
|
ItemPageBitstreamsGuard,
|
||||||
ItemPageRelationshipsGuard,
|
ItemPageRelationshipsGuard,
|
||||||
ItemPageVersionHistoryGuard,
|
ItemPageVersionHistoryGuard,
|
||||||
ItemPageCollectionMapperGuard,
|
ItemPageCollectionMapperGuard,
|
||||||
|
ItemPageAccessControlGuard,
|
||||||
ItemPageRegisterDoiGuard,
|
ItemPageRegisterDoiGuard,
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
@@ -0,0 +1,31 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { ActivatedRouteSnapshot, Router, RouterStateSnapshot } from '@angular/router';
|
||||||
|
import { AuthorizationDataService } from '../../core/data/feature-authorization/authorization-data.service';
|
||||||
|
import { ItemPageResolver } from '../item-page.resolver';
|
||||||
|
import { Item } from '../../core/shared/item.model';
|
||||||
|
import { DsoPageSingleFeatureGuard } from '../../core/data/feature-authorization/feature-authorization-guard/dso-page-single-feature.guard';
|
||||||
|
import { Observable, of as observableOf } from 'rxjs';
|
||||||
|
import { FeatureID } from '../../core/data/feature-authorization/feature-id';
|
||||||
|
import { AuthService } from '../../core/auth/auth.service';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
/**
|
||||||
|
* Guard for preventing unauthorized access to certain {@link Item} pages requiring administrator rights
|
||||||
|
*/
|
||||||
|
export class ItemPageAccessControlGuard extends DsoPageSingleFeatureGuard<Item> {
|
||||||
|
constructor(protected resolver: ItemPageResolver,
|
||||||
|
protected authorizationService: AuthorizationDataService,
|
||||||
|
protected router: Router,
|
||||||
|
protected authService: AuthService) {
|
||||||
|
super(resolver, authorizationService, router, authService);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check administrator authorization rights
|
||||||
|
*/
|
||||||
|
getFeatureID(next: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<FeatureID> {
|
||||||
|
return observableOf(FeatureID.AdministratorOf);
|
||||||
|
}
|
||||||
|
}
|
31
src/app/item-page/edit-item-page/item-page-curate.guard.ts
Normal file
31
src/app/item-page/edit-item-page/item-page-curate.guard.ts
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { ActivatedRouteSnapshot, Router, RouterStateSnapshot } from '@angular/router';
|
||||||
|
import { AuthorizationDataService } from '../../core/data/feature-authorization/authorization-data.service';
|
||||||
|
import { ItemPageResolver } from '../item-page.resolver';
|
||||||
|
import { Item } from '../../core/shared/item.model';
|
||||||
|
import { DsoPageSingleFeatureGuard } from '../../core/data/feature-authorization/feature-authorization-guard/dso-page-single-feature.guard';
|
||||||
|
import { Observable, of as observableOf } from 'rxjs';
|
||||||
|
import { FeatureID } from '../../core/data/feature-authorization/feature-id';
|
||||||
|
import { AuthService } from '../../core/auth/auth.service';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
/**
|
||||||
|
* Guard for preventing unauthorized access to certain {@link Item} pages requiring administrator rights
|
||||||
|
*/
|
||||||
|
export class ItemPageCurateGuard extends DsoPageSingleFeatureGuard<Item> {
|
||||||
|
constructor(protected resolver: ItemPageResolver,
|
||||||
|
protected authorizationService: AuthorizationDataService,
|
||||||
|
protected router: Router,
|
||||||
|
protected authService: AuthService) {
|
||||||
|
super(resolver, authorizationService, router, authService);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check administrator authorization rights
|
||||||
|
*/
|
||||||
|
getFeatureID(next: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<FeatureID> {
|
||||||
|
return observableOf(FeatureID.AdministratorOf);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user