< Summary

Information
Class: Elsa.Identity.Endpoints.Secrets.Hash.Hash
Assembly: Elsa.Identity
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Identity/Endpoints/Secrets/Hash/Endpoint.cs
Line coverage
66%
Covered lines: 6
Uncovered lines: 3
Coverable lines: 9
Total lines: 35
Line coverage: 66.6%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
Configure()100%11100%
ExecuteAsync(...)100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Identity/Endpoints/Secrets/Hash/Endpoint.cs

#LineLine coverage
 1using Elsa.Identity.Contracts;
 2using FastEndpoints;
 3using JetBrains.Annotations;
 4
 5namespace Elsa.Identity.Endpoints.Secrets.Hash;
 6
 7/// <summary>
 8/// Hash a given password. Requires the <code>SecurityRoot</code> policy.
 9/// </summary>
 10[PublicAPI]
 11internal class Hash : Endpoint<Request, Response>
 12{
 13    private readonly ISecretHasher _secretHasher;
 14
 115    public Hash(ISecretHasher secretHasher)
 16    {
 117        _secretHasher = secretHasher;
 118    }
 19
 20    /// <inheritdoc />
 21    public override void Configure()
 22    {
 123        Post("/identity/secrets/hash");
 124        Policies(IdentityPolicyNames.SecurityRoot);
 125    }
 26
 27    /// <inheritdoc />
 28    public override Task<Response> ExecuteAsync(Request request, CancellationToken cancellationToken)
 29    {
 030        var hashedPassword = _secretHasher.HashSecret(request.Secret);
 031        var response = new Response(hashedPassword.EncodeSecret(), hashedPassword.EncodeSalt());
 32
 033        return Task.FromResult(response);
 34    }
 35}