Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Integrating Custom User System
bluisana
#1 Posted : Thursday, 15 April 2010 12:12:40 PM(UTC)
Rank: Member

Joined: 15/04/2010(UTC)
Posts: 26
Location: Raleigh

Hello Roger,

I am planning to integrate your gallery into a custom CMS that I have designed. The CMS already has a complete user system that is similar to the membership classes but it is completely custom.

I am planning to disable all of the user management features in the gallery and pass the logged in user info to the gallery.

I starting stepping through all of the source code to find the login points. After spending a fair amount of time going through everything I thought I should post on here for some suggestions before making changes.

Do you have any suggestions about how to pass the user info to the gallery.

Thanks for your help

Roger Martin
#2 Posted : Thursday, 15 April 2010 1:48:52 PM(UTC)
Roger Martin

Rank: Administration

Joined: 3/08/2007(UTC)
Posts: 3,300
Location: Fort Atkinson, WI

There are a number of ways to do it. Here is one:

1. Create a new web service in gs\services\Gallery.asmx called LogOnUser where you pass a username. Pay attention to security so that not just anyone can call it (not sure how you'd do this).

2. Inside the body of this web service, call UserController.LogOnUser()

3. After invoking the web service, redirect the user to the gallery.

If you have trouble with that or can't resolve the security challenge, another approach is to create a new .aspx page where you pass the user info and - in it's code behind - it calls UserController.LogOnUser() and then redirects to the gallery.

You will need some type of membership provider configured or else GSP won't run. You can create a new one that implements the MembershipProvider class but only fleshes out the minimum number of methods to work. Take a look at SQLiteMembershipProvider for an example.

Good luck,
Roger Martin
Creator and Lead Developer of Gallery Server Pro
bluisana
#3 Posted : Friday, 16 April 2010 5:26:09 AM(UTC)
Rank: Member

Joined: 15/04/2010(UTC)
Posts: 26
Location: Raleigh

Thanks so much,

I was planning to do something much more complicated. It is pretty easy to securely encrypt webserice communications. I will also make sure that only logged in users can access the web service. I will post the code here in case anyone else wants to use it or if you want to include it in a future release.

Bryan
bluisana
#4 Posted : Tuesday, 27 April 2010 12:31:41 AM(UTC)
Rank: Member

Joined: 15/04/2010(UTC)
Posts: 26
Location: Raleigh

Hello Roger,

I have just finished building my custom membership provider. What is the easiest way to pass it to the gallery on login?
Roger Martin
#5 Posted : Tuesday, 27 April 2010 1:31:44 AM(UTC)
Roger Martin

Rank: Administration

Joined: 3/08/2007(UTC)
Posts: 3,300
Location: Fort Atkinson, WI

Try one of the ways I described in my first reply. Pick the one that sounds easiest to you.
Roger Martin
Creator and Lead Developer of Gallery Server Pro
bluisana
#6 Posted : Tuesday, 27 April 2010 12:52:21 PM(UTC)
Rank: Member

Joined: 15/04/2010(UTC)
Posts: 26
Location: Raleigh

Your logon method from above just accepts username not the full membership provider. I can easily create the new webservice method to call this logon method but how do I pass the actual full membership provider to the gallery in addition to calling this logon method?
Roger Martin
#7 Posted : Tuesday, 27 April 2010 12:58:01 PM(UTC)
Roger Martin

Rank: Administration

Joined: 3/08/2007(UTC)
Posts: 3,300
Location: Fort Atkinson, WI

The membership provider is defined in the web.config file. Replace the existing definition with yours and then make sure your membership dll is in the bin directory.
Roger Martin
Creator and Lead Developer of Gallery Server Pro
bluisana
#8 Posted : Tuesday, 27 April 2010 2:11:56 PM(UTC)
Rank: Member

Joined: 15/04/2010(UTC)
Posts: 26
Location: Raleigh

I was naively thinking that I could populate a membershipuser from my custom provider class and pass it to the Gallery. After looking at your existing code it looks like I am going to have to implement most of the membership methods fully. I also noticed that you have a role manager and profile provider that use membership providers. Do these providers use the standard provider methods?

After looking at all of this I am wondering if I should start over using your sqllite provider as a template.

Roger Martin
#9 Posted : Wednesday, 28 April 2010 12:24:27 AM(UTC)
Roger Martin

Rank: Administration

Joined: 3/08/2007(UTC)
Posts: 3,300
Location: Fort Atkinson, WI

Yeah, your idea won't work. You need to create a new membership *provider*, but it's not as scary as it sounds. You only have to implement the methods that GSP uses; leave the others empty. For example, if you won't be creating users in GSP, you don't need to implement the CreateUser method (just use an empty method body and return null).

One of the most important you will need to implement is the GetUser function.

I don't understand your question about "standard provider methods".

I advise making a copy of the SQLite membership provider class and modifying it to suit your needs. Start by deleting the contents of all override methods except the GetUser one (the one with this signature: public override MembershipUser GetUser(string username, bool userIsOnline)). Modify GetUser for your situation and start experimenting.

If you will be using GSP for reading membership rather than updating it, that might be just about all you need.
Roger Martin
Creator and Lead Developer of Gallery Server Pro
bluisana
#10 Posted : Monday, 3 May 2010 1:12:15 AM(UTC)
Rank: Member

Joined: 15/04/2010(UTC)
Posts: 26
Location: Raleigh

Hey Roger,

I am finally getting back to this today. I basically just copied the entire sqllite project and starting changing everything to use my usermanager through the membershipprovider methods.

In your web config you have sections defined for the sqllite provider and regular sql provider. I just added my new provider in the membership, role, and profile provider. Everything is compiling and I am just working through each error one at a time.

Should I just comment out the internal GaleryPro providers (sqllite, and sql) from the web.config?

Does it seem like I am going about this the correct way. This is a pretty serious integration.

Thanks
bluisana
#11 Posted : Monday, 3 May 2010 6:55:27 AM(UTC)
Rank: Member

Joined: 15/04/2010(UTC)
Posts: 26
Location: Raleigh

Roger,

I have my membership provider and logonuser webmethod setup and compiling. It doesn't seem like calling the UserController.LogOnUser(username) initiates the membership providers getuser method. The logonuser method goes through succesfully but GalleryPage.IsAnonymousUser user is still true and breakpoints within the getuser method of my custom provider never get hit. Is there a way to force this to happen or am I still missing something?

Thanks,

Bryan
Roger Martin
#12 Posted : Tuesday, 4 May 2010 2:02:21 AM(UTC)
Roger Martin

Rank: Administration

Joined: 3/08/2007(UTC)
Posts: 3,300
Location: Fort Atkinson, WI

The LogOnUser does not authenticate the user; it assumes some other code has already done that. All it does it take care of some housekeeping such as setting the authentication cookie and assigning Util.IsAuthenticated = true. However, the LogOnUser function *should* cause GalleryPage.IsAnonymousUser to be false since that property merely returns the opposite of the Util.IsAuthenticated property. In other words, if LogOnUser is successful, then GalleryPage.IsAnonymousUser should always return false. You may want to step through the code to see why this doesn't seem to be the case for you.

If you want to get a reference to a MembershipUser, you must call your provider's GetUser method. You can use the UserController.GetUser() function in the web layer, which calls your membership provider behind the scenes.

If you need to validate a user's name and password, call your provider's ValidateUser method. Of course your provider must then implement this function.

Hope this helps.
Roger Martin
Creator and Lead Developer of Gallery Server Pro
bluisana
#13 Posted : Wednesday, 5 May 2010 6:59:10 AM(UTC)
Rank: Member

Joined: 15/04/2010(UTC)
Posts: 26
Location: Raleigh

Thanks for the feedback again,

I am finally getting very close to having this working. I actually did a complete 360 and started over in a new route. I have changed our CMS to use the sqlmembership provider. I have our CMS and the gallery working off of the same users and roles now. I also have the gallery webservice being called from the main web application when a user signs in.

Our website is setup in its own virtual directory then the gallery setup is in a virtual directory one level down (http://www.website.com/gallery).

When I redirect out to the gallery after being logged into the regular site the gallery doesn't think there is a logged in user. I am assuming that is because of the virtual directories being separate so they are using different authcookies.

Do you think I should try to keep my current setup and force the gallery to create its own auth cookie when the Logon webservice is called or can you think of a better way?

soooo close,

I really like your design methodology. I do software consulting for about 20 different companies and I rarely get into someone else's project and am impressed. You have done a very good job with this Gallery. How long have you been working on it?

Bryan

After reading through you documentation I am going to try what you have listed in the "Integrate into an ASP.NET web application" section. It looks like that should work.

Roger Martin
#14 Posted : Thursday, 6 May 2010 6:48:15 AM(UTC)
Roger Martin

Rank: Administration

Joined: 3/08/2007(UTC)
Posts: 3,300
Location: Fort Atkinson, WI

I think going with the Logon web service is a good approach, bearing in mind that I know almost nothing about your requirements and architecture. You must also keep an eye on security so that the web service cannot be abused.

I have been working on GSP more or less full time since 2002. The only times I am not is when I have to take on a contract to help pay the bills, but I get back to GSP as soon as I can. I am back on it full time right now. Woo hoo!
Roger Martin
Creator and Lead Developer of Gallery Server Pro
Rss Feed  Atom Feed
Users browsing this topic
Guest
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.