8000 [OID4VP] Add Multi-Credential Support by dominikschlosser · Pull Request #55424 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/js-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ jobs:
- name: Start Keycloak server
run: |
tar xfvz keycloak-999.0.0-SNAPSHOT.tar.gz
keycloak-999.0.0-SNAPSHOT/bin/kc.sh start-dev --features=admin-fine-grained-authz:v2,transient-users,spiffe,oid4vc-vci,oid4vc-mdoc,kubernetes-service-accounts,jwt-authorization-grant,workflows,ssf,resource-indicators &> ~/server.log &
keycloak-999.0.0-SNAPSHOT/bin/kc.sh start-dev --features=admin-fine-grained-authz:v2,transient-users,spiffe,oid4vc-vci,oid4vc-mdoc,oid4vc-vp,kubernetes-service-accounts,jwt-authorization-grant,workflows,ssf,resource-indicators &> ~/server.log &
env:
KC_BOOTSTRAP_ADMIN_USERNAME: admin
KC_BOOTSTRAP_ADMIN_PASSWORD: admin
Expand Down
28 changes: 20 additions & 8 deletions docs/documentation/release_notes/topics/27_0_0.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,23 @@ Realms that explicitly used `keycloak.v2` are migrated to `keycloak.v3` during u

Custom login themes can override `header.ftl`, `aside.ftl`, `footer.ftl`, `alert.ftl`, and `language-selector.ftl` to customize brand content, a side panel for marketing or help text, the login-card footer, alerts, and the locale selector without replacing the full page layout.

== OID4VP verifier infers the DCQL query from mappers (experimental)

The OID4VP identity provider no longer requires a hand-written DCQL query.
Configure the accepted credential types (`vct`) in the new *Default Credential Types* setting, and the query sent to the wallet is built from the claims that the identity provider mappers read, plus the principal attribute.

A DCQL query can still be configured for requests that mappers cannot express, such as claim sets.
It takes precedence over the inferred query and is now validated when the identity provider is saved.
Only a single credential in the `dc+sd-jwt` format can be requested.
== OID4VP verifier requests multiple credentials (experimental)

The OID4VP identity provider now requests credentials through the new *Requested credentials* section of the Admin Console, which lists the credentials, their accepted types, their trust material identity providers and the claim that identifies the user.
The Admin REST API stores this as a JSON document in the `requestedCredentials` configuration property.
It replaces the *DCQL Query*, *Principal Attribute*, *Trusted Issuer JWKS* and *Trust Material Identity Providers* settings, so existing OID4VP identity providers need to be configured again.
Each of their mappers now selects one of the requested credentials in its *Credential* setting.
Trusted issuer keys that were configured inline now go into a trust material identity provider.
An OID4VP identity provider is no longer a trust material identity provider itself, so replace references to it in other trust material settings with that trust material identity provider.

The DCQL query sent to the wallet is always built from the requested credentials and the claims that the identity provider mappers read.
If a mapper refers to a credential that is no longer requested, Keycloak logs a warning and treats the claim of the mapper as missing.
A user attribute mapper then removes its custom attribute at login, unless its sync mode is *Import*.

Credential sets express optional credentials and alternatives.
The credential holding the claim that identifies the user must be part of every option of at least one required credential set.
The user is linked by the presented type (`vct`) of that credential together with the claim, so a credential of another type with the same claim value does not sign in as that user.
Each accepted type of that credential therefore links its own identity.
The claim must be unique across all trusted issuers of a type, since any of them can issue a credential with that value.
Links to an OID4VP identity provider created by an earlier version no longer match and block the first broker login of their users, so remove them.
Only credentials in the `dc+sd-jwt` format can be requested.
Original file line number Diff line number Diff line change
Expand Up @@ -4307,3 +4307,37 @@ removeRole=Remove role {{name}}
removeOrganization=Remove organization {{name}}
maximum age
age of a SAML assertion with a OneTimeUse condition, counted from the time the identity provider issued it. Older assertions are rejected. Default is 1 hour (3600 seconds).
oid4vpRequestedCredentials=Requested credentials
oid4vpRequestedCredentialsHelp=Credentials the wallet is asked to present. The mappers of this identity provider define which claims of each credential are requested.
oid4vpNewCredential=New credential
oid4vpAddCredential=Add credential
oid4vpRemoveCredential=Remove credential
oid4vpCredentialId=Credential ID
oid4vpCredentialIdHelp=Unique ID of the credential in the request. Mappers refer to the credential by this ID.
oid4vpCredentialIdInvalid=Use only letters, digits, '_' and '-'.
oid4vpCredentialFormat=Format
oid4vpCredentialFormatHelp=Format in which the wallet presents the credential.
oid4vpSdJwtVcFormat=SD-JWT VC (dc+sd-jwt)
oid4vpCredentialTypes=Credential types
oid4vpCredentialTypesHelp=Accepted values of the vct claim. The wallet presents a credential of one of these types.
oid4vpAddCredentialType=Add credential type
oid4vpTrustMaterialIdps=Trust material identity providers
oid4vpTrustMaterialIdpsHelp=Identity providers whose trust material verifies the issuer of this credential.
oid4vpCredentialSets=Credential sets
oid4vpCredentialSetsHelp=Combinations of credentials the wallet may present. Without credential sets, the wallet must present every credential.
oid4vpAddCredentialSet=Add credential set
oid4vpCredentialSet=Credential set {{index}}
oid4vpRemoveCredentialSet=Remove credential set
oid4vpCredentialSetRequired=Required
oid4vpCredentialSetRequiredHelp=The wallet must present one option of every required set. It may present an option of an optional set if it holds those credentials.
oid4vpCredentialSetOption=Option {{index}}
oid4vpCredentialSetOptionHelp=Credentials the wallet presents together to satisfy this set.
oid4vpAddCredentialSetOption=Add option
oid4vpRemoveCredentialSetOption=Remove option
oid4vpNoRequiredCredentialSet=At least one credential set must be required.
oid4vpPrincipal=Principal
oid4vpPrincipalHelp=The claim that identifies the user. Its credential must be part of every option of at least one required credential set. The user is linked by the presented type of that credential together with the claim, so each type links its own identity.
oid4vpPrincipalCredential=Principal credential
oid4vpPrincipalCredentialHelp=Credential that holds the principal claim.
oid4vpPrincipalClaim=Principal claim
oid4vpPrincipalClaimHelp=Path of the claim in the principal credential, for example personal_administrative_number or address.locality.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { useFetch } from "@keycloak/keycloak-ui-shared";
import { useState } from "react";
import { useWatch } from "react-hook-form";
import { useAdminClient } from "../../admin-client";
import { toRequestedCredentialsForm } from "../../identity-providers/add/requestedCredentials";
import type { IdentityProviderEditMapperParams } from "../../identity-providers/routes/EditMapper";
import { useParams } from "../../utils/useParams";
import type { ComponentProps } from "./components";
import { ListComponent } from "./ListComponent";

