Skip to content

Commit a0683c8

Browse files
committed
Ref #29277: re-add saml to spel
1 parent 77deff0 commit a0683c8

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

src/main/java/eu/openanalytics/containerproxy/auth/impl/saml/ResponseAuthenticationConverter.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public AbstractAuthenticationToken convert(@Nonnull OpenSamlAuthenticationProvid
103103
}
104104

105105
return new Saml2Authentication(
106-
new DefaultSaml2AuthenticatedPrincipal(nameValue.get(), principal.getAttributes()),
106+
new Saml2AuthenticatedPrincipal(nameId, nameValue.get(), principal.getAttributes()),
107107
authentication.getSaml2Response(),
108108
grantedAuthorities);
109109
}
@@ -143,4 +143,19 @@ private Optional<List<Object>> getAttributeIgnoringCase(DefaultSaml2Authenticate
143143
.map(Map.Entry::getValue);
144144
}
145145

146+
public static class Saml2AuthenticatedPrincipal extends DefaultSaml2AuthenticatedPrincipal {
147+
148+
private final String nameId;
149+
150+
public Saml2AuthenticatedPrincipal(String nameId, String principalName, Map<String, List<Object>> attributes) {
151+
super(principalName, attributes);
152+
this.nameId = nameId;
153+
}
154+
155+
public String getNameId() {
156+
return nameId;
157+
}
158+
159+
}
160+
146161
}

src/main/java/eu/openanalytics/containerproxy/spec/expression/SpecExpressionContext.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
package eu.openanalytics.containerproxy.spec.expression;
2222

2323
import eu.openanalytics.containerproxy.auth.impl.OpenIDAuthenticationBackend;
24+
import eu.openanalytics.containerproxy.auth.impl.saml.ResponseAuthenticationConverter;
2425
import eu.openanalytics.containerproxy.model.runtime.Proxy;
2526
import eu.openanalytics.containerproxy.model.spec.ContainerSpec;
2627
import eu.openanalytics.containerproxy.model.spec.ProxySpec;
@@ -49,7 +50,7 @@ public class SpecExpressionContext {
4950
Proxy proxy;
5051
OpenIDAuthenticationBackend.CustomNameOidcUser oidcUser;
5152
KeycloakPrincipal keycloakUser;
52-
// private SAMLCredential samlCredential;
53+
ResponseAuthenticationConverter.Saml2AuthenticatedPrincipal samlCredential;
5354
LdapUserDetails ldapUser;
5455
List<String> groups;
5556
String userId;
@@ -128,8 +129,8 @@ public static SpecExpressionContext create(SpecExpressionContextBuilder builder,
128129
builder.oidcUser = (OpenIDAuthenticationBackend.CustomNameOidcUser) o;
129130
} else if (o instanceof KeycloakPrincipal) {
130131
builder.keycloakUser = (KeycloakPrincipal) o;
131-
// } else if (o instanceof SAMLCredential) {
132-
// ctx.samlCredential = (SAMLCredential) o;
132+
} else if (o instanceof ResponseAuthenticationConverter.Saml2AuthenticatedPrincipal) {
133+
builder.samlCredential = (ResponseAuthenticationConverter.Saml2AuthenticatedPrincipal) o;
133134
} else if (o instanceof LdapUserDetails) {
134135
builder.ldapUser = (LdapUserDetails) o;
135136
}

0 commit comments

Comments
 (0)