Table of Contents

Class FileSystemKeyStore

Namespace
Fdyay.IdentityServer.Stores
Assembly
Fdyay.IdentityServer.Core.dll

Keeps signing keys as files in a directory, one per key: is-signing-key-{id}.json. The default ISigningKeyStore, at KeyManagementOptions.KeyPath. Duende's FileSystemKeyStore, measured.

public class FileSystemKeyStore : ISigningKeyStore
Inheritance
FileSystemKeyStore
Implements
Inherited Members

Remarks

Each file is the SerializedKey as JSON; a file that does not read is logged and skipped, and the store goes on. Until 0.137.0 the default store was in memory, so a restart made a new key and every outstanding token stopped validating. The directory is created when first needed. Several instances may share it: key management converges on one key between them (0.136.0).

Constructors

FileSystemKeyStore(DirectoryInfo, ILogger<FileSystemKeyStore>)

A store over directory, which is created when first needed.

public FileSystemKeyStore(DirectoryInfo directory, ILogger<FileSystemKeyStore> logger)

Parameters

directory DirectoryInfo

The directory the key files are kept in.

logger ILogger<FileSystemKeyStore>

Where a key file that cannot be read or deleted is reported.

Exceptions

ArgumentNullException

directory or logger is null.

FileSystemKeyStore(string, ILogger<FileSystemKeyStore>)

A store over the directory at path, which is created when first needed.

public FileSystemKeyStore(string path, ILogger<FileSystemKeyStore> logger)

Parameters

path string

The directory's path.

logger ILogger<FileSystemKeyStore>

Where a key file that cannot be read or deleted is reported.

Exceptions

ArgumentNullException

path or logger is null.

Methods

DeleteKeyAsync(string, CancellationToken)

Deletes a key by id.

public Task DeleteKeyAsync(string id, CancellationToken cancellationToken = default)

Parameters

id string
cancellationToken CancellationToken

Returns

Task

Remarks

A file that cannot be deleted is logged, not thrown.

LoadKeysAsync(CancellationToken)

Loads all persisted keys.

public Task<IEnumerable<SerializedKey>> LoadKeysAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

Task<IEnumerable<SerializedKey>>

Remarks

Reads every is-signing-key-*.json file; one that cannot be read or parsed is logged and skipped.

StoreKeyAsync(SerializedKey, CancellationToken)

Persists a key.

public Task StoreKeyAsync(SerializedKey key, CancellationToken cancellationToken = default)

Parameters

key SerializedKey
cancellationToken CancellationToken

Returns

Task

Remarks

Writes is-signing-key-{id}.json, replacing a file of that name.