Search in sources :

Example 1 with Authorisation

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));
}
Also used : Authorisation(org.dcache.auth.attributes.MultiTargetedRestriction.Authorisation) FsPath(diskCacheV111.util.FsPath)

Example 2 with Authorisation

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));
}
Also used : Authorisation(org.dcache.auth.attributes.MultiTargetedRestriction.Authorisation) Test(org.junit.Test)

Example 3 with Authorisation

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));
}
Also used : Authorisation(org.dcache.auth.attributes.MultiTargetedRestriction.Authorisation) Test(org.junit.Test)

Example 4 with Authorisation

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));
}
Also used : Authorisation(org.dcache.auth.attributes.MultiTargetedRestriction.Authorisation) WlcgProfileScope(org.dcache.gplazma.oidc.profiles.WlcgProfileScope) Test(org.junit.Test)

Example 5 with Authorisation

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));
}
Also used : Authorisation(org.dcache.auth.attributes.MultiTargetedRestriction.Authorisation) FsPath(diskCacheV111.util.FsPath) Test(org.junit.Test)

Aggregations

Authorisation (org.dcache.auth.attributes.MultiTargetedRestriction.Authorisation)16 Test (org.junit.Test)10 FsPath (diskCacheV111.util.FsPath)7 ArrayList (java.util.ArrayList)5 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)2 Splitter (com.google.common.base.Splitter)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 IOException (java.io.IOException)2 Principal (java.security.Principal)2 Instant (java.time.Instant)2 Collection (java.util.Collection)2 Collections (java.util.Collections)2 EnumSet (java.util.EnumSet)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 Objects.requireNonNull (java.util.Objects.requireNonNull)2 Optional (java.util.Optional)2 Properties (java.util.Properties)2 Set (java.util.Set)2