feat: Support config metadata
This commit is contained in:
parent
c065dc86e4
commit
1dfecd0482
1 changed files with 18 additions and 0 deletions
|
@ -5,10 +5,15 @@ import de.sventorben.keycloak.authorization.client.access.AccessProviderFactory;
|
||||||
import org.keycloak.Config;
|
import org.keycloak.Config;
|
||||||
import org.keycloak.models.KeycloakSession;
|
import org.keycloak.models.KeycloakSession;
|
||||||
import org.keycloak.models.KeycloakSessionFactory;
|
import org.keycloak.models.KeycloakSessionFactory;
|
||||||
|
import org.keycloak.provider.ProviderConfigProperty;
|
||||||
|
import org.keycloak.provider.ProviderConfigurationBuilder;
|
||||||
import org.keycloak.provider.ServerInfoAwareProviderFactory;
|
import org.keycloak.provider.ServerInfoAwareProviderFactory;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static org.keycloak.provider.ProviderConfigProperty.STRING_TYPE;
|
||||||
|
|
||||||
public final class ClientRoleBasedAccessProviderFactory implements AccessProviderFactory, ServerInfoAwareProviderFactory {
|
public final class ClientRoleBasedAccessProviderFactory implements AccessProviderFactory, ServerInfoAwareProviderFactory {
|
||||||
|
|
||||||
public static final String PROVIDER_ID = "client-role";
|
public static final String PROVIDER_ID = "client-role";
|
||||||
|
@ -52,6 +57,19 @@ public final class ClientRoleBasedAccessProviderFactory implements AccessProvide
|
||||||
return Map.of("Version", version, CLIENT_ROLE_NAME, getClientRoleName());
|
return Map.of("Version", version, CLIENT_ROLE_NAME, getClientRoleName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ProviderConfigProperty> getConfigMetadata() {
|
||||||
|
return ProviderConfigurationBuilder.create()
|
||||||
|
.property()
|
||||||
|
.name(CLIENT_ROLE_NAME)
|
||||||
|
.label("Client role name")
|
||||||
|
.defaultValue(CLIENT_ROLE_NAME_DEFAULT)
|
||||||
|
.helpText("The name of the client role used to enable the authenticator and grant access.")
|
||||||
|
.type(STRING_TYPE)
|
||||||
|
.add()
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
private String getClientRoleName() {
|
private String getClientRoleName() {
|
||||||
return config.get(CLIENT_ROLE_NAME, CLIENT_ROLE_NAME_DEFAULT);
|
return config.get(CLIENT_ROLE_NAME, CLIENT_ROLE_NAME_DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue