-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add cert option in dev app add decrypt cert
- Loading branch information
Showing
13 changed files
with
153 additions
and
43 deletions.
There are no files selected for viewing
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
File renamed without changes.
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
File renamed without changes.
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
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
69 changes: 69 additions & 0 deletions
69
tests/Microsoft.Identity.Web.Test/Certificates/DefaultCertificateLoaderTests.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 |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System.Collections.Generic; | ||
using System.Security.Cryptography.X509Certificates; | ||
using Microsoft.Identity.Web.Test.Common; | ||
using Xunit; | ||
|
||
namespace Microsoft.Identity.Web.Test.Certificates | ||
{ | ||
public class DefaultCertificateLoaderTests | ||
{ | ||
// https://portal.azure.com/#blade/Microsoft_AAD_RegisteredApps/ApplicationMenuBlade/Credentials/appId/86699d80-dd21-476a-bcd1-7c1a3d471f75/isMSAApp/ | ||
// [InlineData(CertificateSource.KeyVault, TestConstants.KeyVaultContainer, TestConstants.KeyVaultReference)] | ||
// [InlineData(CertificateSource.Path, @"c:\temp\WebAppCallingWebApiCert.pfx", "")] | ||
// [InlineData(CertificateSource.StoreWithDistinguishedName, "CurrentUser/My", "CN=WebAppCallingWebApiCert")] | ||
// [InlineData(CertificateSource.StoreWithThumbprint, "CurrentUser/My", "962D129A859174EE8B5596985BD18EFEB6961684")] | ||
[InlineData(CertificateSource.Base64Encoded, null, TestConstants.CertificateX5c)] | ||
[Theory] | ||
public void TestDefaultCertificateLoader(CertificateSource certificateSource, string container, string referenceOrValue) | ||
{ | ||
CertificateDescription certificateDescription = new CertificateDescription | ||
{ | ||
SourceType = certificateSource, | ||
Container = container, | ||
ReferenceOrValue = referenceOrValue, | ||
}; | ||
|
||
ICertificateLoader loader = new DefaultCertificateLoader(); | ||
loader.LoadIfNeeded(certificateDescription); | ||
|
||
Assert.NotNull(certificateDescription.Certificate); | ||
} | ||
|
||
[InlineData(CertificateSource.Base64Encoded, null, TestConstants.CertificateX5c)] | ||
[Theory] | ||
public void TestLoadFirstCertificate( | ||
CertificateSource certificateSource, | ||
string container, | ||
string referenceOrValue) | ||
{ | ||
IEnumerable<CertificateDescription> certDescriptions = CreateCertificateDescriptions( | ||
certificateSource, | ||
container, | ||
referenceOrValue); | ||
|
||
X509Certificate2 certificate = DefaultCertificateLoader.LoadFirstCertificate(certDescriptions); | ||
|
||
Assert.NotNull(certificate); | ||
Assert.Equal("CN=ACS2ClientCertificate", certificate.Issuer); | ||
} | ||
|
||
private IEnumerable<CertificateDescription> CreateCertificateDescriptions( | ||
CertificateSource certificateSource, | ||
string container, | ||
string referenceOrValue) | ||
{ | ||
List<CertificateDescription> certificateDescription = new List<CertificateDescription>(); | ||
certificateDescription.Add(new CertificateDescription | ||
{ | ||
SourceType = certificateSource, | ||
Container = container, | ||
ReferenceOrValue = referenceOrValue, | ||
}); | ||
|
||
return certificateDescription; | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
tests/WebAppCallsWebApiCallsGraph/Client/Properties/serviceDependencies.json
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"dependencies": { | ||
"secrets1": { | ||
"type": "secrets" | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
tests/WebAppCallsWebApiCallsGraph/Client/Properties/serviceDependencies.local.json
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"dependencies": { | ||
"secrets1": { | ||
"type": "secrets.user" | ||
} | ||
} | ||
} |
55 changes: 30 additions & 25 deletions
55
tests/WebAppCallsWebApiCallsGraph/Client/appsettings.json
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,34 +1,39 @@ | ||
{ | ||
"AzureAd": { | ||
"Instance": "https://login.microsoftonline.com/", | ||
"Domain": "msidentitysamplestesting.onmicrosoft.com", | ||
"TenantId": "7f58f645-c190-4ce5-9de4-e2b7acd2a6ab", | ||
"ClientId": "86699d80-dd21-476a-bcd1-7c1a3d471f75", | ||
"CallbackPath": "/signin-oidc", | ||
"SignedOutCallbackPath ": "/signout-callback-oidc", | ||
"AzureAd": { | ||
"Instance": "https://login.microsoftonline.com/", | ||
"Domain": "msidentitysamplestesting.onmicrosoft.com", | ||
"TenantId": "7f58f645-c190-4ce5-9de4-e2b7acd2a6ab", | ||
"ClientId": "86699d80-dd21-476a-bcd1-7c1a3d471f75", | ||
"CallbackPath": "/signin-oidc", | ||
"SignedOutCallbackPath ": "/signout-callback-oidc", | ||
|
||
|
||
|
||
// To call an API | ||
"ClientSecret": "[Copy the client secret added to the app from the Azure portal]" | ||
}, | ||
"TodoList": { | ||
/* | ||
// To call an API | ||
// "ClientSecret": "[Copy the client secret added to the app from the Azure portal]", | ||
//"ClientCertificates": [ | ||
// { | ||
// "SourceType": "", | ||
// "Container": "", | ||
// "ReferenceOrValue": "" | ||
// } | ||
//] | ||
}, | ||
"TodoList": { | ||
/* | ||
TodoListScope is the scope of the Web API you want to call. This can be: "api://a4c2469b-cf84-4145-8f5f-cb7bacf814bc/access_as_user", | ||
- a scope for a V2 application (for instance api://b3682cc7-8b30-4bd2-aaba-080c6bf0fd31/access_as_user) | ||
- a scope corresponding to a V1 application (for instance <GUID>/user_impersonation, where <GUID> is the | ||
clientId of a V1 application, created in the https://portal.azure.com portal. | ||
*/ | ||
"TodoListScope": "api://a4c2469b-cf84-4145-8f5f-cb7bacf814bc/access_as_user", | ||
"TodoListBaseAddress": "https://localhost:44351" | ||
"TodoListScope": "api://a4c2469b-cf84-4145-8f5f-cb7bacf814bc/access_as_user", | ||
"TodoListBaseAddress": "https://localhost:44351" | ||
|
||
}, | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft": "Warning", | ||
"Microsoft.Hosting.Lifetime": "Information" | ||
} | ||
}, | ||
"AllowedHosts": "*" | ||
}, | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft": "Warning", | ||
"Microsoft.Hosting.Lifetime": "Information" | ||
} | ||
}, | ||
"AllowedHosts": "*" | ||
} |