-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sr at21 integration test cofig3 (#233)
* unauth systemregister * reauth systemregister * add profileclient and it's dependencies * access token etc towards profile api * fix comment
- Loading branch information
1 parent
ae6ac9f
commit 8501d92
Showing
14 changed files
with
343 additions
and
230 deletions.
There are no files selected for viewing
109 changes: 0 additions & 109 deletions
109
...nn.Authentication.UI/Altinn.Authentication.UI.Core/Authentication/HttpClientExtensions.cs
This file was deleted.
Oops, something went wrong.
170 changes: 76 additions & 94 deletions
170
...Authentication.UI/Altinn.Authentication.UI.Core/Common/Extensions/HttpClientExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,109 +1,91 @@ | ||
namespace Altinn.Authentication.UI.Core.Common; | ||
namespace Altinn.Authentication.UI.Core.Extensions; | ||
|
||
public static class HttpClientExtensions | ||
/// <summary> | ||
/// This extension is created to make it easy to add a bearer token to a HttpRequests. | ||
/// </summary> | ||
public static class HttpClientExtension | ||
{ | ||
|
||
/// <summary> | ||
/// Extensionmethod to add Authorization token and access token to the header | ||
/// </summary> | ||
/// <param name="httpClient"></param> | ||
/// <param name="authorizationToken"></param> | ||
/// <param name="requestURI"></param> | ||
/// <param name="content"></param> | ||
/// <param name="platformAccessToken"></param> | ||
/// <returns></returns> | ||
public static Task<HttpResponseMessage> PostAsync( | ||
this HttpClient httpClient, | ||
string authorizationToken, string requestURI, | ||
HttpContent content, string? platformAccessToken = null) | ||
/// <summary> | ||
/// Extension that add authorization header to request. | ||
/// </summary> | ||
/// <param name="httpClient">The HttpClient.</param> | ||
/// <param name="authorizationToken">the authorization token (jwt).</param> | ||
/// <param name="requestUri">The request Uri.</param> | ||
/// <param name="content">The http content.</param> | ||
/// <param name="platformAccessToken">The platformAccess tokens.</param> | ||
/// <returns>A HttpResponseMessage.</returns> | ||
public static Task<HttpResponseMessage> PostAsync(this HttpClient httpClient, string authorizationToken, string requestUri, HttpContent content, string platformAccessToken = null) | ||
{ | ||
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, requestUri); | ||
request.Headers.Add("Authorization", "Bearer " + authorizationToken); | ||
request.Content = content; | ||
if (!string.IsNullOrEmpty(platformAccessToken)) | ||
{ | ||
HttpRequestMessage request = new(HttpMethod.Post, requestURI); | ||
request.Headers.Add("Authorization", "Bearer " + authorizationToken); | ||
request.Content = content; | ||
if(platformAccessToken is not null && platformAccessToken.Length > 0) | ||
{ | ||
request.Headers.Add("PlatformAccessToken", platformAccessToken); | ||
} | ||
|
||
return httpClient.SendAsync(request, CancellationToken.None); | ||
request.Headers.Add("PlatformAccessToken", platformAccessToken); | ||
} | ||
|
||
/// <summary> | ||
/// Extensionmethod to add Authorization token and access token to the header | ||
/// </summary> | ||
/// <param name="httpClient"></param> | ||
/// <param name="authorizationToken"></param> | ||
/// <param name="requestURI"></param> | ||
/// <param name="content"></param> | ||
/// <param name="platformAccessToken"></param> | ||
/// <returns></returns> | ||
public static Task<HttpResponseMessage> PutAsync( | ||
this HttpClient httpClient, | ||
string authorizationToken, string requestURI, | ||
HttpContent content, string? platformAccessToken = null) | ||
{ | ||
HttpRequestMessage request = new(HttpMethod.Put, requestURI); | ||
request.Headers.Add("Authorization", "Bearer " + authorizationToken); | ||
request.Content = content; | ||
|
||
if(platformAccessToken is not null && platformAccessToken.Length > 0) | ||
{ | ||
request.Headers.Add("PlatformAccessToken", platformAccessToken); | ||
} | ||
return httpClient.SendAsync(request, CancellationToken.None); | ||
} | ||
|
||
return httpClient.SendAsync(request, CancellationToken.None); | ||
/// <summary> | ||
/// Extension that add authorization header to request. | ||
/// </summary> | ||
/// <param name="httpClient">The HttpClient.</param> | ||
/// <param name="authorizationToken">the authorization token (jwt).</param> | ||
/// <param name="requestUri">The request Uri.</param> | ||
/// <param name="content">The http content.</param> | ||
/// <param name="platformAccessToken">The platformAccess tokens.</param> | ||
/// <returns>A HttpResponseMessage.</returns> | ||
public static Task<HttpResponseMessage> PutAsync(this HttpClient httpClient, string authorizationToken, string requestUri, HttpContent content, string platformAccessToken = null) | ||
{ | ||
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Put, requestUri); | ||
request.Headers.Add("Authorization", "Bearer " + authorizationToken); | ||
request.Content = content; | ||
if (!string.IsNullOrEmpty(platformAccessToken)) | ||
{ | ||
request.Headers.Add("PlatformAccessToken", platformAccessToken); | ||
} | ||
|
||
return httpClient.SendAsync(request, CancellationToken.None); | ||
} | ||
|
||
/// <summary> | ||
/// Extensionmethod to add Authorization token and access token to the header | ||
/// </summary> | ||
/// <param name="httpClient"></param> | ||
/// <param name="authorizationToken"></param> | ||
/// <param name="requestURI"></param> | ||
/// <param name="content"></param> | ||
/// <param name="platformAccessToken"></param> | ||
/// <returns></returns> | ||
public static Task<HttpResponseMessage> GetAsync( | ||
this HttpClient httpClient, | ||
string authorizationToken, string requestURI, | ||
HttpContent content, string? platformAccessToken = null) | ||
/// <summary> | ||
/// Extension that add authorization header to request. | ||
/// </summary> | ||
/// <param name="httpClient">The HttpClient.</param> | ||
/// <param name="authorizationToken">the authorization token (jwt).</param> | ||
/// <param name="requestUri">The request Uri.</param> | ||
/// <param name="platformAccessToken">The platformAccess tokens.</param> | ||
/// <returns>A HttpResponseMessage.</returns> | ||
public static Task<HttpResponseMessage> GetAsync(this HttpClient httpClient, string authorizationToken, string requestUri, string platformAccessToken = null) | ||
{ | ||
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, requestUri); | ||
request.Headers.Add("Authorization", "Bearer " + authorizationToken); | ||
if (!string.IsNullOrEmpty(platformAccessToken)) | ||
{ | ||
HttpRequestMessage request = new(HttpMethod.Get, requestURI); | ||
request.Headers.Add("Authorization", "Bearer " + authorizationToken); | ||
request.Content = content; | ||
|
||
if(platformAccessToken is not null && platformAccessToken.Length > 0) | ||
{ | ||
request.Headers.Add("PlatformAccessToken", platformAccessToken); | ||
} | ||
|
||
return httpClient.SendAsync(request, CancellationToken.None); | ||
request.Headers.Add("PlatformAccessToken", platformAccessToken); | ||
} | ||
|
||
/// <summary> | ||
/// Extensionmethod to add Authorization token and access token to the header | ||
/// </summary> | ||
/// <param name="httpClient"></param> | ||
/// <param name="authorizationToken"></param> | ||
/// <param name="requestURI"></param> | ||
/// <param name="content"></param> | ||
/// <param name="platformAccessToken"></param> | ||
/// <returns></returns> | ||
public static Task<HttpResponseMessage> DeleteAsync( | ||
this HttpClient httpClient, | ||
string authorizationToken, string requestURI, | ||
HttpContent content, string? platformAccessToken = null) | ||
{ | ||
HttpRequestMessage request = new(HttpMethod.Delete, requestURI); | ||
request.Headers.Add("Authorization", "Bearer " + authorizationToken); | ||
request.Content = content; | ||
|
||
if(platformAccessToken is not null && platformAccessToken.Length > 0) | ||
{ | ||
request.Headers.Add("PlatformAccessToken", platformAccessToken); | ||
} | ||
return httpClient.SendAsync(request, HttpCompletionOption.ResponseContentRead, CancellationToken.None); | ||
} | ||
|
||
return httpClient.SendAsync(request, CancellationToken.None); | ||
/// <summary> | ||
/// Extension that add authorization header to request. | ||
/// </summary> | ||
/// <param name="httpClient">The HttpClient.</param> | ||
/// <param name="authorizationToken">the authorization token (jwt).</param> | ||
/// <param name="requestUri">The request Uri.</param> | ||
/// <param name="platformAccessToken">The platformAccess tokens.</param> | ||
/// <returns>A HttpResponseMessage.</returns> | ||
public static Task<HttpResponseMessage> DeleteAsync(this HttpClient httpClient, string authorizationToken, string requestUri, string platformAccessToken = null) | ||
{ | ||
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Delete, requestUri); | ||
request.Headers.Add("Authorization", "Bearer " + authorizationToken); | ||
if (!string.IsNullOrEmpty(platformAccessToken)) | ||
{ | ||
request.Headers.Add("PlatformAccessToken", platformAccessToken); | ||
} | ||
|
||
return httpClient.SendAsync(request, CancellationToken.None); | ||
} | ||
} |
5 changes: 0 additions & 5 deletions
5
...tinn.Authentication.UI/Altinn.Authentication.UI.Core/UserProfiles/IAccessTokenProvider.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.