Skip to content

Commit

Permalink
Add OIDC authentication (#1130)
Browse files Browse the repository at this point in the history
* Добавил поддержку OIDC.

DDCORE-8610

* Исключил для UseOidc из проверки на наличие асинхронного аналога

* Добавил ObsoleteReasons.

* Добавил перегрузки с actionToken.

Добавил тест на то, что у каждого метода АПИ в клиенте есть перегрузка с authToken.
  • Loading branch information
tkirill authored Oct 24, 2024
1 parent 6168f1d commit 1eb647b
Show file tree
Hide file tree
Showing 17 changed files with 1,152 additions and 74 deletions.
274 changes: 274 additions & 0 deletions src/ComDiadocApi.cs

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions src/Constants/ObsoleteReasons.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Diadoc.Api.Constants
{
internal static class ObsoleteReasons
{
public const string UseAuthTokenOverload = "Use overload with authToken argument";
}
}
145 changes: 145 additions & 0 deletions src/DiadocApi.Async.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,30 +134,65 @@ public Task<OrganizationList> GetOrganizationsByInnKppAsync(string inn, string k
return diadocHttpApi.GetOrganizationsByInnKppAsync(inn, kpp, includeRelations);

Check warning on line 134 in src/DiadocApi.Async.cs

View workflow job for this annotation

GitHub Actions / build_and_test

'DiadocHttpApi.GetOrganizationsByInnKppAsync(string, string, bool)' is obsolete: 'Use overload with authToken argument'

Check warning on line 134 in src/DiadocApi.Async.cs

View workflow job for this annotation

GitHub Actions / build_and_test

'DiadocHttpApi.GetOrganizationsByInnKppAsync(string, string, bool)' is obsolete: 'Use overload with authToken argument'
}

public Task<OrganizationList> GetOrganizationsByInnKppAsync(string authToken, string inn, string kpp, bool includeRelations = false)
{
if (authToken == null) throw new ArgumentNullException(nameof(authToken));
if (inn == null) throw new ArgumentNullException(nameof(inn));
return diadocHttpApi.GetOrganizationsByInnKppAsync(authToken, inn, kpp, includeRelations);
}

public Task<Organization> GetOrganizationByIdAsync(string orgId)
{
if (orgId == null) throw new ArgumentNullException("orgId");
return diadocHttpApi.GetOrganizationByIdAsync(orgId);

Check warning on line 147 in src/DiadocApi.Async.cs

View workflow job for this annotation

GitHub Actions / build_and_test

'DiadocHttpApi.GetOrganizationByIdAsync(string)' is obsolete: 'Use overload with authToken argument'

Check warning on line 147 in src/DiadocApi.Async.cs

View workflow job for this annotation

GitHub Actions / build_and_test

'DiadocHttpApi.GetOrganizationByIdAsync(string)' is obsolete: 'Use overload with authToken argument'
}

public Task<Organization> GetOrganizationByIdAsync(string authToken, string orgId)
{
if (authToken == null) throw new ArgumentNullException(nameof(authToken));
if (orgId == null) throw new ArgumentNullException(nameof(orgId));
return diadocHttpApi.GetOrganizationByIdAsync(authToken, orgId);
}

public Task<Organization> GetOrganizationByBoxIdAsync(string boxId)
{
if (boxId == null) throw new ArgumentNullException("boxId");
return diadocHttpApi.GetOrganizationByBoxIdAsync(boxId);

Check warning on line 160 in src/DiadocApi.Async.cs

View workflow job for this annotation

GitHub Actions / build_and_test

'DiadocHttpApi.GetOrganizationByBoxIdAsync(string)' is obsolete: 'Use overload with authToken argument'

Check warning on line 160 in src/DiadocApi.Async.cs

View workflow job for this annotation

GitHub Actions / build_and_test

'DiadocHttpApi.GetOrganizationByBoxIdAsync(string)' is obsolete: 'Use overload with authToken argument'
}

public Task<Organization> GetOrganizationByBoxIdAsync(string authToken, string boxId)
{
if (authToken == null) throw new ArgumentNullException(nameof(authToken));
if (boxId == null) throw new ArgumentNullException(nameof(boxId));
return diadocHttpApi.GetOrganizationByBoxIdAsync(authToken, boxId);
}

public Task<Organization> GetOrganizationByFnsParticipantIdAsync(string fnsParticipantId)
{
if (fnsParticipantId == null) throw new ArgumentException("fnsParticipantId");
return diadocHttpApi.GetOrganizationByFnsParticipantIdAsync(fnsParticipantId);

Check warning on line 173 in src/DiadocApi.Async.cs

View workflow job for this annotation

GitHub Actions / build_and_test

'DiadocHttpApi.GetOrganizationByFnsParticipantIdAsync(string)' is obsolete: 'Use overload with authToken argument'

Check warning on line 173 in src/DiadocApi.Async.cs

View workflow job for this annotation

GitHub Actions / build_and_test

'DiadocHttpApi.GetOrganizationByFnsParticipantIdAsync(string)' is obsolete: 'Use overload with authToken argument'
}

public Task<Organization> GetOrganizationByFnsParticipantIdAsync(string authToken, string fnsParticipantId)
{
if (authToken == null) throw new ArgumentNullException(nameof(authToken));
if (fnsParticipantId == null) throw new ArgumentNullException(nameof(fnsParticipantId));
return diadocHttpApi.GetOrganizationByFnsParticipantIdAsync(authToken, fnsParticipantId);
}

public Task<Organization> GetOrganizationByInnKppAsync(string inn, string kpp)
{
if (inn == null) throw new ArgumentException("inn");
return diadocHttpApi.GetOrganizationByInnKppAsync(inn, kpp);

Check warning on line 186 in src/DiadocApi.Async.cs

View workflow job for this annotation

GitHub Actions / build_and_test

'DiadocHttpApi.GetOrganizationByInnKppAsync(string, string)' is obsolete: 'Use overload with authToken argument'

Check warning on line 186 in src/DiadocApi.Async.cs

View workflow job for this annotation

GitHub Actions / build_and_test

'DiadocHttpApi.GetOrganizationByInnKppAsync(string, string)' is obsolete: 'Use overload with authToken argument'
}

public Task<Organization> GetOrganizationByInnKppAsync(string authToken, string inn, string kpp)
{
if (authToken == null) throw new ArgumentNullException(nameof(authToken));
if (inn == null) throw new ArgumentNullException(nameof(inn));
return diadocHttpApi.GetOrganizationByInnKppAsync(authToken, inn, kpp);
}

public Task<RoamingOperatorList> GetRoamingOperatorsAsync(string authToken, string boxId)
{
return diadocHttpApi.GetRoamingOperatorsAsync(authToken, boxId);
Expand All @@ -169,6 +204,13 @@ public Task<Box> GetBoxAsync(string boxId)
return diadocHttpApi.GetBoxAsync(boxId);

Check warning on line 204 in src/DiadocApi.Async.cs

View workflow job for this annotation

GitHub Actions / build_and_test

'DiadocHttpApi.GetBoxAsync(string)' is obsolete: 'Use overload with authToken argument'

Check warning on line 204 in src/DiadocApi.Async.cs

View workflow job for this annotation

GitHub Actions / build_and_test

'DiadocHttpApi.GetBoxAsync(string)' is obsolete: 'Use overload with authToken argument'
}

public Task<Box> GetBoxAsync(string authToken, string boxId)
{
if (authToken == null) throw new ArgumentNullException(nameof(authToken));
if (boxId == null) throw new ArgumentNullException(nameof(boxId));
return diadocHttpApi.GetBoxAsync(authToken, boxId);
}

public Task<Department> GetDepartmentAsync(string authToken, string orgId, string departmentId)
{
if (authToken == null) throw new ArgumentNullException("authToken");
Expand Down Expand Up @@ -839,71 +881,155 @@ public Task<RussianAddress> ParseRussianAddressAsync(string address)
return diadocHttpApi.ParseRussianAddressAsync(address);

Check warning on line 881 in src/DiadocApi.Async.cs

View workflow job for this annotation

GitHub Actions / build_and_test

'DiadocHttpApi.ParseRussianAddressAsync(string)' is obsolete: 'Use overload with authToken argument'

Check warning on line 881 in src/DiadocApi.Async.cs

View workflow job for this annotation

GitHub Actions / build_and_test

'DiadocHttpApi.ParseRussianAddressAsync(string)' is obsolete: 'Use overload with authToken argument'
}

public Task<RussianAddress> ParseRussianAddressAsync(string authToken, string address)
{
if (authToken == null) throw new ArgumentNullException(nameof(authToken));
return diadocHttpApi.ParseRussianAddressAsync(authToken, address);
}

public Task<InvoiceInfo> ParseInvoiceXmlAsync(byte[] invoiceXmlContent)
{
return diadocHttpApi.ParseInvoiceXmlAsync(invoiceXmlContent);

Check warning on line 892 in src/DiadocApi.Async.cs

View workflow job for this annotation

GitHub Actions / build_and_test

'DiadocHttpApi.ParseInvoiceXmlAsync(byte[])' is obsolete: 'Use overload with authToken argument'

Check warning on line 892 in src/DiadocApi.Async.cs

View workflow job for this annotation

GitHub Actions / build_and_test

'DiadocHttpApi.ParseInvoiceXmlAsync(byte[])' is obsolete: 'Use overload with authToken argument'
}

public Task<InvoiceInfo> ParseInvoiceXmlAsync(string authToken, byte[] invoiceXmlContent)
{
if (authToken == null) throw new ArgumentNullException(nameof(authToken));
return diadocHttpApi.ParseInvoiceXmlAsync(authToken, invoiceXmlContent);
}

public Task<Torg12SellerTitleInfo> ParseTorg12SellerTitleXmlAsync(byte[] xmlContent)
{
return diadocHttpApi.ParseTorg12SellerTitleXmlAsync(xmlContent);

Check warning on line 903 in src/DiadocApi.Async.cs

View workflow job for this annotation

GitHub Actions / build_and_test

'DiadocHttpApi.ParseTorg12SellerTitleXmlAsync(byte[])' is obsolete: 'Use overload with authToken argument'

Check warning on line 903 in src/DiadocApi.Async.cs

View workflow job for this annotation

GitHub Actions / build_and_test

'DiadocHttpApi.ParseTorg12SellerTitleXmlAsync(byte[])' is obsolete: 'Use overload with authToken argument'
}

public Task<Torg12SellerTitleInfo> ParseTorg12SellerTitleXmlAsync(string authToken, byte[] xmlContent)
{
if (authToken == null) throw new ArgumentNullException(nameof(authToken));
return diadocHttpApi.ParseTorg12SellerTitleXmlAsync(authToken, xmlContent);
}

public Task<Torg12BuyerTitleInfo> ParseTorg12BuyerTitleXmlAsync(byte[] xmlContent)
{
return diadocHttpApi.ParseTorg12BuyerTitleXmlAsync(xmlContent);

Check warning on line 914 in src/DiadocApi.Async.cs

View workflow job for this annotation

GitHub Actions / build_and_test

'DiadocHttpApi.ParseTorg12BuyerTitleXmlAsync(byte[])' is obsolete: 'Use overload with authToken argument'
}

public Task<Torg12BuyerTitleInfo> ParseTorg12BuyerTitleXmlAsync(string authToken, byte[] xmlContent)
{
if (authToken == null) throw new ArgumentNullException(nameof(authToken));
return diadocHttpApi.ParseTorg12BuyerTitleXmlAsync(authToken, xmlContent);
}

public Task<TovTorgSellerTitleInfo> ParseTovTorg551SellerTitleXmlAsync(byte[] xmlContent)
{
return diadocHttpApi.ParseTovTorg551SellerTitleXmlAsync(xmlContent);
}

public Task<TovTorgSellerTitleInfo> ParseTovTorg551SellerTitleXmlAsync(string authToken, byte[] xmlContent)
{
if (authToken == null) throw new ArgumentNullException(nameof(authToken));
return diadocHttpApi.ParseTovTorg551SellerTitleXmlAsync(authToken, xmlContent);
}

public Task<TovTorgBuyerTitleInfo> ParseTovTorg551BuyerTitleXmlAsync(byte[] xmlContent)
{
return diadocHttpApi.ParseTovTorg551BuyerTitleXmlAsync(xmlContent);
}

public Task<TovTorgBuyerTitleInfo> ParseTovTorg551BuyerTitleXmlAsync(string authToken, byte[] xmlContent)
{
if (authToken == null) throw new ArgumentNullException(nameof(authToken));
return diadocHttpApi.ParseTovTorg551BuyerTitleXmlAsync(authToken, xmlContent);
}

public Task<AcceptanceCertificateSellerTitleInfo> ParseAcceptanceCertificateSellerTitleXmlAsync(byte[] xmlContent)
{
return diadocHttpApi.ParseAcceptanceCertificateSellerTitleXmlAsync(xmlContent);
}

public Task<AcceptanceCertificateSellerTitleInfo> ParseAcceptanceCertificateSellerTitleXmlAsync(string authToken, byte[] xmlContent)
{
if (authToken == null) throw new ArgumentNullException(nameof(authToken));
return diadocHttpApi.ParseAcceptanceCertificateSellerTitleXmlAsync(authToken, xmlContent);
}

public Task<AcceptanceCertificateBuyerTitleInfo> ParseAcceptanceCertificateBuyerTitleXmlAsync(byte[] xmlContent)
{
return diadocHttpApi.ParseAcceptanceCertificateBuyerTitleXmlAsync(xmlContent);
}

public Task<AcceptanceCertificateBuyerTitleInfo> ParseAcceptanceCertificateBuyerTitleXmlAsync(string authToken, byte[] xmlContent)
{
if (authToken == null) throw new ArgumentNullException(nameof(authToken));
return diadocHttpApi.ParseAcceptanceCertificateBuyerTitleXmlAsync(authToken, xmlContent);
}

public Task<AcceptanceCertificate552SellerTitleInfo> ParseAcceptanceCertificate552SellerTitleXmlAsync(byte[] xmlContent)
{
return diadocHttpApi.ParseAcceptanceCertificate552SellerTitleXmlAsync(xmlContent);
}

public Task<AcceptanceCertificate552SellerTitleInfo> ParseAcceptanceCertificate552SellerTitleXmlAsync(string authToken, byte[] xmlContent)
{
if (authToken == null) throw new ArgumentNullException(nameof(authToken));
return diadocHttpApi.ParseAcceptanceCertificate552SellerTitleXmlAsync(authToken, xmlContent);
}

public Task<AcceptanceCertificate552BuyerTitleInfo> ParseAcceptanceCertificate552BuyerTitleXmlAsync(byte[] xmlContent)
{
return diadocHttpApi.ParseAcceptanceCertificate552BuyerTitleXmlAsync(xmlContent);
}

public Task<AcceptanceCertificate552BuyerTitleInfo> ParseAcceptanceCertificate552BuyerTitleXmlAsync(string authToken, byte[] xmlContent)
{
if (authToken == null) throw new ArgumentNullException(nameof(authToken));
return diadocHttpApi.ParseAcceptanceCertificate552BuyerTitleXmlAsync(authToken, xmlContent);
}

public Task<UniversalTransferDocumentSellerTitleInfo> ParseUniversalTransferDocumentSellerTitleXmlAsync(byte[] xmlContent, string documentVersion = DefaultDocumentVersions.Utd)
{
return diadocHttpApi.ParseUniversalTransferDocumentSellerTitleXmlAsync(xmlContent, documentVersion);
}

public Task<UniversalTransferDocumentSellerTitleInfo> ParseUniversalTransferDocumentSellerTitleXmlAsync(string authToken, byte[] xmlContent, string documentVersion = DefaultDocumentVersions.Utd)
{
if (authToken == null) throw new ArgumentNullException(nameof(authToken));
return diadocHttpApi.ParseUniversalTransferDocumentSellerTitleXmlAsync(authToken, xmlContent, documentVersion);
}

public Task<UniversalTransferDocumentBuyerTitleInfo> ParseUniversalTransferDocumentBuyerTitleXmlAsync(byte[] xmlContent)
{
return diadocHttpApi.ParseUniversalTransferDocumentBuyerTitleXmlAsync(xmlContent);
}

public Task<UniversalTransferDocumentBuyerTitleInfo> ParseUniversalTransferDocumentBuyerTitleXmlAsync(string authToken, byte[] xmlContent)
{
if (authToken == null) throw new ArgumentNullException(nameof(authToken));
return diadocHttpApi.ParseUniversalTransferDocumentBuyerTitleXmlAsync(authToken, xmlContent);
}

public Task<UniversalCorrectionDocumentSellerTitleInfo> ParseUniversalCorrectionDocumentSellerTitleXmlAsync(byte[] xmlContent, string documentVersion = DefaultDocumentVersions.Ucd)
{
return diadocHttpApi.ParseUniversalCorrectionDocumentSellerTitleXmlAsync(xmlContent, documentVersion);
}

public Task<UniversalCorrectionDocumentSellerTitleInfo> ParseUniversalCorrectionDocumentSellerTitleXmlAsync(string authToken, byte[] xmlContent, string documentVersion = DefaultDocumentVersions.Ucd)
{
if (authToken == null) throw new ArgumentNullException(nameof(authToken));
return diadocHttpApi.ParseUniversalCorrectionDocumentSellerTitleXmlAsync(authToken, xmlContent, documentVersion);
}

public Task<UniversalTransferDocumentBuyerTitleInfo> ParseUniversalCorrectionDocumentBuyerTitleXmlAsync(byte[] xmlContent)
{
return diadocHttpApi.ParseUniversalCorrectionDocumentBuyerTitleXmlAsync(xmlContent);
}

public Task<UniversalTransferDocumentBuyerTitleInfo> ParseUniversalCorrectionDocumentBuyerTitleXmlAsync(string authToken, byte[] xmlContent)
{
if (authToken == null) throw new ArgumentNullException(nameof(authToken));
return diadocHttpApi.ParseUniversalCorrectionDocumentBuyerTitleXmlAsync(authToken, xmlContent);
}

public Task<byte[]> ParseTitleXmlAsync(
string authToken,
string boxId,
Expand Down Expand Up @@ -952,6 +1078,13 @@ public Task<List<Organization>> GetOrganizationsByInnListAsync(GetOrganizationsB
return diadocHttpApi.GetOrganizationsByInnListAsync(innList);
}

public Task<List<Organization>> GetOrganizationsByInnListAsync(string authToken, GetOrganizationsByInnListRequest innList)
{
if (authToken == null) throw new ArgumentNullException(nameof(authToken));
if (innList == null) throw new ArgumentNullException(nameof(innList));
return diadocHttpApi.GetOrganizationsByInnListAsync(authToken, innList);
}

public Task<List<OrganizationWithCounteragentStatus>> GetOrganizationsByInnListAsync(string authToken, string myOrgId,
GetOrganizationsByInnListRequest innList)
{
Expand All @@ -969,11 +1102,23 @@ public Task<RevocationRequestInfo> ParseRevocationRequestXmlAsync(byte[] revocat
return diadocHttpApi.ParseRevocationRequestXmlAsync(revocationRequestXmlContent);
}

public Task<RevocationRequestInfo> ParseRevocationRequestXmlAsync(string authToken, byte[] revocationRequestXmlContent)
{
if (authToken == null) throw new ArgumentNullException(nameof(authToken));
return diadocHttpApi.ParseRevocationRequestXmlAsync(authToken, revocationRequestXmlContent);
}

public Task<SignatureRejectionInfo> ParseSignatureRejectionXmlAsync(byte[] signatureRejectionXmlContent)
{
return diadocHttpApi.ParseSignatureRejectionXmlAsync(signatureRejectionXmlContent);
}

public Task<SignatureRejectionInfo> ParseSignatureRejectionXmlAsync(string authToken, byte[] signatureRejectionXmlContent)
{
if (authToken == null) throw new ArgumentNullException(nameof(authToken));
return diadocHttpApi.ParseSignatureRejectionXmlAsync(authToken, signatureRejectionXmlContent);
}

public Task<DocumentProtocolResult> GenerateDocumentProtocolAsync(string authToken, string boxId, string messageId,
string documentId)
{
Expand Down
Loading

0 comments on commit 1eb647b

Please sign in to comment.