There's a common use case where you are using some external system e.g. Facebook to authenticate and ADFS is in the pipeline as a R-STS.
Facebook only returns a GUID which doesn't mean a lot to AD so you have a registration flow where you ask the user for their details e.g. name, email address .. and then map the GUID to this.
So the next time the user logs in you have the GUID but need to use this as a "primary key" to get the rest of the details from AD.
Assume you have placed the Facebook GUID in a claim type called:
http://schemas.xmlsoap.org/ws/2005/05/identity/claims/guid
and it's stored in AD in extensionAttribute1.
So you have a normal LDAP claims rule that maps:
extensionAttribute1 --> http://schemas.xmlsoap.org/ws/2005/05/identity/claims/guid
Then you need a custom ADFS claim rule to do the extraction based on the mapping:
c:[Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/guid"]
=> issue(store = "Active Directory", types = ("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname", "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname", "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress", "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/mobilephone"), query = "(&(extensionAttribute1={0})(objectClass=user));givenName,sn,mail,mobile;domain\user", param = c.Value);
So the rule searches AD for the user whose extensionAttribute1 value matches "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/guid" and then returns:
"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname"
"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname"
"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress"
"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/mobilephone"
as four separate claims.
Enjoy!
Ideas and thoughts about Microsoft Identity, C# development, cabbages and kings and random flotsam on the incoming tide
Monday, November 17, 2014
AD : Information about the domain could not be retrieved (1355)
Setting up a new system with an AD in a DC in another domain that is "sandpitted" and got this error.
"Information about the domain could not be retrieved (1355)".
Can ping the DC but the IP / Name is in my host file - it's not on the DNS.
Lots of stuff on the Internet - mainly red herrings.
The problem was the DNS "hole" - adding this DC as my alternate DNS on my Windows 7 box fixed the problem.
Update
Turns out this is not sufficient. Still get this &^%&^% problem.
Start / Control Panel / Network and Internet / Network and Sharing Centre
On LHS at top / Change Adapter Settings
Right click / Disable
You will lose your network connection!!!
Right click / Enable
All will be well until you reset your PC and then you will have the joy of doing it all again.
Use at own risk but works for me.
Enjoy!
"Information about the domain could not be retrieved (1355)".
Can ping the DC but the IP / Name is in my host file - it's not on the DNS.
Lots of stuff on the Internet - mainly red herrings.
The problem was the DNS "hole" - adding this DC as my alternate DNS on my Windows 7 box fixed the problem.
Update
Turns out this is not sufficient. Still get this &^%&^% problem.
Start / Control Panel / Network and Internet / Network and Sharing Centre
On LHS at top / Change Adapter Settings
Right click / Disable
You will lose your network connection!!!
Right click / Enable
All will be well until you reset your PC and then you will have the joy of doing it all again.
Use at own risk but works for me.
Enjoy!
Wednesday, November 12, 2014
stackoverflow: Writing the perfect question
I've blogged on this before but it bears repeating.
cf Jon Skeet: Writing the perfect question.
There was a question on SO that's a perfect example.
"How do I achieve SSO with site a, site b, WIF and SAML and STS"?
Is site a /b .NET / Java / ...?
What flavour STS?
WIF and SAML are mutually incompatible, Explain.
Are site a / b in different domains? With different identity repositories? If so, what repositories are these? AD or ...?
And so on.
In my experience, the quality of the answer correlates with the quality of the question.
Yeah - I get that people are leaving out important details because they don't really understand the environment.
If so, Google other questions. What details do they supply?
If you want to be noticed in the vast list of SO questions, you have to put some effort in.
Make me want to help you by answering!
Enjoy!
cf Jon Skeet: Writing the perfect question.
There was a question on SO that's a perfect example.
"How do I achieve SSO with site a, site b, WIF and SAML and STS"?
Is site a /b .NET / Java / ...?
What flavour STS?
WIF and SAML are mutually incompatible, Explain.
Are site a / b in different domains? With different identity repositories? If so, what repositories are these? AD or ...?
And so on.
In my experience, the quality of the answer correlates with the quality of the question.
Yeah - I get that people are leaving out important details because they don't really understand the environment.
If so, Google other questions. What details do they supply?
If you want to be noticed in the vast list of SO questions, you have to put some effort in.
Make me want to help you by answering!
Enjoy!
IdentityServer: two different WS-Fed endpoints
So I've been using thinktecture's IdentityServer for a project.
First off - it's a damn good product - but then you have two top class MVP's working on it!
I'm using V2.
I'm using it in two modes:
As an IDP against the SQL Server DB
As a R-STS - effectively a broker that just passes on the traffic.
Normally these are the same endpoint e.g. ADFS.
But I was battling until I realised that there are actually TWO WS-Fed endpoints.
My bad - it's obvious when you see the metadata list.
So /issue/wsfed works for the IDP and /issue/hrd works for the R-STS. As the name implies, this brings up the HRD screen.
If you look at the two controllers, the code (as you would expect) is pretty similar and they both share the same WSFederationResult.
Enjoy!
First off - it's a damn good product - but then you have two top class MVP's working on it!
I'm using V2.
I'm using it in two modes:
As an IDP against the SQL Server DB
As a R-STS - effectively a broker that just passes on the traffic.
Normally these are the same endpoint e.g. ADFS.
But I was battling until I realised that there are actually TWO WS-Fed endpoints.
My bad - it's obvious when you see the metadata list.
So /issue/wsfed works for the IDP and /issue/hrd works for the R-STS. As the name implies, this brings up the HRD screen.
If you look at the two controllers, the code (as you would expect) is pretty similar and they both share the same WSFederationResult.
Enjoy!
Thursday, November 06, 2014
Windows Server: Where's the drive mapping?
Needed to map a drive on Server 2012 R2 to load some media so:
Start - right click "This PC" - check "Map network drive"
Than map to G: e.g.
Into command prompt with run as administrator set - type "G:" - no such drive - WTF? - I can see the mapping in File Explorer!
Turns out you have to do an extra step i.e.
net use g: \\"mapping path" password /user:domain\user /p:no
where:
g: = drive to map
mapping path = path to media
password = your password
/user:domain\user = your domain and user
/p:no = don't persist mapping across logins
Job done.
I suspect this will work on Windows 8 as well.
Enjoy!
Start - right click "This PC" - check "Map network drive"
Than map to G: e.g.
Into command prompt with run as administrator set - type "G:" - no such drive - WTF? - I can see the mapping in File Explorer!
Turns out you have to do an extra step i.e.
net use g: \\"mapping path" password /user:domain\user /p:no
where:
g: = drive to map
mapping path = path to media
password = your password
/user:domain\user = your domain and user
/p:no = don't persist mapping across logins
Job done.
I suspect this will work on Windows 8 as well.
Enjoy!
Wednesday, October 01, 2014
ADFS : ADFS 3.0 - no web.config
I've blogged before about the changes in ADFS 3.0 on Server 2012 R2.
No IIS so no web.config.
Hang on - what about things like:
They are no longer there.
The trick is to use PowerShell: (Thanks @paullem!)
Set-AdfsWebConfig
e.g.
Set-AdfsWebConfig -ContextCookieEnabled $True -HRDCookieEnabled $True -HRDCookieLifetime 30
Enjoy!
No IIS so no web.config.
Hang on - what about things like:
<context hidden="true" /> <error page="Error.aspx" /> <acceptedFederationProtocols saml="true" wsFederation="true" /> <homeRealmDiscovery page="HomeRealmDiscovery.aspx" /> <persistIdentityProviderInformation enabled="true" lifetimeInDays="30" />
They are no longer there.
The trick is to use PowerShell: (Thanks @paullem!)
Set-AdfsWebConfig
e.g.
Set-AdfsWebConfig -ContextCookieEnabled $True -HRDCookieEnabled $True -HRDCookieLifetime 30
Enjoy!
Wednesday, September 24, 2014
Misc : Popular posts
There is a little widget that's supposed to do this but here are the actual statistics.
Notice the number of ADFS hits!
Enjoy!
Notice the number of ADFS hits!
Enjoy!
Misc : GitHub for Windows - Clone in Desktop
GitHub for Windows is a neat tool but suffers from a severe lack of documentation.
I find a project I like, click "Clone in Desktop" on the RHS and it takes me to a screen saying "Download GitHub for Windows" even though I have the damn thing already installed.
So ^^%$$% frustrating.
Mr. Google to the rescue and after a number of false starts (Google sucks more and more at delivering useful search results) I discovered that you need to log-in first on the GitHub site.
Then all is OK.
Going by the number of hits I found on this, 99% of this would be avoided if GitHub put a notice to that effect on the page e.g.
"You must first Login".
Enjoy!
I find a project I like, click "Clone in Desktop" on the RHS and it takes me to a screen saying "Download GitHub for Windows" even though I have the damn thing already installed.
So ^^%$$% frustrating.
Mr. Google to the rescue and after a number of false starts (Google sucks more and more at delivering useful search results) I discovered that you need to log-in first on the GitHub site.
Then all is OK.
Going by the number of hits I found on this, 99% of this would be avoided if GitHub put a notice to that effect on the page e.g.
"You must first Login".
Enjoy!
Tuesday, September 23, 2014
ADFS : The joys of hidden context
Playing around with ADFS 3.0 on Server 2012 R2 and found yet another difference with ADFS 2.x.
Imagine you have a number of .NET applications going via ADFS as a RP-STS going to another IP-STS.
Now on the IP-STS you want to know which RP the authentication request is coming from.
All the ADFS requests are coming through one channel so parameters like "Referer: " are useless.
In your RP web.config you can add a parameter like wreply or wtrealm as per wsFederation.
You'll see these in the URL going to ADFS in the &wctx section. But there's nothing going to the IP-STS. ADFS "removes" them. Instead there is a &wctx which is a GUID.
And there is a cookie on the way which looks like:
In ADFS 2.0, there was an entry in the web.config which told ADFS not to encode this information in a cookie but to send it as part of the query string - which makes for a lll-oon-nnn-ggg query string!
This entry was:
context hidden="true"
C:\Windows\ADFS
and there's a file called:
Microsoft.IdentityServer.Servicehost.exe.config
but it has no such entry.
The trick is to use PowerShell:
Set-AdfsWebConfig -ContextCookieEnabled $False
Enjoy!
Imagine you have a number of .NET applications going via ADFS as a RP-STS going to another IP-STS.
Now on the IP-STS you want to know which RP the authentication request is coming from.
All the ADFS requests are coming through one channel so parameters like "Referer: " are useless.
In your RP web.config you can add a parameter like wreply or wtrealm as per wsFederation.
You'll see these in the URL going to ADFS in the &wctx section. But there's nothing going to the IP-STS. ADFS "removes" them. Instead there is a &wctx which is a GUID.
And there is a cookie on the way which looks like:
MSISContextc1da81dd-46b6-4cee-b051-9c0e7a298527=xxxyyy==
where xxxyyy is Base64 encoded.
In ADFS 2.0, there was an entry in the web.config which told ADFS not to encode this information in a cookie but to send it as part of the query string - which makes for a lll-oon-nnn-ggg query string!
This entry was:
context hidden="true"
ADFSBut in ADFS 3.0 there is no actual web.config, You have to look in:
C:\Windows\ADFS
and there's a file called:
Microsoft.IdentityServer.Servicehost.exe.config
but it has no such entry.
The trick is to use PowerShell:
Set-AdfsWebConfig -ContextCookieEnabled $False
Enjoy!
Friday, August 08, 2014
ADFS : Certificate details in the metadata
Common problem - you get sent some metadata that contains certificate info. and then get an error when you try and import it.
Would be really useful to see the actual certificate, right?
Good news is that help is at hand.
In the metadata file, you'll see something like:
Copy it - the stuff between the open and closing ds:X509Certificate tag.
Now paste that into an editor - Notepad++ is my poison of choice.
Then save that as a .cer file.
Now double-click on the file in Explorer.
Job done!
Enjoy!
Would be really useful to see the actual certificate, right?
Good news is that help is at hand.
In the metadata file, you'll see something like:
Then there's the actual certificate info. which is in Base64.<KeyDescriptor use="signing"> <ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> <ds:X509Data> <ds:X509Certificate>
Copy it - the stuff between the open and closing ds:X509Certificate tag.
Now paste that into an editor - Notepad++ is my poison of choice.
Then save that as a .cer file.
Now double-click on the file in Explorer.
Job done!
Enjoy!
Wednesday, July 23, 2014
stackoverflow : 500 answers
Finally hit the mark.
If you calculate that I try to answer one question every day and 5 weekdays per week, then:
500 / 5 = 100 weeks ~ 2 years to get here!
Actually, it's taken almost 6 years.
Can do better!
Enjoy!
If you calculate that I try to answer one question every day and 5 weekdays per week, then:
500 / 5 = 100 weeks ~ 2 years to get here!
Actually, it's taken almost 6 years.
Can do better!
Enjoy!
Monday, July 21, 2014
SAML : I want to test my code
This question pops up frequently on the forums.
"I have written my own custom IDP / SP. How can I test it against some instance that's publicly available?"
There are a range of commercial products e.g. Tivoli, Oracle, Ping Identity. OpenAM which all deliver this functionality but they are complex to set up and are most certainly not free.
If you work in the Microsoft world and have a "spare" Windows server that's domain joined you can use ADFS. This runs on 2008 R2, 2012 and 2012 R2 and supports both IDP and SP mode.
Open source:
* Shibboleth
* and also Testshib
* simpleSAMLphp
Both these support IDP and SP mode.
Others:
* SSOCircle - IDP only
* Kentor - IDP only
* Feide OpenIDP - IDP only
* Salesforce developer - (IDP / SP)
Beware: These are often simplified and some security checks have been removed so the fact that your code works in these environments does not ensure that they will work in the real world.
There are also some commercial / open source implementations for SAML stacks. These often have test IDP and SP that you can run up for basic testing.
* ComponentSpace is one example.
* onelogin SAML Toolkits - open source
There are others.
Enjoy!
"I have written my own custom IDP / SP. How can I test it against some instance that's publicly available?"
There are a range of commercial products e.g. Tivoli, Oracle, Ping Identity. OpenAM which all deliver this functionality but they are complex to set up and are most certainly not free.
If you work in the Microsoft world and have a "spare" Windows server that's domain joined you can use ADFS. This runs on 2008 R2, 2012 and 2012 R2 and supports both IDP and SP mode.
Open source:
* Shibboleth
* and also Testshib
* simpleSAMLphp
Both these support IDP and SP mode.
Others:
* SSOCircle - IDP only
* Kentor - IDP only
* Feide OpenIDP - IDP only
* Salesforce developer - (IDP / SP)
Beware: These are often simplified and some security checks have been removed so the fact that your code works in these environments does not ensure that they will work in the real world.
There are also some commercial / open source implementations for SAML stacks. These often have test IDP and SP that you can run up for basic testing.
* ComponentSpace is one example.
* onelogin SAML Toolkits - open source
There are others.
Enjoy!
Subscribe to:
Posts (Atom)
