Skip to content

Commit 29f7210

Browse files
authored
Merge pull request #1 from walissa/release-v1.0.0.0
Release v1.0.0.0
2 parents 5ade063 + 5bbfb7a commit 29f7210

31 files changed

+2010
-1
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,3 +348,6 @@ MigrationBackup/
348348

349349
# Ionide (cross platform F# VS Code tools) working folder
350350
.ionide/
351+
/Deployment
352+
/BizTalkComponents.WCFExtensions.SecurityTokenHelper1.0.0.0.msi
353+
/WcfExtensions.config
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 14
4+
VisualStudioVersion = 14.0.25420.1
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecurityTokenHelper", "src\SecurityTokenHelper\SecurityTokenHelper.csproj", "{E23E8B45-A2F0-4B31-9778-AF8642C0C88E}"
7+
EndProject
8+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{EAE664FA-8A51-4E8C-A0B2-BFB19AAA679C}"
9+
ProjectSection(SolutionItems) = preProject
10+
README.md = README.md
11+
EndProjectSection
12+
EndProject
13+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecurityTokenHelperTests", "UnitTests\SecurityTokenHelperTests\SecurityTokenHelperTests.csproj", "{09050B4B-A709-4BD4-91C7-86AF2FD9C459}"
14+
EndProject
15+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestCacheToken", "UnitTests\TestCacheToken\TestCacheToken.csproj", "{BEF9AF84-FCDA-4DE5-B255-4D59387CD83C}"
16+
EndProject
17+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{29D0D37E-71F8-41DD-9ABF-0221837E204A}"
18+
ProjectSection(SolutionItems) = preProject
19+
Build\Build.proj = Build\Build.proj
20+
EndProjectSection
21+
EndProject
22+
Global
23+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
24+
Debug|Any CPU = Debug|Any CPU
25+
Release|Any CPU = Release|Any CPU
26+
EndGlobalSection
27+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
28+
{E23E8B45-A2F0-4B31-9778-AF8642C0C88E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
29+
{E23E8B45-A2F0-4B31-9778-AF8642C0C88E}.Debug|Any CPU.Build.0 = Debug|Any CPU
30+
{E23E8B45-A2F0-4B31-9778-AF8642C0C88E}.Release|Any CPU.ActiveCfg = Release|Any CPU
31+
{E23E8B45-A2F0-4B31-9778-AF8642C0C88E}.Release|Any CPU.Build.0 = Release|Any CPU
32+
{09050B4B-A709-4BD4-91C7-86AF2FD9C459}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33+
{09050B4B-A709-4BD4-91C7-86AF2FD9C459}.Debug|Any CPU.Build.0 = Debug|Any CPU
34+
{09050B4B-A709-4BD4-91C7-86AF2FD9C459}.Release|Any CPU.ActiveCfg = Release|Any CPU
35+
{09050B4B-A709-4BD4-91C7-86AF2FD9C459}.Release|Any CPU.Build.0 = Release|Any CPU
36+
{BEF9AF84-FCDA-4DE5-B255-4D59387CD83C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
37+
{BEF9AF84-FCDA-4DE5-B255-4D59387CD83C}.Debug|Any CPU.Build.0 = Debug|Any CPU
38+
{BEF9AF84-FCDA-4DE5-B255-4D59387CD83C}.Release|Any CPU.ActiveCfg = Release|Any CPU
39+
{BEF9AF84-FCDA-4DE5-B255-4D59387CD83C}.Release|Any CPU.Build.0 = Release|Any CPU
40+
EndGlobalSection
41+
GlobalSection(SolutionProperties) = preSolution
42+
HideSolutionNode = FALSE
43+
EndGlobalSection
44+
EndGlobal

Build/Build.proj

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<Project DefaultTargets="GenerateMsi" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2+
<Import Project="$(MSBuildExtensionsPath1)\BtsMsiTask\BtsMsiTask.targets" />
3+
<Import Project="$(MSBuildExtensionsPath1)\ExtensionPack\4.0\MSBuild.ExtensionPack.tasks"/>
4+
5+
<PropertyGroup>
6+
<DestinationPath>$(build_artifactstagingdirectory)</DestinationPath>
7+
<ApplicationName>BizTalkComponents.WCFExtensions.SecurityTokenHelper</ApplicationName>
8+
</PropertyGroup>
9+
<ItemGroup>
10+
<Resource Include="..\Src\SecurityTokenHelper\bin\$(Configuration)\BizTalkComponents.WCFExtensions.SecurityTokenHelper.dll" />
11+
</ItemGroup>
12+
13+
<Target Name="GetVersion">
14+
<MSBuild.ExtensionPack.Framework.Assembly TaskAction="GetInfo" NetAssembly="..\Src\SecurityTokenHelper\bin\$(Configuration)\BizTalkComponents.WCFExtensions.SecurityTokenHelper.dll">
15+
<Output TaskParameter="OutputItems" ItemName="Info"/>
16+
</MSBuild.ExtensionPack.Framework.Assembly>
17+
</Target>
18+
19+
<Target Name="GenerateMsi" DependsOnTargets="GetVersion">
20+
<MsiTask
21+
FileName="BizTalkComponents.WCFExtensions.SecurityTokenHelper%(Info.AssemblyInformationalVersion).msi"
22+
DestinationPath="$(DestinationPath)"
23+
ApplicationName="$(ApplicationName)"
24+
SourceLocation="C:\%(Info.AssemblyInformationalVersion)"
25+
Resources="@(Resource)" />
26+
</Target>
27+
</Project>

README.md

Lines changed: 103 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,104 @@
11
# SecurityTokenHelper
2-
WCF behavior extension allows to retrieve a token from a token service endpoint and to add the token to the main call for a given binding like WebHttpBinding
2+
[![Build status](https://dev.azure.com/mytestings/Integrations/_apis/build/status/SecurityTokenHelper?branchName=main)](https://dev.azure.com/mytestings/Integrations/_build/latest?definitionId=30)
3+
4+
SecurityTokenHelper is a WCF endpoint behavior extension that helps authenticating calls in BizTalk, it also contains TokenHelper class that use to get token with without using WCF.
5+
6+
## TokenHelper Functions
7+
8+
- string GetBasicAuthEncoded(string username, string password): encodes username:password string in Base64 format to be used in basic auth header.
9+
- GetToken
10+
```
11+
string GetToken(HttpMethodEnum method, string url, HeaderCollection headers, string contentType, string body, string tokenPath)
12+
string GetToken(HttpMethodEnum method, string url, HeaderCollection headers, string contentType, string body, string tokenPath, Guid tokenId, int tokenExpiresIn, bool cachedToken)
13+
```
14+
### Parameters
15+
| Parameter| Type| Description |
16+
|--|--|--|
17+
| method | HttpMethodEnum (Required) | The http method used when calling the token service endpoint.<br/>[POST (Default),GET]
18+
| url | string (Required) | The token service endpoint url.
19+
| headers | HeaderCollection (Optional) | Headers to be used to make successful call.
20+
| contentType | string (Optional) | The content-type for the body is being sent in the call, Required if the body parameter is not empty |
21+
| body | string (Optional) | The body of the call.
22+
| tokenPath | string (Required)| The XPath or JPath for the token value e.g. for JSON: $..access_token, For Xml: /Token/Access_Token.|
23+
|cachedToken| bool (Optional)| determines if the token to be cached, or retrieved from Token Cache|
24+
| tokenId | guid (Optional) | Token identifier, must be determined if cachedToken is set to true.|
25+
| expriesIn | int (Optional) | the period in seconds for the token before it expires, required if cachedToken is set to true, and must have a value greater than 0|
26+
27+
## SecurityTokenHelperBehavior
28+
The WCF Behavior extension to be used with WCF bindings to retrieve the token from a token service endpoint before performing the main call.
29+
30+
### Properties
31+
32+
|Property | Type| Description |
33+
|--|--|--|
34+
| HttpMethod | HttpMethodEnum (Required) | The http method used when calling the token service endpoint.<br/>[POST (Default),GET]
35+
| AuthEndpoint | string (Required) | The token service endpoint url.
36+
| Headers| HeaderCollection (Optional) | Headers to be used to make successful call.
37+
| ContentType| string (Optional) | The content-type for the body is being sent in the call, Required if Body property is not empty |
38+
| Body | string (Optional) | The body of the call.
39+
| TokenPath | string (Required)| The XPath or JPath for the token value e.g. for JSON: $..access_token, For Xml: /Token/Access_Token.|
40+
|CacheToken| bool (Optional)| determines if the token to be cached, or retrieved from Token Cache|
41+
| TokenId| guid (Optional) | Token identifier, must be determined if CacheToken is set to true.|
42+
| TokenExpiresIn| int (Optional) | the period in seconds for the token before it expires, required if CacheToken is set to true, and must have a value greater than 0|
43+
|TokenUsage| TokenUsageEnum(Required) | Specifies where to use the retrieved token in the main call, [Header (Default),QueryParameter]|
44+
|TokenKey| string (Required)| the name of the header or the query string parameter that holds the retrieved token e.g. Authorization|
45+
|TokenPrefix| string(Optional)| a prefix to be added before the token e.g. Bearer |
46+
|TokenSuffix| string (Optional) | a suffix to be added to the token |
47+
48+
49+
## SecurityTokenHelperElement
50+
This is the WCF behavior extension element, that will load all the configuration from the config file, and it presents the behavior extension in BizTalk.
51+
52+
### Properties
53+
54+
|Property | Type| Description |
55+
|--|--|--|
56+
| HttpMethod | HttpMethodEnum (Required) | The http method used when calling the token service endpoint.<br/>[POST (Default),GET]
57+
| AuthEndpoint | string (Required) | The token service endpoint url.
58+
| Headers| string(Optional) | Headers to be used to make successful call, this is multiline property and each header is represented in a single line.
59+
| ContentType| string (Optional) | The content-type for the body is being sent in the call, Required if Body property is not empty |
60+
| Body | string (Optional) | The body of the call.
61+
| TokenPath | string (Required)| The XPath or JPath for the token value e.g. for JSON: $..access_token, For Xml: /Token/Access_Token.|
62+
|CacheToken| bool (Optional)| determines if the token to be cached, or retrieved from Token Cache|
63+
| TokenId| guid (Optional) | Token identifier, must be determined if CacheToken is set to true.|
64+
| TokenExpiresIn| int (Optional) | the period in seconds for the token before it expires, required if CacheToken is set to true, and must have a value greater than 0|
65+
|TokenUsage| TokenUsageEnum(Required) | Specifies where to use the retrieved token in the main call, [Header (Default),QueryParameter]|
66+
|TokenKey| string (Required)| the name of the header or the query string parameter that holds the retrieved token e.g. Authorization|
67+
|TokenPrefix| string(Optional)| a prefix to be added before the token e.g. Bearer |
68+
|TokenSuffix| string (Optional) | a suffix to be added to the token |
69+
## Remarks
70+
71+
72+
## Installation
73+
Download and install the latest release.
74+
This extension is designed to be used with BizTalk, but it can also be used with other applications.
75+
There are two ways to add this extension to the configuration, it can be added to the global machine.config file, or it can be added to the host instance only.
76+
77+
### Adding the extension to machine.config
78+
the extension must be added to both .Net framework versions (32 bit and 64 bit).
79+
80+
81+
`%windir%\Microsoft.Net\Framework\<.NET Version>\config\machine.config`
82+
83+
`%windir%\Microsoft.Net\Framework64\<.NET Version>\config\machine.config`
84+
85+
86+
locate behaviorExtensions section and add the following line
87+
```
88+
<add name="SecurityTokenHelper" type="BizTalkComponents.WCFExtensions.SecurityTokenHelper.SecurityTokenHelperElement, BizTalkComponents.WCFExtensions.SecurityTokenHelper, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f8600b34c8012b7b" />
89+
```
90+
91+
### Adding the extension to BizTalk Host Instance
92+
In BizTalk Administrator Console, go to Platform Settings --> Adapters and select the WCF adapter you would like to add the extension to, then select the send handler you want to make the extension available with, right click on it and then select properties, Click Properties button in Adapter Handler Properties, then select WCF extensions, copy the code below to a new Xml file then click on Import.
93+
```
94+
<configuration>
95+
<system.serviceModel>
96+
<extensions>
97+
<behaviorExtensions>
98+
<add name="SecurityTokenHelper" type="BizTalkComponents.WCFExtensions.SecurityTokenHelper.SecurityTokenHelperElement, BizTalkComponents.WCFExtensions.SecurityTokenHelper, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f8600b34c8012b7b" />
99+
</behaviorExtensions>
100+
</extensions>
101+
</system.serviceModel>
102+
</configuration>
103+
```
104+
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("TestAuthHelper")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("TestAuthHelper")]
13+
[assembly: AssemblyCopyright("Copyright © 2021")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("09050b4b-a709-4bd4-91c7-86af2fd9c459")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProjectGuid>{09050B4B-A709-4BD4-91C7-86AF2FD9C459}</ProjectGuid>
7+
<OutputType>Library</OutputType>
8+
<AppDesignerFolder>Properties</AppDesignerFolder>
9+
<RootNamespace>TestAuthHelper</RootNamespace>
10+
<AssemblyName>TestAuthHelper</AssemblyName>
11+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
14+
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
15+
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
16+
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
17+
<IsCodedUITest>False</IsCodedUITest>
18+
<TestProjectType>UnitTest</TestProjectType>
19+
</PropertyGroup>
20+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
21+
<DebugSymbols>true</DebugSymbols>
22+
<DebugType>full</DebugType>
23+
<Optimize>false</Optimize>
24+
<OutputPath>bin\Debug\</OutputPath>
25+
<DefineConstants>DEBUG;TRACE</DefineConstants>
26+
<ErrorReport>prompt</ErrorReport>
27+
<WarningLevel>4</WarningLevel>
28+
</PropertyGroup>
29+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
30+
<DebugType>pdbonly</DebugType>
31+
<Optimize>true</Optimize>
32+
<OutputPath>bin\Release\</OutputPath>
33+
<DefineConstants>TRACE</DefineConstants>
34+
<ErrorReport>prompt</ErrorReport>
35+
<WarningLevel>4</WarningLevel>
36+
</PropertyGroup>
37+
<ItemGroup>
38+
<Reference Include="System" />
39+
<Reference Include="System.configuration" />
40+
<Reference Include="System.Data.Services" />
41+
<Reference Include="System.Runtime.Serialization" />
42+
<Reference Include="System.ServiceModel" />
43+
<Reference Include="System.ServiceModel.Web" />
44+
</ItemGroup>
45+
<Choose>
46+
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
47+
<ItemGroup>
48+
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
49+
</ItemGroup>
50+
</When>
51+
<Otherwise>
52+
<ItemGroup>
53+
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
54+
</ItemGroup>
55+
</Otherwise>
56+
</Choose>
57+
<ItemGroup>
58+
<Compile Include="TestBehaviorExtElement.cs" />
59+
<Compile Include="Properties\AssemblyInfo.cs" />
60+
<Compile Include="TestHelper.cs" />
61+
<Compile Include="TestService.cs" />
62+
</ItemGroup>
63+
<ItemGroup>
64+
<ProjectReference Include="..\..\src\SecurityTokenHelper\SecurityTokenHelper.csproj">
65+
<Project>{e23e8b45-a2f0-4b31-9778-af8642c0c88e}</Project>
66+
<Name>SecurityTokenHelper</Name>
67+
</ProjectReference>
68+
</ItemGroup>
69+
<Choose>
70+
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
71+
<ItemGroup>
72+
<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
73+
<Private>False</Private>
74+
</Reference>
75+
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
76+
<Private>False</Private>
77+
</Reference>
78+
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
79+
<Private>False</Private>
80+
</Reference>
81+
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
82+
<Private>False</Private>
83+
</Reference>
84+
</ItemGroup>
85+
</When>
86+
</Choose>
87+
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
88+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
89+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
90+
Other similar extension points exist, see Microsoft.Common.targets.
91+
<Target Name="BeforeBuild">
92+
</Target>
93+
<Target Name="AfterBuild">
94+
</Target>
95+
-->
96+
</Project>

0 commit comments

Comments
 (0)