refactor for other project

This commit is contained in:
Frede Hundewadt 2023-10-03 09:09:26 +02:00
parent fdbf97b4d1
commit d0f097c35d
13 changed files with 566 additions and 163 deletions

View file

@ -1,13 +1,13 @@
// *********************************************************************** // ***********************************************************************
// Assembly : FCS.Lib.Azure // Assembly : FCS.Lib.Azure
// Author : FH // Author :
// Created : 05-10-2022 // Created : 2023 10 02 13:17
// //
// Last Modified By : FH // Last Modified By : root
// Last Modified On : 05-10-2022 // Last Modified On : 2023 10 02 15:24
// *********************************************************************** // ***********************************************************************
// <copyright file="RpcAzureAuthStore.cs" company="FCS"> // <copyright file="AzureAuthStore.cs" company="FCS">
// Copyright (C) 2022 FCS Frede's Computer Services. // Copyright (C) 2023-2023 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the // published by the Free Software Foundation, either version 3 of the
@ -24,13 +24,23 @@
// <summary></summary> // <summary></summary>
// *********************************************************************** // ***********************************************************************
namespace FCS.Lib.Azure namespace FCS.Lib.Azure;
public class AzureAuthStore
{ {
public class AzureAuthStore /// <summary>
{ /// Azure Auth Store Constructor
/// </summary>
/// <param name="azureLoginUrl"></param>
/// <param name="azureOAuthEndpoint"></param>
/// <param name="azureTenantId"></param>
/// <param name="azureClientId"></param>
/// <param name="azureGrantType"></param>
/// <param name="azureClientSecret"></param>
/// <param name="azureLoginScope"></param>
public AzureAuthStore( public AzureAuthStore(
string azureLoginUrl, string azureOAuthEndpoint, string azureTenantId, string azureLoginUrl, string azureOAuthEndpoint, string azureTenantId,
string azureClientId, string azureGrantType, string azureSecret, string azureClientId, string azureGrantType, string azureClientSecret,
string azureLoginScope) string azureLoginScope)
{ {
AzureLoginUrl = azureLoginUrl; AzureLoginUrl = azureLoginUrl;
@ -38,21 +48,47 @@ namespace FCS.Lib.Azure
AzureTenantId = azureTenantId; AzureTenantId = azureTenantId;
AzureClientId = azureClientId; AzureClientId = azureClientId;
AzureGrantType = azureGrantType; AzureGrantType = azureGrantType;
AzureSecret = azureSecret; AzureClientSecret = azureClientSecret;
AzureLoginScope = azureLoginScope; AzureLoginScope = azureLoginScope;
} }
protected string AzureLoginUrl { get; set; } /// <summary>
protected string AzureOAuthEndpoint { get; set; } /// Azure Client Id
protected string AzureTenantId { get; } /// </summary>
public string AzureClientId { get; } public string AzureClientId { get; }
/// <summary>
/// Azure Client Secret
/// </summary>
public string AzureClientSecret { get; }
/// <summary>
/// Azure Grant Type
/// </summary>
public string AzureGrantType { get; } public string AzureGrantType { get; }
public string AzureSecret { get; }
/// <summary>
/// Azure Login Scope
/// </summary>
public string AzureLoginScope { get; } public string AzureLoginScope { get; }
/// <summary>
/// Azure Login Url
/// </summary>
protected string AzureLoginUrl { get; set; }
/// <summary>
/// Azure OAuth Endpoint
/// </summary>
protected string AzureOAuthEndpoint { get; set; }
/// <summary>
/// Azure Tenant Id
/// </summary>
protected string AzureTenantId { get; }
public string AzureTokenEndpoint() public string AzureTokenEndpoint()
{ {
return $"{AzureLoginUrl}/{AzureTenantId}/{AzureOAuthEndpoint}"; return $"{AzureLoginUrl}/{AzureTenantId}/{AzureOAuthEndpoint}";
} }
}
} }

View file