export const OID4VPCredentialListComponent = (props: ComponentProps) => {
const { adminClient } = useAdminClient();
const { alias } = useParams<IdentityProviderEditMapperParams>();
const [credentialIds, setCredentialIds] = useState<string[]>();
const selected: string | undefined = useWatch({
name: props.convertToName(props.name!),
});

useFetch(
() => adminClient.identityProviders.findOne({ alias }),
(idp) =>
setCredentialIds(
toRequestedCredentialsForm(idp?.config?.requestedCredentials)
.credentials.map(({ id }) => id)
.filter((id) => id),
),
[alias],
);

if (!credentialIds) return null;

// A credential that is no longer requested stays visible, so the stale setting can be seen and changed
const options =
selected && !credentialIds.includes(selected)
? [selected, ...credentialIds]
: credentialIds;

return <ListComponent {...props} options={options} />;
};
5 changes: 4 additions & 1 deletion js/apps/admin-ui/src/components/dynamic/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { UrlComponent } from "./UrlComponent";
import { UserProfileAttributeListComponent } from "./UserProfileAttributeListComponent";
import { IntComponent } from "./IntComponent";
import { NumberComponent } from "./NumberComponent";
import { OID4VPCredentialListComponent } from "./OID4VPCredentialListComponent";

export type ComponentProps = Omit<ConfigPropertyRepresentation, "type"> & {
isDisabled?: boolean;
Expand Down Expand Up @@ -53,7 +54,8 @@ type ComponentType =
| "File"
| "Password"
| "Url"
| "ClaimDisplay";
| "ClaimDisplay"
| "OID4VPCredentialList";

export const COMPONENTS: {
[index in ComponentType]: FunctionComponent<ComponentProps>;
Expand All @@ -77,6 +79,7 @@ export const COMPONENTS: {
Password: PasswordComponent,
Url: UrlComponent,
ClaimDisplay: ClaimDisplayComponent,
OID4VPCredentialList: OID4VPCredentialListComponent,
} as const;

export const isValidComponentType = (value: string): value is ComponentType =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export const MultiLineInput = ({
? t("required")
: undefined,
});
}, [register]);
}, [register, name]);

const getError = () => {
return name.split(".").reduce((record: any, key) => record?.[key], errors);
Expand Down
15 changes: 14 additions & 1 deletion js/apps/admin-ui/src/identity-providers/add/AddOid4Vp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ import { useRealm } from "../../context/realm-context/RealmContext";
import { toIdentityProvider } from "../routes/IdentityProvider";
import { toIdentityProviders } from "../routes/IdentityProviders";
import Oid4VpSettings from "./Oid4VpSettings";
import {
toRequestedCredentialsForm,
toRequestedCredentialsJson,
} from "./requestedCredentials";

export default function AddOid4Vp() {
const { adminClient } = useAdminClient();
Expand All @@ -24,7 +28,10 @@ export default function AddOid4Vp() {
const id = "oid4vp";

const form = useForm<IdentityProviderRepresentation>({
defaultValues: { alias: id },
defaultValues: {
alias: id,
config: { requestedCredentials: toRequestedCredentialsForm() },
},
mode: "onChange",
});
const {
Expand All @@ -39,6 +46,12 @@ export default function AddOid4Vp() {
try {
await adminClient.identityProviders.create({
...provider,
config: {
...provider.config,
requestedCredentials: toRequestedCredentialsJson(
provider.config!.requestedCredentials,
),
},
providerId: id,
});
addAlert(t("createIdentityProviderSuccess"), AlertVariant.success);
Expand Down
Loading
Loading
0