Search in sources :

Example 1 with OidcSubjectPrincipal

use of org.dcache.auth.OidcSubjectPrincipal in project dcache by dCache.

the class BaseProfile method addSub.

private void addSub(IdentityProvider idp, Map<String, JsonNode> claims, Set<Principal> principals) {
    var node = claims.get("sub");
    if (node != null && node.isTextual()) {
        String claimValue = node.asText();
        principals.add(new OidcSubjectPrincipal(claimValue, idp.getName()));
        // REVISIT: the JwtSubPrincipal is only included for backwards compatibility.  It is
        // not used by dCache and should (very likely) be removed.
        principals.add(new JwtSubPrincipal(idp.getName(), claimValue));
    }
}
Also used : OidcSubjectPrincipal(org.dcache.auth.OidcSubjectPrincipal) JwtSubPrincipal(org.dcache.auth.JwtSubPrincipal)

Example 2 with OidcSubjectPrincipal

use of org.dcache.auth.OidcSubjectPrincipal in project dcache by dCache.

the class GplazmaMultiMapFileTest method shouldIgnoreMappingWithWrongOP.

@Test
public void shouldIgnoreMappingWithWrongOP() throws Exception {
    givenConfig("oidc:googleoidcsubject@GOOGLE    username:kermit");
    whenMapping(new OidcSubjectPrincipal("googleoidcsubject", "NOT-GOOGLE"));
    assertThat(warnings, is(empty()));
    assertThat(mappedPrincipals, is(empty()));
}
Also used : OidcSubjectPrincipal(org.dcache.auth.OidcSubjectPrincipal) Test(org.junit.Test)

Example 3 with OidcSubjectPrincipal

use of org.dcache.auth.OidcSubjectPrincipal in project dcache by dCache.

the class GplazmaMultiMapFileTest method shouldPassWhenOidcMappedWithoutOP.

@Test
public void shouldPassWhenOidcMappedWithoutOP() throws Exception {
    givenConfig("oidc:googleoidcsubject    username:kermit");
    whenMapping(new OidcSubjectPrincipal("googleoidcsubject", "GOOGLE"));
    assertThat(warnings, is(empty()));
    assertThat(mappedPrincipals, hasItem(new UserNamePrincipal("kermit")));
}
Also used : UserNamePrincipal(org.dcache.auth.UserNamePrincipal) OidcSubjectPrincipal(org.dcache.auth.OidcSubjectPrincipal) Test(org.junit.Test)

Example 4 with OidcSubjectPrincipal

use of org.dcache.auth.OidcSubjectPrincipal in project dcache by dCache.

the class GplazmaMultiMapFileTest method shouldFailWhenWrongMapFormatOidc.

@Test
public void shouldFailWhenWrongMapFormatOidc() throws Exception {
    givenConfig("oid:googleopenidsubject    username:kermit");
    whenMapping(new OidcSubjectPrincipal("googleopenidsubject", "GOOGLE"));
    assertThat(warnings, is(not(empty())));
    assertThat(mappedPrincipals, is(empty()));
}
Also used : OidcSubjectPrincipal(org.dcache.auth.OidcSubjectPrincipal) Test(org.junit.Test)

Example 5 with OidcSubjectPrincipal

use of org.dcache.auth.OidcSubjectPrincipal in project dcache by dCache.

the class GplazmaMultiMapFileTest method shouldPassWhenUidPrimaryGidFalseMappedFromOidcWithoutOP.

@Test
public void shouldPassWhenUidPrimaryGidFalseMappedFromOidcWithoutOP() throws Exception {
    givenConfig("oidc:googleoidcsubject   gid:1000,false  uid:1000  ");
    whenMapping(new OidcSubjectPrincipal("googleoidcsubject", "GOOGLE"));
    assertThat(warnings, is(empty()));
    assertThat(mappedPrincipals, hasItem(new UidPrincipal("1000")));
    assertThat(mappedPrincipals, hasItem(new GidPrincipal("1000", false)));
}
Also used : OidcSubjectPrincipal(org.dcache.auth.OidcSubjectPrincipal) UidPrincipal(org.dcache.auth.UidPrincipal) GidPrincipal(org.dcache.auth.GidPrincipal) Test(org.junit.Test)

Aggregations

OidcSubjectPrincipal (org.dcache.auth.OidcSubjectPrincipal)23 Test (org.junit.Test)21 UidPrincipal (org.dcache.auth.UidPrincipal)11 GidPrincipal (org.dcache.auth.GidPrincipal)9 UserNamePrincipal (org.dcache.auth.UserNamePrincipal)4 JwtSubPrincipal (org.dcache.auth.JwtSubPrincipal)3 JwtJtiPrincipal (org.dcache.auth.JwtJtiPrincipal)2 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 Splitter (com.google.common.base.Splitter)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 FsPath (diskCacheV111.util.FsPath)1 IOException (java.io.IOException)1 Principal (java.security.Principal)1 Instant (java.time.Instant)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 EnumSet (java.util.EnumSet)1 HashMap (java.util.HashMap)1 List (java.util.List)1