Posted by: HeadFried - Thursday, 12 December 2013 16:58:34
We have set up the YAF forum and it is working fine, we have this on a subdomain.
forum.oursite.com
We also have a custom made site we've have built using MVC 4.
www.oursite,com
We've added a Content table to the YAF database, our main site is pulling content from this database.
[b]We need to now, secure the content on our main MVC site, users must login to view it.[/b]
We want to put a login on our MVC site in order to authenticate the users, once authenticated they will then be able to view our content. We want them to use the YAF_User table.
Is there a tutorial or a sample project I can download to help me out?
Has anyone any ideas?
Posted by: Jaben - Friday, 13 December 2013 02:40:13
You need the same machine key on the both sites and both sites need the same authentication cookie. Also, the domain setting for the auth cookie has to be set properly:
[code]
[/code]
Notice the domain key with the ".yetanotherforum.net" -- that authentication will work for ALL yetanotherforum.net domains... so www.yetanotherforum.net, forum.yetanotherforum.net, wiki.yetanotherforum.net and yetanotherforum.net.
That's the single most important trick to doing single sign on authentication for a whole site. Good luck.
Posted by: HeadFried - Monday, 16 December 2013 17:25:14
[quote=Jaben;62168]You need the same machine key on the both sites and both sites need the same authentication cookie. Also, the domain setting for the auth cookie has to be set properly:
[code]
[/code]
Notice the domain key with the ".yetanotherforum.net" -- that authentication will work for ALL yetanotherforum.net domains... so www.yetanotherforum.net, forum.yetanotherforum.net, wiki.yetanotherforum.net and yetanotherforum.net.
That's the single most important trick to doing single sign on authentication for a whole site. Good luck.[/quote]
Thanks for this, but we're still very stuck.
Does anybody have an example of their account controller for an MVC 4 project were they have managed to authenticate a user from the YAF database?
Posted by: Jaben - Monday, 16 December 2013 18:42:31
Which provider are you using? It's not "YAF.NET's database" -- it's called Forms Authentication and YAF is a slave to it. Both MVC and YAF.NET use the same provider. That is the easy part. The hard part is getting single sign on working across sub domains.
Seems your stuck on the abstraction... which seems to be a big problem with understanding Forms Authentication. YAF.NET does not provide the authentication -- ASP.NET does. When you start to think in terms that concept -- it should be easier to understand. The only thing required is that the settings are all the same.
Posted by: HeadFried - Tuesday, 17 December 2013 17:06:41
[quote=Jaben;62208]Which provider are you using? It's not "YAF.NET's database" -- it's called Forms Authentication and YAF is a slave to it. Both MVC and YAF.NET use the same provider. That is the easy part. The hard part is getting single sign on working across sub domains.
Seems your stuck on the abstraction... which seems to be a big problem with understanding Forms Authentication. YAF.NET does not provide the authentication -- ASP.NET does. When you start to think in terms that concept -- it should be easier to understand. The only thing required is that the settings are all the same.[/quote]
Jaben,
Thanks for your help with this.
I've created an ASP.Net web application, updated the web.config to point to the YAF database, ive added references to the YAF dlls, the project loads and I can login...happy days.
I've then created a simple MVC 3 project updated the webConfig etc...ran the project.....and I can login again...happy days.
Now...
I am trying to create an MVC 4 project, and it wont run as MVC 4 does not use the same provider, rafter a bit of googling Ive realised that MVC 4 is using SimpleMemberShipProvider, im not sure if there is a way round this?
What would be great is a sample MVC 4 project that works with the YAF database....or even just the web config file and account controller!
Thanks again for your help with this, we love the forum!
Posted by: Jaben - Tuesday, 17 December 2013 17:35:53
You should still be able to use YAF.NET providers for MVC4 project. Yes, the default is the simple providers... but just replace with YAF.NET providers and ... viola, working login.
... Glad you like the forum ;)
Also, FYI, you don't have to use YAF.NET providers with YAF. You can use any membership provider -- including "SimpleMembershipProvider" or any other provider.
Posted by: JP - Monday, 6 January 2014 19:58:48
I run an MVC4 site with the YAF Membership provider. However, the forum is a losely integrated part of the site on the same site address in a subfolder..
What I have done is to use the same static machine key for both in the web.config.
All logins handled by the YAF login, not using the MVC4 AccountController at all...