Skip to content

Commit

Permalink
Filling ou tthe AT PoP skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
FehintolaObafemi committed May 21, 2024
1 parent 61502b8 commit 3ceea14
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 99 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,32 @@ private static async Task<InteractiveBrowserCredential> GetInteractiveBrowserCre
if (IsATPoPSupported())
{
// Logic to implement ATPoP Authentication
var client = new PopClient(interactiveBrowserCredential, authContext, new PopClientOptions()
{
Diagnostics =
{
IsLoggingContentEnabled = true,
LoggedHeaderNames = { "Authorization" }
}
authRecord = await Task.Run(() =>
{
var popTokenAuthenticationPolicy = new PopTokenAuthenticationPolicy(interactiveBrowserCredential as ISupportsProofOfPossession, $"https://graph.microsoft.com/.default");

var pipelineOptions = new HttpPipelineOptions(new PopClientOptions()
{
Diagnostics =
{
IsLoggingContentEnabled = true,
LoggedHeaderNames = { "Authorization" }
},
});
pipelineOptions.PerRetryPolicies.Add(popTokenAuthenticationPolicy);

var _pipeline = HttpPipelineBuilder.Build(pipelineOptions, new HttpPipelineTransportOptions { ServerCertificateCustomValidationCallback = (_) => true });
using var request = _pipeline.CreateRequest();
request.Method = RequestMethod.Get;
request.Uri.Reset(new Uri("https://20.190.132.47/beta/me"));
var response = _pipeline.SendRequest(request, cancellationToken);
var message = new HttpMessage(request, new ResponseClassifier());

// Manually invoke the authentication policy's process method
popTokenAuthenticationPolicy.ProcessAsync(message, ReadOnlyMemory<HttpPipelinePolicy>.Empty);
// Run the thread in MTA.
return interactiveBrowserCredential.Authenticate(new TokenRequestContext(authContext.Scopes), cancellationToken);
});
//var response = client.Get(new Uri("https://20.190.132.47/beta/me"), CancellationToken.None);
authRecord = client.GetAuthRecord();
}
else
{
Expand Down Expand Up @@ -472,4 +488,7 @@ public static Task DeleteAuthRecordAsync()
return Task.CompletedTask;
}
}
internal class PopClientOptions : ClientOptions
{
}
}
88 changes: 0 additions & 88 deletions src/Authentication/Authentication.Core/Utilities/PopClient.cs

This file was deleted.

This file was deleted.

0 comments on commit 3ceea14

Please sign in to comment.