How to Protect Only Certain Parts of a Web Site using the Federated Authentication Module - single-sign-on

I want to Integrate Windows Identity Framework(WIF) For SSO, Federated Authentication Module of WIF is triggering on every Page of Website sends user to Signin Pgae i want on Some Page of My Website it did not apply Authentication.

You can add the bellow to the web.config and it will allow all users to access the location.
<location path="Default.aspx">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
In the example above I allow all users to access Default.aspx page.
Hope this helps.

Related

Securing a Rest-API integrated in Custom policy in Azure AD b2c issue

I have a rest api which is being called by Azure AD B2C(through technical profile in Custom policy).
I need to secure the api.But as it is being called by Azure BEFORE Authentication(basically it only needs to check if the email already exists in database or not in sign in flow), it doesn't have Authorize attribute.
I have ClientCertificate AuthenticationType, configured in the custom policy for this REST API in the metadata of the technical profile, following this document
https://learn.microsoft.com/en-us/azure/active-directory-b2c/secure-rest-api
So basically my metadata looks like this:
<Metadata>
<Item Key="ServiceUrl">https://your-account.azurewebsites.net/api/GetProfile?code=your-code</Item>
<Item Key="SendClaimsIn">Body</Item>
<Item Key="AuthenticationType">ClientCertificate</Item>
<Item Key="AllowInsecureAuthInProduction">false</Item>
</Metadata>
<CryptographicKeys>
<Key Id="ClientCertificate" StorageReferenceId="B2C_1A_RestApiClientCertificate" />
</CryptographicKeys>
But when I call the rest api from the browser, it is still accessible.
I am not sure if I missed something, but isn't this process supposed to secure your api so only Azure can call it?
The REST API mutually needs to be authenticated with the client certificate. Configuration Client certificate in the custom policy needs to be validated near the REST API also right.
You can secure back-end services using client certificate authentication in Azure API Management or you can configure client certificate authentication in the code

Sustainsys using Salesforce as IdP for multiple communities

I am using Salesforce as an IdP for my MVC app. I have multiple communities in my Salesforce instance each with a different signOnUrl. How do I configure multiple communities to use the same Sustainsys Identity Provider?
I have tried using the same community link for the different communities, that gives a privileges error. I've tried setting multiple Identity provider nodes for the different community signOnUrls but it hasn't worked
<identityProviders>
<add entityId="https://{Salesforce}" signOnUrl="https://{Salesforce}/{community1}/idp/login?app={appId}" allowUnsolicitedAuthnResponse="true" binding="HttpRedirect">
<signingCertificate fileName="~/App_Data/{cert}.crt" />
</add>
<add entityId="https://{Salesforce}" signOnUrl="https://{Salesforce}/{community2}/idp/login?app={appId}" allowUnsolicitedAuthnResponse="true" binding="HttpRedirect">
<signingCertificate fileName="~/App_Data/{cert}.crt" />
</add>
</identityProviders>
When I try adding multiple entity providers to the same server the error is The entry https://{Salesforce} has already been added.
Found the answer... instead of adding multiple identity providers with different signOnUrl parameters. You can add multiple signOnUrls in the same node.
<identityProviders>
<add entityId="https://{Salesforce}" signOnUrl="https://{Salesforce}/{community1}/idp/login?app={appId}*;https://{Salesforce}/{community2}/idp/login?app={appId}*" allowUnsolicitedAuthnResponse="true" binding="HttpRedirect">
<signingCertificate fileName="~/App_Data/{cert}.crt">
</add>
</identityProviders>
If you are using owin or asp.net core, a better approach is probably to register one authentication scheme for each Salesforce community. This will make your application work as two virtual service providers to Salesforce, one for each community.
When registering the SAML2 middleware/handler twice, you need to ensure that each instans has a unique EntityId and a unique ModulePath.

Keycloak/mod_auth_openidc under reverse proxy

I have a landing page for my openid which will redirect to Keycloak if not yet authorized, then will redirect to my landing page once verified.
I used my keycloak server under a Apache mod_proxy.
The configuration is successful. Now, my problem is that even though my applications (Gitbucket and Jenkins) use the same realm for my mod_auth_openidc, I still need to login for the applications (SSO setup) even though I was already verified when accessing my landing page. Please see image on the link: https://ibb.co/VND01SY
!https://ibb.co/VND01SY
DocumentRoot "/var/www/html"
DirectoryIndex index.html index. cgi index.php index.shtml
<Proxy "balancer://apache_mod_proxy">
BalancerMember "http://192.168.122.125:8080"
</Proxy>
ProxyPreserveHost On
ProxyPass "/auth/" "balancer://apache_mod_proxy/auth/"
ProxyPassReverse "/auth/" "balancer://apache_mod_proxy/auth/"
OIDCProviderMetadataURL "http://192.168.122.103/auth/realms/ci/.well-known/openid-configuration"
OIDCClientID "apache24"
OIDCClientName "apache24"
OIDCClientSecret "cc251291-9254-42ef-8073-6f5b396f73cc"
OIDCScope "openid email profile"
OIDCProviderTokenEndPointAuth "client_secret_basic"
OIDCRedirectURI http://192.168.122.103/test/redirect_uri
OIDCCryptoPassphrase 0123456789
OIDCRemoteUserClaim "preferred_username"
<Location /test>
AuthType openid-connect
Require valid-user
</Location>
^This is my current configurations.
My expected output should be:
If not yet verified by Keycloak:
1. Access index.html -> redirect to Keycloak if first time to login
2. Redirect to index.html after verification (this contains links to Jenkins and Gitbucket)
3. When link for applications are clicked, I dont need to relogin for the same realm.
Please correct me if my understanding for the scenario is correct.
I also dont know how to use logout and where to put logout for the landing page and SSO.
SSO to Jenkins and Gitbucket depends on how these applications are configured to recognize the user. They should be configured to depend on headers set by the reverse proxy running mod_auth_openidc in front of it.

Kentor AuthService - Redirect to IDP from Browser URL

In our ASP.Net project, I am using 'Kentor.AuthServices' as SAML2 Authentication Service. For testing purpose, I am using 'Kentor.AuthServices.StubIDP'.
Currently we gave an anchor tag in the page with href as:
href=#Url.Content("~/AuthServices/SignIn?idp=" + entityId)
This works perfectly fine and once we click the anchor tag, it gets redirected to Identity Provider:
http://localhost:17009//SamplePath/AuthServices/SignIn?idp=http://stubidp.kentor.se/Metadata
But what we need to achieve is without using the anchor tag,where we directly enter our site URL address in the browser, it should automatically redirect to Identity Provider.
When using the HttpModule, you use the forms authentication setup in the web.config to cause unauthenticated requests to be redirected to the sign in sequence.
<authentication mode="Forms">
<forms loginUrl="~/AuthServices/SignIn"></forms>
</authentication>

Setting up website with separate app in virtual directory Asp.Net Forms authentication

I have an Asp.net MVC Website using Forms authentication.
The site is hosted in IIS using Forms Auth and works fine.
Due to a number of reasons, I want to know if it is possible to do the following:
I want to create a Virtual Directory underneath the main website, a separate application, and secure it using Forms Authentication as well.
The main site, and the site in the child Virtual Directory will be separate applications, and the Forms Auth will be completely independent of each other, and using different databases.
Is it possible to set up in this way?
Forms authentication works by using cookies. So as long as you provide different authentication cookie names for both sites they will be independent.
<authentication mode="Forms">
<forms name=".Auth1" />
</authentication>
But the problem AFAIK is that the <authentication mode="Forms"> tag cannot be redefined in sub web.config files.