/* ========================================================================
* Copyright (c) 2005-2026 The OPC Foundation, Inc. All rights reserved.
*
* OPC Foundation MIT License 1.00
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* The complete license agreement can be found here:
* http://opcfoundation.org/License/MIT/1.00/
* ======================================================================*/
using System.Collections.Generic;
namespace Opc.Ua.Identity
{
///
/// Optional probe interface that exposes authentication claims (groups,
/// roles, raw key/value pairs) carried by an authenticated
/// .
///
///
///
/// Designed to be implemented alongside
/// (NOT inherited) so that existing identity types remain on the
/// stable, non-claims contract. Consumers probe via
/// identity as IIdentityClaims.
///
///
/// Implementations populate this from the underlying token: a JWT
/// IssuedIdentityToken exposes the decoded JWT claim set; an
/// X509IdentityToken typically projects subject + SAN + EKU; a
/// UserNameIdentityToken projects preferred_username.
///
///
/// This interface intentionally has no setters. Claims are populated
/// once by the validating and
/// are immutable for the lifetime of the identity.
///
///
/// Used by IRoleManager.ResolveGrantedRoles to evaluate the
/// Part 18 §4.4.4 GroupId and Role identity criteria
/// against externally asserted group/role claims (e.g. from an
/// OIDC groups / roles claim, an Entra groups
/// claim, or a Kerberos PAC).
///
///
public interface IIdentityClaims
{
///
/// The raw claim set keyed by claim name. Claim names follow
/// OIDC / Entra conventions where possible — for example
/// sub, iss, aud, exp,
/// preferred_username, email, oid,
/// tid, upn, groups, roles,
/// scope.
///
///
/// Values are typically , ,
/// , or of those.
/// JSON arrays from a JWT body are projected as
/// of ;
/// nested JSON objects are not exposed in this interface and
/// should be flattened by the authenticator using dot notation
/// when needed.
///
IReadOnlyDictionary Claims { get; }
///
/// Group identifiers asserted by the identity provider, typically
/// the values of the OIDC / Entra groups claim. Used to
/// evaluate Part 18 §4.4.4 .
///
///
/// May be empty when the identity provider did not assert group
/// membership. Implementations that source groups from multiple
/// claims (e.g. Entra groups plus a custom
/// group_ids claim) merge them into this list.
///
IReadOnlyList Groups { get; }
///
/// Role identifiers asserted by the identity provider, typically
/// the values of the OIDC / Entra roles claim. Used to
/// evaluate Part 18 §4.4.4 .
///
///
/// Per Part 18 §4.4.4 a
/// criteria value may be prefixed with the issuer URI separated
/// by a forward slash (iss/roleName). The
/// IRoleManager consumer of this list is responsible for
/// resolving that prefix against
/// [iss].
///
IReadOnlyList Roles { get; }
///
/// Issuer URI as asserted by the identity provider, mirroring the
/// JWT iss claim. Provided as a convenience for Part 18
/// role-claim prefix resolution and audit logging. May be
/// when the underlying token type does
/// not carry an issuer (e.g. an X509 certificate identity).
///
string? Issuer { get; }
///
/// The subject identifier asserted by the identity provider,
/// mirroring the JWT sub claim. For X509 identities this
/// is the canonical subject DN; for UserName identities this is
/// the user name. Used as a stable identity key for audit
/// logging.
///
string? Subject { get; }
}
}