Enable Windows Identity Foundation in docker - wif

In our current project we develop an ASP.net MVC application hosted in an docker (Docker Desktop for Windows) container using the windows server core image (https://hub.docker.com/r/microsoft/windowsservercore/). Everything is working well but now we would like to use the Windows Identify Foundation (WIF) for authentication with an ADFS.
Unfortunately, the Windows Server Core image for docker does not support the WIF feature and it cannot be installed.
Does someone have an idea how to use the WIF inside of a docker container and/or experience with installing the feature in this image?
Is their an alternative image with the feature enabled?
Similar topics without docker such as:
https://support.microsoft.com/en-us/help/3044149/you-can-t-install-windows-identity-foundation-in-windows-core
https://blogs.technet.microsoft.com/server_core/2012/05/09/configuring-the-minimal-server-interface/
Did not help.

I know this is an old question, but I recently ran into the same problem and wanted to share the resolution I was able to come up with. In my case, I was working with a legacy software solution that referenced "Microsoft.IdentityModel.dll" (installed by WIF), and it was not as easy to just switch it out to something else.
I installed WIF on my laptop (Windows 10) and then added the file to my docker image
C:\Program Files\Reference Assemblies\Microsoft\Windows Identity Foundation\v3.5\Microsoft.IdentityModel.dll
Then, add a PowerShell script to your DOCKERFILE to install that assembly into the GAC manually. Here's a good blog post showing how to do that as well:
https://www.andrewcbancroft.com/2015/12/16/using-powershell-to-install-a-dll-into-the-gac/
Hope it helps!

We could solve our problems with OWIN.
Bas Lijten posted a nice tutorial on this:
http://blog.baslijten.com/configure-claims-based-web-applications-using-owin-wsfederation-middleware/
We configured the usage of WS-Fed with Owin but did not use an Embedded STS. Instead we created a standalone identityserver instance to test the ADFS integration.
On GitHub you can find an example for such an identity server configuration:
https://github.com/IdentityServer/IdentityServer3.Samples/tree/master/source/SelfHost%20(InMem%20with%20WS-Fed)

Related

Error publishing Docker image to Azure container registry

I am trying to publish my first Docker image (built from a simple .Net core console app) to my Azure container registry. The process started and ran for about two minues before errored out. Here is the error:
The log mentioned contains the same imformation.
It looks like the error is related to some Nuget package:
But the problem is that I don't have this "C:\Program Files\dotnet\sdk\5.0.408" folder on my machine:
and I don't have a reference to that package in my project:
What am I missing? and what should do to fix it? I am totaly new to Docker so any inputs will be highly appreciated.
UPDATE
Here is my firewall settings - it doesn't have any Docker related items in it! Could that be the problem? If so, how do I fix it?
• I would advise you to please check the installation of the latest version of the ‘Docker Desktop for Windows’ software that is supported by ‘ASP .Net Core Web App’ long term release version. It should be compatible to the created ‘.Net Core Web App’ version such that when you are trying to publish your web app image from the Visual Studio App to the Azure container registry, the ‘Docker Desktop for Windows’ will be able to sync push the image to the linked ACR.
• Would also suggest you to please check whether the Linux kernel package for x64 machines is updated or not. If not, would suggest you to please download the WSL2 Linux Kernel update package, install it and restart the ‘Docker Desktop for Windows’ software on your system. This will ensure that the Linux kernel set for the Web app in Visual studio is accordingly setup in ‘Docker Desktop for Windows’ application.
• Finally, please check the local Windows firewall for the inbound allow rules for the ‘Docker Desktop for Windows’ software whether its backend is allowed to run and connect to the Azure Container Registry or not as below: -
Also, ensure that the ‘Azure.Container.ContainerRegistry’ library is installed in your environment through the Visual Studio extension gallery as it is required for developing a .Net Web app code. Please ensure that ‘Microsoft Authentication’ libraries are also installed correctly in your Visual Studio repository for successful connections. I followed the below documentation link for publishing Docker image to Azure Container Registry and I was able to successfully connect to the ACR as shown below: -
https://learn.microsoft.com/en-us/visualstudio/containers/hosting-web-apps-in-docker?view=vs-2022
Thus, would suggest you follow the given link.

Providing a Dev-Cert for an ASP.Net Core 3.1 project running in Docker?

When running my ASP.Net Core 3.1 web app in IISExpress the Dev-Cert I have in place is found and used to provide HTTPS, but when I try to run the same app on the same machine but in a Docker Windows container the certificate is not found.
I assume there are some steps needed to make the certificate visible in the Docker container but I've not been able to find anything current discussing this.
What needs to be done to get a Dev https app running in a Windows Docker container? (running from Visual Studio 2019)

Multiple VS 2017 Projects in one Docker Container

I am using VS 2017 15.6.4 which is the latest version. I have a single solution that has three web projects in it:
Solution:
Web Project 1
Web Project 2
Web Project 3
I would like to add Docker support so that all the web projects end up in a single container running IIS with the following IIS site structure:
Root Site (Web Project 1)
Admin Virtual Application (Web Project 2)
Campaign Virtual Application (Web Project 3)
Is there a way to accomplish this in Visual Studio 2017? When I add Docker support it seems to be on a project by project basis. I can run each project in its own container with no issues. Will I be forced to do this outside of Visual Studio?
I had a similar question and found the following helpful. Make sure you have Docker CE installed on your machine, along with VS2017 with Docker support. In VS2017, when you do "Add->Docker Support", it should automatically include the docker-compose.yml file at the root of your solution.
https://learn.microsoft.com/en-us/dotnet/standard/microservices-architecture/multi-container-microservice-net-applications/multi-container-applications-docker-compose#step4_define_svcs_in_docker_compose_yml
There is also a sample application posted on github, linked below. Note that this follows .Net Core v2.1. I'm assuming you are using .net core and if so, note that v2.0 is end of life later this year so you should consider moving to v2.1
https://github.com/dotnet-architecture/eShopOnContainers
The github project above also has links to some free books talking more on docker and .net core. They helped me out a lot!

Base Docker image from existing Windows machine

We have a large application with several parts running on a Windows VM and I am trying to evaluate Docker containers for our application deployment. Is it possible to create a base docker image from an existing Windows VM already running my application? (I know this can be done using Dockerfile but I am looking for a quick way to create the image)
https://docs.docker.com/engine/userguide/eng-image/baseimages/
Above link describes creating image from working machine for Linux, but I am looking for something similar for Windows.
The only base image for Windows that I know are the ones proposed by Microsoft, for Windows Server 2016 or 1709.
See "PoC: How to build images for 1709 without 1709"
That means you can translate any Widows VM into an image.
You would need:
a Dockerfile
the right Microsoft base image, which would represent a Windows server one.
Typically:
microsoft/nanoserver,
microsoft/windowsservercore
If you application only runs on a Windows VM, you need to make sure it can be installed and run on one of those base Windows images.
EVen though you are using a VM Windows server 2016, you would not be able to quickly "capture its state": you need a Dockerfile to describe what you want your Widows container to run.
No it's not possible. You have some stuff like Vm2Docker etc but all it does the same thing you will do manually that is enumerate features installed and create some artifacts for you.
But it's not possible to do for third party application as you mentioned. You'd have to disassemble it and figure out how to scripts to install it.
I am looking for a way to have a Development environment of Production web server for our Developers/testers created using Docker on windows.
I have windows server 2016 OS installed on a Physical server (not VM), and want to dockerize it so that Dev team can make changes on it first and once they confirm all working fine then same changes will be done on production web server.
Thanks,
RK.

How do i run a ServiceStack console project as a Windows Service?

I have create a ServiceStack console application that works great, but of course, I have to leave it running after triggering it from a command prompt. I want to run this as a Windows Service.
I'm reviewing this wiki page which states that you can run SS as a Windows Service.
https://github.com/ServiceStack/ServiceStack/wiki/Self-hosting
I was not totally clear on how to do this. This StarterTemplate is referenced from 2 years ago. Do I clone this project and then copy my code into it?
https://github.com/ServiceStack/ServiceStack.Examples/tree/master/src/StarterTemplates/WinServiceAppHost
The easiest way is to create a ServiceStack Windows Service Empty project in ServiceStackVS VS.NET Extension.
Otherwise you can clone the WinService project, and create a new Windows Service project from Visual Studio and copy the approach in Program.cs.
A more recent ServiceStack Windows Service project is the Razor Rockstars website running in a Windows Service Host, the template of which was based on the ServiceStack.Examples Starter template.
I use topshelf to run a servicestack console app as a windows service. It works really well for me. https://github.com/Topshelf/Topshelf

Resources