@ -1,36 +1,114 @@
namespace FCS.Lib.Azure; // ***********************************************************************
// Assembly : FCS.Lib.Azure
// Author :
// Created : 2023 10 02 13:17
//
// Last Modified By : root
// Last Modified On : 2023 10 02 15:24
// ***********************************************************************
// <copyright file="AzureConfigStore.cs" company="FCS">
// Copyright (C) 2023-2023 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see [https://www.gnu.org/licenses]
// </copyright>
// <summary></summary>
// ***********************************************************************
namespace FCS.Lib.Azure;
public class AzureConfigStore public class AzureConfigStore
{ {
public AzureConfigStore(string baseUrl, string tenantId, string environment, /// <summary>
string api, string apiGroup, string apiVersion, /// Azure Config Store Constructor
/// </summary>
/// <param name="baseUrl"></param>
/// <param name="tenantId"></param>
/// <param name="environment"></param>
/// <param name="apiPublisher"></param>
/// <param name="apiGroup"></param>
/// <param name="apiVersion"></param>
/// <param name="ledgerId"></param>
/// <param name="oDataVersion"></param>
public AzureConfigStore(
string baseUrl, string tenantId, string environment,
string apiPublisher, string apiGroup, string apiVersion,
string ledgerId, string oDataVersion) string ledgerId, string oDataVersion)
{ {
BaseUrl = baseUrl; BaseUrl = baseUrl;
TenantId = tenantId; TenantId = tenantId;
Environment = environment; Environment = environment;
Api = api; ApiPublisher = apiPublisher;
ApiGroup = apiGroup; ApiGroup = apiGroup;
ApiVersion = apiVersion; ApiVersion = apiVersion;
LedgerId = ledgerId; LedgerId = ledgerId;
ODataVersion = oDataVersion; ODataVersion = oDataVersion;
} }
protected string BaseUrl { get; set; } /// <summary>
protected string TenantId { get; } /// Azure Api Group
protected string Environment { get; set; } /// </summary>
protected string Api { get; set; }
protected string ApiGroup { get; set; } protected string ApiGroup { get; set; }
/// <summary>
/// Azure Api
/// </summary>
protected string ApiPublisher { get; set; }
/// <summary>
/// Azure Api Group
/// </summary>
protected string ApiVersion { get; set; } protected string ApiVersion { get; set; }
/// <summary>
/// Azure Base Url
/// </summary>
protected string BaseUrl { get; set; }
/// <summary>
/// Azure Ledger Id
/// </summary>
protected string LedgerId { get; set; } protected string LedgerId { get; set; }
/// <summary>
/// Azure ODate Version
/// </summary>
protected string ODataVersion { get; set; } protected string ODataVersion { get; set; }
public string InnoClientApiEndpoint() /// <summary>
/// Azure Environment
/// </summary>
protected string Environment { get; set; }
/// <summary>
/// Azure Tenant Id
/// </summary>
protected string TenantId { get; }
/// <summary>
/// Azure Client Api Endpoint
/// </summary>
/// <returns></returns>
public string AzureClientApiEndpoint()
{ {
return $"{BaseUrl}/{TenantId}/{Environment}/api/{Api}/{ApiGroup}/{ApiVersion}/companies({LedgerId})"; return
$"{BaseUrl}/{TenantId}/{Environment}/api/{ApiPublisher}/{ApiGroup}/{ApiVersion}/companies({LedgerId})";
} }
public string InnoClientOAuthEndpoint() /// <summary>
/// Azure OAuth Endpoint
/// </summary>
/// <returns></returns>
public string AzureClientOAuthEndpoint()
{ {
return $"{BaseUrl}/{TenantId}/{Environment}/{ODataVersion}/Company('{LedgerId}')"; return $"{BaseUrl}/{TenantId}/{Environment}/{ODataVersion}/Company('{LedgerId}')";
} }

55
AzureToken.cs Normal file
View file

@ -0,0 +1,55 @@
// ***********************************************************************
// Assembly : FCS.Lib.Azure
// Author :
// Created : 2023 10 02 13:17
//
// Last Modified By : root
// Last Modified On : 2023 10 02 15:24
// ***********************************************************************
// <copyright file="AzureToken.cs" company="FCS">
// Copyright (C) 2023-2023 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see [https://www.gnu.org/licenses]
// </copyright>
// <summary></summary>
// ***********************************************************************
namespace FCS.Lib.Azure;
public class AzureToken
{
/// <summary>
/// Token Type
/// </summary>
public string TokenType { get; set; } = "";
/// <summary>
/// Access Token
/// </summary>
public string AccessToken { get; set; } = "";
/// <summary>
/// Expires
/// </summary>
public long Expires { get; set; }
/// <summary>
/// Token Has Expired
/// </summary>
/// <param name="timestamp"></param>
/// <returns></returns>
public bool HasExpired(long timestamp)
{
return timestamp > Expires;
}
}

56
AzureTokenDto.cs Normal file
View file

@ -0,0 +1,56 @@
// ***********************************************************************
// Assembly : FCS.Lib.Azure
// Author :
// Created : 2023 10 02 13:17
//
// Last Modified By : root
// Last Modified On : 2023 10 02 15:24
// ***********************************************************************
// <copyright file="AzureTokenDto.cs" company="FCS">
// Copyright (C) 2023-2023 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see [https://www.gnu.org/licenses]
// </copyright>
// <summary></summary>
// ***********************************************************************
using System.Text.Json.Serialization;
namespace FCS.Lib.Azure;
public class AzureTokenDto
{
/// <summary>
/// Token Type
/// </summary>
[JsonPropertyName("token_type")]
public string TokenType { get; set; }
/// <summary>
/// Expires In
/// </summary>
[JsonPropertyName("expires_in")]
public long ExpiresIn { get; set; }
/// <summary>
/// Ext Expires In
/// </summary>
[JsonPropertyName("ext_expires_in")]
public long ExtExpiresIn { get; set; }
/// <summary>
/// Access Token
/// </summary>
[JsonPropertyName("access_token")]
public string AccessToken { get; set; }
}

View file

@ -1,13 +1,13 @@
// *********************************************************************** // ***********************************************************************
// Assembly : FCS.Lib.Azure // Assembly : FCS.Lib.Azure
// Author : FH // Author :
// Created : 05-10-2022 // Created : 2023 10 02 13:25
// //
// Last Modified By : FH // Last Modified By : root
// Last Modified On : 05-10-2022 // Last Modified On : 2023 10 02 15:24
// *********************************************************************** // ***********************************************************************
// <copyright file="AzureTokenFetcher.cs" company="FCS-TECH"> // <copyright file="AzureTokenFetcher.cs" company="FCS">
// Copyright (C) 2022 FCS Frede's Computer Services. // Copyright (C) 2023-2023 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the // published by the Free Software Foundation, either version 3 of the
@ -25,24 +25,35 @@
// *********************************************************************** // ***********************************************************************
using System.Threading.Tasks; using System.Threading.Tasks;
using FCS.Contracts; using FCS.Lib.Azure;
using FCS.Lib.Common;
namespace Inno.Azure;
namespace FCS.Lib.Azure /// <summary>
/// Implements IAzureTokenFetcher
/// </summary>
public class AzureTokenFetcher : IAzureTokenFetcher
{ {
public class AzureTokenFetcher : IAzureTokenFetcher
{
private readonly AzureAuthStore _config; private readonly AzureAuthStore _config;
/// <summary>
/// Construct a new Azure Token Fetcher from configuration
/// </summary>
/// <param name="config"></param>
public AzureTokenFetcher(AzureAuthStore config) public AzureTokenFetcher(AzureAuthStore config)
{ {
_config = config; _config = config;
} }
/// <summary>
/// Fetch Azure Token
/// </summary>
/// <returns></returns>
public async Task<AzureToken> FetchAzureToken() public async Task<AzureToken> FetchAzureToken()
{ {
var result = await AzureTokenHttpRequest.RequestTokenAsync(_config).ConfigureAwait(true); var result = await AzureTokenHttpRequest.RequestTokenAsync(_config).ConfigureAwait(true);
return !result.IsSuccessStatusCode ? new AzureToken{Expires = -1} : new AzureTokenMapper().MapAzureToken(result.Message); return !result.IsSuccessStatusCode
} ? new AzureToken { Expires = -1 }
: new AzureTokenMapper().MapAzureToken(result.Message);
} }
} }

View file

@ -1,19 +1,45 @@
using System.Collections.Generic; // ***********************************************************************
// Assembly : FCS.Lib.Azure
// Author :
// Created : 2023 10 02 13:19
//
// Last Modified By : root
// Last Modified On : 2023 10 02 15:24
// ***********************************************************************
// <copyright file="AzureTokenHttpRequest.cs" company="FCS">
// Copyright (C) 2023-2023 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see [https://www.gnu.org/licenses]
// </copyright>
// <summary></summary>
// ***********************************************************************
using System.Collections.Generic;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using Inno.Business.Models.Common; using FCS.Lib.Common;
namespace Inno.Azure namespace FCS.Lib.Azure;
public class AzureTokenHttpRequest
{ {
public class AzureTokenHttpRequest public static async Task<HttpResponseView> RequestTokenAsync(AzureAuthStore auth)
{
public static async Task<ResponseView> RequestTokenAsync(AzureAuthStore auth)
{ {
var credentials = new Dictionary<string, string> var credentials = new Dictionary<string, string>
{ {
{ "grant_type", auth.AzureGrantType }, { "grant_type", auth.AzureGrantType },
{ "client_id", auth.AzureClientId }, { "client_id", auth.AzureClientId },
{ "client_secret", auth.AzureSecret }, { "client_secret", auth.AzureClientSecret },
{ "scope", auth.AzureLoginScope } { "scope", auth.AzureLoginScope }
}; };
@ -27,12 +53,11 @@ namespace Inno.Azure
var azureResponse = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(true); var azureResponse = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(true);
return new ResponseView return new HttpResponseView
{ {
Code = responseMessage.StatusCode, Code = responseMessage.StatusCode,
IsSuccessStatusCode = responseMessage.IsSuccessStatusCode, IsSuccessStatusCode = responseMessage.IsSuccessStatusCode,
Message = azureResponse Message = azureResponse
}; };
} }
}
} }

View file

@ -1,13 +1,13 @@
// *********************************************************************** // ***********************************************************************
// Assembly : FCS.Lib.Azure // Assembly : FCS.Lib.Azure
// Author : FH // Author :
// Created : 05-08-2022 // Created : 2023 10 02 13:17
// //
// Last Modified By : FH // Last Modified By : root
// Last Modified On : 05-10-2022 // Last Modified On : 2023 10 02 15:24
// *********************************************************************** // ***********************************************************************
// <copyright file="AzureTokenMapper.cs" company="FCS-TECH"> // <copyright file="AzureTokenMapper.cs" company="FCS">
// Copyright (C) 2022 FCS Frede's Computer Services. // Copyright (C) 2023-2023 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the // published by the Free Software Foundation, either version 3 of the
@ -24,28 +24,27 @@
// <summary></summary> // <summary></summary>
// *********************************************************************** // ***********************************************************************
using System; using System;
using System.Text.Json; using System.Text.Json;
using FCS.Lib.Common;
using FCS.Lib.Utility; using FCS.Lib.Utility;
namespace FCS.Lib.Azure namespace FCS.Lib.Azure;
public class AzureTokenMapper
{ {
public class AzureTokenMapper
{
public AzureToken MapAzureToken(string json) public AzureToken MapAzureToken(string json)
{ {
if(string.IsNullOrWhiteSpace(json)) if (string.IsNullOrWhiteSpace(json))
throw new ArgumentNullException(nameof(json)); throw new ArgumentNullException(nameof(json));
var token = JsonSerializer.Deserialize<AzureTokenDto>(json); var token = JsonSerializer.Deserialize<AzureTokenDto>(json);
return token == null ? null : new AzureToken return token == null
? null
: new AzureToken
{ {
AccessToken = token.AccessToken, AccessToken = token.AccessToken,
Expires = Mogrify.CurrentDateTimeToTimeStamp() + token.ExtExpiresIn - 600, Expires = Mogrify.CurrentDateTimeToTimeStamp() + token.ExtExpiresIn - 600,
TokenType = token.TokenType TokenType = token.TokenType
}; };
} }
}
} }

View file

@ -3,6 +3,7 @@
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup> <PropertyGroup>
<LangVersion>10.0</LangVersion> <LangVersion>10.0</LangVersion>
<TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@ -12,7 +13,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>FCS.Lib.Azure</RootNamespace> <RootNamespace>FCS.Lib.Azure</RootNamespace>
<AssemblyName>FCS.Lib.Azure</AssemblyName> <AssemblyName>FCS.Lib.Azure</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion> <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic> <Deterministic>true</Deterministic>
<NuGetPackageImportStamp> <NuGetPackageImportStamp>
@ -38,9 +39,14 @@
<ItemGroup> <ItemGroup>
<Compile Include="AzureAuthStore.cs" /> <Compile Include="AzureAuthStore.cs" />
<Compile Include="AzureConfigStore.cs" /> <Compile Include="AzureConfigStore.cs" />
<Compile Include="AzureToken.cs" />
<Compile Include="AzureTokenDto.cs" />
<Compile Include="AzureTokenFetcher.cs" /> <Compile Include="AzureTokenFetcher.cs" />
<Compile Include="AzureTokenHttpRequest.cs" /> <Compile Include="AzureTokenHttpRequest.cs" />
<Compile Include="AzureTokenMapper.cs" /> <Compile Include="AzureTokenMapper.cs" />
<Compile Include="IAzureConfigProvider.cs" />
<Compile Include="IAzureTokenFetcher.cs" />
<Compile Include="IAzureTokenProvider.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -62,10 +68,6 @@
<Project>{3e5fa1ab-44d2-4cbc-b6d7-80b74ca9b265}</Project> <Project>{3e5fa1ab-44d2-4cbc-b6d7-80b74ca9b265}</Project>
<Name>FCS.Lib.Common</Name> <Name>FCS.Lib.Common</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\fcs-contracts\FCS.Contracts.csproj">
<Project>{8ccdfbd9-80ca-4ddf-9031-3d5d3fb972c2}</Project>
<Name>FCS.Contracts</Name>
</ProjectReference>
<ProjectReference Include="..\fcs-utils\FCS.Lib.Utility.csproj"> <ProjectReference Include="..\fcs-utils\FCS.Lib.Utility.csproj">
<Project>{1f1fecfd-e07e-4b5c-a7f9-67fb89ee94a3}</Project> <Project>{1f1fecfd-e07e-4b5c-a7f9-67fb89ee94a3}</Project>
<Name>FCS.Lib.Utility</Name> <Name>FCS.Lib.Utility</Name>

33
IAzureConfigProvider.cs Normal file
View file

@ -0,0 +1,33 @@
// ***********************************************************************
// Assembly : FCS.Lib.Azure
// Author :
// Created : 2023 10 02 13:17
//
// Last Modified By : root
// Last Modified On : 2023 10 02 15:24
// ***********************************************************************
// <copyright file="IAzureConfigProvider.cs" company="FCS">
// Copyright (C) 2023-2023 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see [https://www.gnu.org/licenses]
// </copyright>
// <summary></summary>
// ***********************************************************************
namespace FCS.Lib.Azure;
public interface IAzureConfigProvider
{
AzureConfigStore GetAzureConfigStore(string country);
AzureAuthStore GetAzureAuthStore();
}

34
IAzureTokenFetcher.cs Normal file
View file

@ -0,0 +1,34 @@
// ***********************************************************************
// Assembly : FCS.Lib.Azure
// Author :
// Created : 2023 10 02 13:17
//
// Last Modified By : root
// Last Modified On : 2023 10 02 15:24
// ***********************************************************************
// <copyright file="IAzureTokenFetcher.cs" company="FCS">
// Copyright (C) 2023-2023 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see [https://www.gnu.org/licenses]
// </copyright>
// <summary></summary>
// ***********************************************************************
using System.Threading.Tasks;
namespace FCS.Lib.Azure;
public interface IAzureTokenFetcher
{
Task<AzureToken> FetchAzureToken();
}

48
IAzureTokenProvider.cs Normal file
View file

@ -0,0 +1,48 @@
// ***********************************************************************
// Assembly : FCS.Lib.Azure
// Author :
// Created : 2023 10 02 13:17
//
// Last Modified By : root
// Last Modified On : 2023 10 02 15:24
// ***********************************************************************
// <copyright file="IAzureTokenProvider.cs" company="FCS">
// Copyright (C) 2023-2023 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see [https://www.gnu.org/licenses]
// </copyright>
// <summary></summary>
// ***********************************************************************
using System.Threading.Tasks;
namespace FCS.Lib.Azure;
/// <summary>
/// Interface IAzureTokenService
/// </summary>
public interface IAzureTokenProvider
{
/// <summary>
/// Get access token
/// </summary>
/// <returns>Access token as async task</returns>
Task<string> GetAccessToken();
/// <summary>
/// Return if token is valid
/// </summary>
/// <param name="timestamp"></param>
/// <returns>true/false</returns>
bool TokenHasExpired(long timestamp);
}

View file

@ -1,4 +1,30 @@
using System.Reflection; // ***********************************************************************
// Assembly : FCS.Lib.Azure
// Author :
// Created : 2023 10 01 11:03
//
// Last Modified By : root
// Last Modified On : 2023 10 02 15:24
// ***********************************************************************
// <copyright file="AssemblyInfo.cs" company="FCS">
// Copyright (C) 2023-2023 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see [https://www.gnu.org/licenses]
// </copyright>
// <summary></summary>
// ***********************************************************************
using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following

View file

@ -1,19 +1,19 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<configuration> <configuration>
<runtime> <runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly> <dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" /> <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0"/>
</dependentAssembly> </dependentAssembly>
<dependentAssembly> <dependentAssembly>
<assemblyIdentity name="System.Text.Json" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /> <assemblyIdentity name="System.Text.Json" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-6.0.0.4" newVersion="6.0.0.4" /> <bindingRedirect oldVersion="0.0.0.0-6.0.0.4" newVersion="6.0.0.4"/>
</dependentAssembly> </dependentAssembly>
<dependentAssembly> <dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Configuration" publicKeyToken="adb9793829ddae60" culture="neutral" /> <assemblyIdentity name="Microsoft.Extensions.Configuration" publicKeyToken="adb9793829ddae60" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-6.0.0.1" newVersion="6.0.0.1" /> <bindingRedirect oldVersion="0.0.0.0-6.0.0.1" newVersion="6.0.0.1"/>
</dependentAssembly> </dependentAssembly>
</assemblyBinding> </assemblyBinding>
</runtime> </runtime>
</configuration> <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/></startup></configuration>