Skip to content

Commit

Permalink
Merge pull request #62 from italia/show-metadata-url-in-admin-ui
Browse files Browse the repository at this point in the history
Show metadata url in admin UI
  • Loading branch information
nicolabeghin committed Mar 8, 2024
2 parents 407fbc4 + 8d9cb31 commit 0a22faf
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
@@ -0,0 +1,3 @@
target
.github
.vscode
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -8,7 +8,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.lscorcia</groupId>
<artifactId>keycloak-spid-provider</artifactId>
<version>24.0.1-BIS-SNAPSHOT</version>
<version>24.0.1.3-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Keycloak SPID Service Provider</name>
Expand Down
Expand Up @@ -19,6 +19,7 @@
import java.util.List;

import org.keycloak.broker.saml.SAMLIdentityProviderConfig;
import org.keycloak.broker.spid.metadata.SpidSpMetadataResourceProviderFactory;
import org.keycloak.models.IdentityProviderModel;
import org.keycloak.provider.ProviderConfigProperty;
import org.keycloak.provider.ProviderConfigurationBuilder;
Expand Down Expand Up @@ -47,6 +48,7 @@ public class SpidIdentityProviderConfig extends SAMLIdentityProviderConfig {
public static final String BILLING_CONTACT_SITE_PROVINCE = "billingContactSiteProvince";
public static final String BILLING_CONTACT_SITE_COUNTRY = "billingContactSiteCountry";
public static final String SPID_RESPONSE_DEBUG_ENABLED = "debugEnabled";
public static final String METADATA_URL = "metadataUrl";

public SpidIdentityProviderConfig(){
}
Expand Down Expand Up @@ -233,6 +235,15 @@ public void setDebugEnabled(boolean isDebugEnabled) {

public static List<ProviderConfigProperty> getConfigProperties() {
return ProviderConfigurationBuilder.create()

.property()
.name(METADATA_URL)
.type(ProviderConfigProperty.STRING_TYPE)
.defaultValue("/realms/<realm>/" + SpidSpMetadataResourceProviderFactory.ID)
.label("identity-provider.saml.url.metadata")
.helpText("identity-provider.saml.url.metadata.tooltip")
.add()

.property()
.name(ORGANIZATION_NAMES)
.type(ProviderConfigProperty.STRING_TYPE)
Expand Down Expand Up @@ -386,7 +397,7 @@ public static List<ProviderConfigProperty> getConfigProperties() {
.label("identity-provider.spid.debug-enabled")
.helpText("identity-provider.spid.debug-enabled.tooltip")
.add()

.build();
}

Expand Down
Expand Up @@ -26,6 +26,7 @@

import org.keycloak.Config.Scope;
import org.keycloak.broker.provider.AbstractIdentityProviderFactory;
import org.keycloak.broker.spid.metadata.SpidSpMetadataResourceProvider;
import org.keycloak.dom.saml.v2.assertion.AttributeType;
import org.keycloak.dom.saml.v2.metadata.EndpointType;
import org.keycloak.dom.saml.v2.metadata.EntitiesDescriptorType;
Expand Down Expand Up @@ -63,6 +64,7 @@ public String getName() {

@Override
public SpidIdentityProvider create(KeycloakSession session, IdentityProviderModel model) {
model.getConfig().put(SpidIdentityProviderConfig.METADATA_URL, SpidSpMetadataResourceProvider.getMetadataURL(session).toString());
return new SpidIdentityProvider(session, new SpidIdentityProviderConfig(model), destinationValidator);
}

Expand Down
Expand Up @@ -358,4 +358,11 @@ private static String md5hex(String data)
public void close() {
}

public static URI getMetadataURL(KeycloakSession session) {
UriInfo uriInfo = session.getContext().getUri();
return uriInfo.getBaseUriBuilder()
.path("realms").path(session.getContext().getRealm().getName())
.path(SpidSpMetadataResourceProviderFactory.ID)
.build();
}
}
Expand Up @@ -180,4 +180,7 @@ identity-provider.spid.site.countryCode.billing=Headquarter Country Code (Billin
identity-provider.spid.site.countryCode.billing.tooltip=Headquarter Country Code ISO alpha-2 (Billing). Default value is 'it'
# Debug
identity-provider.spid.debug-enabled=Show detailed SPID response errors
identity-provider.spid.debug-enabled.tooltip=If enabled, shows the actual SPID check error code instead of a generic error message
identity-provider.spid.debug-enabled.tooltip=If enabled, shows the actual SPID check error code instead of a generic error message

identity-provider.saml.url.metadata=Metadata URL
identity-provider.saml.url.metadata.tooltip=URL of the generated SAML metadata
Expand Up @@ -180,4 +180,7 @@ identity-provider.spid.site.countryCode.billing=Headquarter Country Code (Billin
identity-provider.spid.site.countryCode.billing.tooltip=Headquarter Country Code ISO alpha-2 (Billing). Default value is 'it'
# Debug
identity-provider.spid.debug-enabled=Show detailed SPID response errors
identity-provider.spid.debug-enabled.tooltip=If enabled, shows the actual SPID check error code instead of a generic error message
identity-provider.spid.debug-enabled.tooltip=If enabled, shows the actual SPID check error code instead of a generic error message

identity-provider.saml.url.metadata=Metadata URL
identity-provider.saml.url.metadata.tooltip=URL of the generated SAML metadata

0 comments on commit 0a22faf

Please sign in to comment.