use of org.dcache.auth.attributes.MultiTargetedRestriction.Authorisation in project dcache by dCache.
the class WlcgProfileScope method authorisation.
@Override
public Optional<MultiTargetedRestriction.Authorisation> authorisation(FsPath prefix) {
FsPath absPath = prefix.resolve(path.substring(1));
LOGGER.debug("WlcgProfileScope authorising {} with prefix \"{}\" to path {}", prefix, operation.allowedActivities, absPath);
return Optional.of(new Authorisation(operation.allowedActivities, absPath));
}
use of org.dcache.auth.attributes.MultiTargetedRestriction.Authorisation in project dcache by dCache.
the class ScitokenScopeTest method shouldAuthoriseReadPaths.
@Test
public void shouldAuthoriseReadPaths() {
ScitokensScope scope = new ScitokensScope("read:/foo");
Optional<Authorisation> maybeAuthorisation = scope.authorisation(FsPath.create("/prefix/path"));
assertTrue(maybeAuthorisation.isPresent());
Authorisation authz = maybeAuthorisation.get();
assertThat(authz.getPath(), equalTo(FsPath.create("/prefix/path/foo")));
assertThat(authz.getActivity(), containsInAnyOrder(LIST, READ_METADATA, DOWNLOAD));
}
use of org.dcache.auth.attributes.MultiTargetedRestriction.Authorisation in project dcache by dCache.
the class ScitokenScopeTest method shouldAuthoriseWritePaths.
@Test
public void shouldAuthoriseWritePaths() {
ScitokensScope scope = new ScitokensScope("write:/foo");
Optional<Authorisation> maybeAuthorisation = scope.authorisation(FsPath.create("/prefix/path"));
assertTrue(maybeAuthorisation.isPresent());
Authorisation authz = maybeAuthorisation.get();
assertThat(authz.getPath(), equalTo(FsPath.create("/prefix/path/foo")));
assertThat(authz.getActivity(), containsInAnyOrder(LIST, READ_METADATA, UPLOAD, MANAGE, DELETE, UPDATE_METADATA));
}
use of org.dcache.auth.attributes.MultiTargetedRestriction.Authorisation in project dcache by dCache.
the class WlcgProfileScopeTest method shouldParseReadScope.
@Test
public void shouldParseReadScope() {
WlcgProfileScope scope = new WlcgProfileScope("storage.read:/");
Optional<Authorisation> maybeAuth = scope.authorisation(FsPath.create("/VOs/wlcg"));
assertTrue(maybeAuth.isPresent());
Authorisation auth = maybeAuth.get();
assertThat(auth.getPath(), equalTo(FsPath.create("/VOs/wlcg")));
assertThat(auth.getActivity(), containsInAnyOrder(LIST, READ_METADATA, DOWNLOAD));
}
use of org.dcache.auth.attributes.MultiTargetedRestriction.Authorisation in project dcache by dCache.
the class MultiTargetedRestrictionTest method shouldSubsumeIfPathDecendent.
@Test
public void shouldSubsumeIfPathDecendent() {
FsPath decendent = TARGET.child("subdir");
Restriction restriction1 = new MultiTargetedRestriction(singleton(new Authorisation(EnumSet.of(Activity.DOWNLOAD), TARGET)));
Restriction restriction2 = new MultiTargetedRestriction(singleton(new Authorisation(EnumSet.of(Activity.DOWNLOAD), decendent)));
assertThat(restriction1.isSubsumedBy(restriction2), is(true));
assertThat(restriction2.isSubsumedBy(restriction1), is(false));
}
Aggregations