How to Authenticate .NET MVC on iFrame - iframe

I am not experienced in .NET authentication, and haven't found a specific answer for this need.
I am developing a .NET Core 2.1 MVC app which will have to run on an iframe on a different .NET Framework 4.5.1 app, which uses a FormsAuthenticationTicket when authenticating users. I have access to the main app's code, but cannot change it.
The present requirement is to automatically authenticate the iframe app, which I am developing, automatically from the main app's cookie information. On my app the login uses ASP.NET boilerplate (Abp) users and login, and the database contains the same usernames that will be using from the main app's database (different databases, same username field).
I currently haven't been able to decrypt the cookie or find a way to configure the iframe app to support this, and would appreciate if someone would kindly steer me in the right direction.

Related

How To: Redirect from MVC .NET website to MVC .NET Core subsite without user having to 'relog'

I have a MVC ASP.NET site that uses a database lookup for user authentication and then stores authentication variables in cookies.
I want to redirect the user to a MVC ASP.NET Core subsite without the user losing his authentication variables.
I am not able to share cookies between the two sites due to different encryption-schemes.
Both sites are hosted on the same domain on a windows server (IIS). Is there any way to securely transfer data along with the url redirect?
Is there some obvious solution that i am missing?
Please let me know if you need additional information about the project.
As a temporary solution, the user is promted for a new login once he is redirected to the subsite. I wish to avoid this.
You can not share data from MVC web app to MVC core web app. That is because it is hard to do.
But, there is a way to share the authentication mechanism. You can have an identity provider which will be responsible for authentication of users in both the sites. The login functionality will be in the identity server. Once a user is logged in, both your sites will use those authentication data.

AngularJS ASP .Net MVC login

I have various AngularJS single page applications running in a single ASP .net MVC project.
In one of my AngularJS SPA's I need to create a login page which would show then show another page of information when successfully logged in. The username and passwords are stored in a database.
I am very new to ASP .net and would like some advice on the best way to (using my angular form) login and have some kind of session cookie so the user remains logged in for the duration of their session.
If you build SPA you with high probability use WebAPI. Reccomended way to authenticate API user is slightly different than usual cookie authentification.
To see how it works create a new project. If you have last VS2015 go to file -> New project -> ASP.NET Web Application -> Web API (Authentification: Individual UserAccounts).
If you just return Json(someData) in your MVC contollers and already have authentification it should work fine on tradition cookie authentification.

OAuth User Registration - ASP.Net 4.5

I'm currently in the beginning stages of developing a website using ASP.Net 4.5 and C#. I'm wanting to map out the process flow of user registration and authentication. There's a starter project that uses the WebSecurity framework - with Simple Membership - that includes OAuth integration, allowing users to use Facebook and other logins to access the site.
What special considerations must one consider when using external logins on their website?
--Specialty login and registration pages for each provider used
--Authentication checks -- making sure application access hasn't been revoked during the course of any logged in session
--Re-Authentication screens
--Merging accounts
I'm seeing a bunch of different posts on how to set up ASP.Net and the WebSecurity framework to accept different logins, but not so many on the considerations needed before implementing such functionality
EDIT: This is an MVC site. Updated post to correct this

SSO between ASP.Net and JSP

I built an ASP.Net MVC 4 application which uses forms authentication by means of a custom membership provider inheriting from the Simple Membership.
Everything is working fine, but now I have a new requirement: I need to integrate a JSP application with mine.
This means that it has to authenticate against the same user database of my application and that they should somehow share the session in order to achieve a kind of Single Sign-On among the two applications (if an user is already authenticated in the ASP.Net application, he should be able to access the JSP application without logging in again, and vice-versa).
What architecture do you suggest me to use?
I would like to change as little as possible the ASP.Net application.
Thanks!
If you need to auhtenticate accross different domains:
You can implement your own security token service (like facebook, google does) Here is some ready to use implementation: http://thinktecture.github.io/Thinktecture.IdentityServer.v2/
If the sites are running on the same domain (subdomain), then you can try to share an authentication cookie within these domains.
An explaining article: http://www.codeproject.com/Articles/106439/Single-Sign-On-SSO-for-cross-domain-ASP-NET-applic

Shared Authentication, Membership & Roles across DNN and ASP.net applications

Here's my situation. I have a DotNetNuke application. I want to link to an existing ASP.net website from within the DNN website, and have decided to use DNN's IFrame for that.
The existing ASP.net application uses Forms Authentication for security - only authorized users can access the pages. This asp.net application also requires user roles for authorization to different pages.
I don't want users to have to sign on twice, and I'd like the asp.net page to use the user membership and role data from the DNN application - it shouldn't require it's own membership database.
Is this possible? According to the MSDN website:
"ASP.NET supports forms authentication in a distributed environment, either across applications on a single server or in a Web farm. When forms authentication is enabled across multiple ASP.NET applications, users are not required to re-authenticate when switching between the applications."
Does this apply to DotNetNuke applications linking to asp.net applications? Both are on the same domain, too.
(I tried modifying the config.web of the asp.net page to work with the DNN config.web, matching machine keys and forms settings - but it didn't work. I could be doing something wrong, but before I pursue, I want to know if it's even possible.)
Thanks for any help!
I don't know if what you're talking about is possible within DNN. We're on DNN 4.0 and they do some weird things with the ASP.NET membership tables which may cause trouble.
What I can tell you is an alternative way (assuming you have control over the ASP.NET application). There is a project called MADAM (Mixed Authentication Disposition ASP.NET Modules - I know a bit of a mouthful) that can be used to provide a method other than forms authentication for application logon.
What you could do is set MADAM up on your ASP.NET application and from DNN pass user credentials to the ASP.NET application. The end result appears to the user as single sign on.
If you need me to elaborate on anything, let me know in the comments.
Actually i am displaying some aspx pages in a iframe module present on a dnn page. Now since inside the iFrame i am displaying aspx pages hosted elsewhere but on same server. I am just want to authenticate the dnn logged-in user before loading the page inside iFrame.
Do dnn provide any API which i can call from apsx pages hosted elsewhere in order to restrict access to ony unauthorized user.

Resources