Hello,
Thanks for getting back to me. You're absolutely correct WRT: OAuth and WS-Federation I had somewhat confused myself by adding the federated authorization service. This is totally redundant as we can talk OAuth directly to ACS. For example, If you modify
the sample as follows you do not require the AuthorizationServer (or the federated Auth service I added ;-)) to get an SWT token back from ACS.
public const string EndUserLoginUrl = "https://{YOUR SERVICE NAMESPACE HERE}.accesscontrol.appfabriclabs.com/v2/wsfederation?wa=wsignin1.0&wtrealm={YOUR REALM URL HERE}&wctx=rm=0&id=passive&ru=/WebClient/Default.aspx?response_type=code&redirect_uri=https://localhost/WebClient/Default.aspx";
However if you do this then for some reason the OAuthClientSettings events I alluded earlier do not get invoked. I was wondering if this had anything to do with the behaviour of the OAuthHandler?
<handlers>
<add name="OAuthHandler" verb="*" path="OAuthHandler.ashx" type="Microsoft.IdentityModel.Protocols.OAuth.Client.EndUserAuthorizationResponseHandler, Microsoft.IdentityModel.Protocols.OAuth"/>
</handlers>
In any case I have been able to achieve the passive federation outlined in my original post without using the majority of Microsoft.IdentityModel.Protocols.OAuth. My only real concern relates to using a custom RequestValidator with the following web configuration.
<location path="Default.aspx">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
<system.web>
<httpRuntime requestValidationMode="4.0" requestValidationType="{MY CUSTOM VALIDATOR}"/>
<authentication mode="None" />
</system.web>
I have completely stripped out the Microsoft.IdentityModel.Protocols.OAuth infrastructure from Global.aspx and Default.aspx now looks something like this
protected void Page_Load( object sender, EventArgs e )
{
OAuthCredential creds = GetOAuthCredential(); // as in 1.4 sample
if (creds != null)
{
// redirect to protected resource - a xap file
}
else
{
// redirect to ACS using a URL similar to the above
}
}
I had wanted to add the following to <system.web> however when I do so
<authorization>
<deny users="?" />
</authorization>
I get the following...
Access is denied.
Description: An error occurred while accessing the resources required to serve this request. The server may not be configured for access to the requested URL.
Error message 401.2.: Unauthorized: Logon failed due to server configuration.
Verify that you have permission to view this directory or page based on the credentials you supplied and the authentication methods enabled on the Web server.
Contact the Web server's administrator for additional assistance.
As you would expect from the above the User Identity is set to an un-authenticated GenericPrincipal. I'm not sure of the best way to fix this. I could construct a
ClaimsPrincipal in RequestValidator but this feels wrong. From a WIF best practice point of view what should I be doing? Introducing a custom Module to take care of this? I know, I know
RTFM ;-) any pointers as to the best place to start would be appreciated.
Regards
Don