• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

dgg / nmoneys-web / 21330671890

25 Jan 2026 09:51AM UTC coverage: 73.95% (-25.4%) from 99.367%
21330671890

push

github

web-flow
authn (#31)

128 of 220 new or added lines in 22 files covered. (58.18%)

264 of 357 relevant lines covered (73.95%)

0.74 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Api/Infrastructure/Auth/ManagementHttpHandler.cs
1
using System.Net.Http.Headers;
2

3
using Microsoft.Extensions.Caching.Memory;
4
using Microsoft.Extensions.Options;
5

6
using NMoneys.Api.Infrastructure.Auth.Models;
7

8
namespace NMoneys.Api.Infrastructure.Auth;
9

NEW
10
internal class ManagementHttpHandler(IOAuthClient client, IMemoryCache cache, IOptions<AuthenticationSettings> configuration) : DelegatingHandler
×
11
{
NEW
12
        public static readonly string CacheKey = "ApplicationsManagerToken";
×
13
        
14
        protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
15
        {
NEW
16
                string accessToken = await getAccessToken(cancellationToken);
×
NEW
17
                request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
×
NEW
18
                return await base.SendAsync(request, cancellationToken);
×
NEW
19
        }
×
20

21
        private async Task<string> getAccessToken(CancellationToken ct)
22
        {
NEW
23
                string? accessToken = await cache.GetOrCreateAsync(CacheKey, async entry =>
×
NEW
24
                {
×
NEW
25
                        OAuthToken token = await client.GetAccessToken(configuration.Value.ApplicationsManager.ClientId,
×
NEW
26
                                configuration.Value.ApplicationsManager.ClientSecret, 
×
NEW
27
                                configuration.Value.Audience,
×
NEW
28
                                ct);
×
NEW
29
                        entry.AbsoluteExpirationRelativeToNow = token.Expiration;
×
NEW
30
                        return token.AccessToken;
×
NEW
31
                });
×
NEW
32
                return accessToken!;
×
NEW
33
        }
×
34
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc