Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Changes between Version 62 and Version 63 of IdentityManagement


Ignore:
Timestamp:
04/29/06 17:14:39 (13 years ago)
Author:
anonymous
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • IdentityManagement

    v62 v63  
    11= Identity Management = 
    22 
    3     '''NOTE''' 
    4  
    5     This page describes the setup for released versions > 0.9a4.   
    6  
    7     For prior versions: change "user_name", "group_name" and "permssions_name" to "userId", "groupId" and "permissionsId", respectively.  Also change "display_name" and "email_address" to "displayName" and "emailAddress. 
    8  
    9 The TurboGears identity management architecture was originally designed and written by [http://metrocat.org/nerd/2005/10/identity-management-for-turbogears Jeff Watkins]. 
    10  
    113Here is a Tutorial for getting TurboGears identity management support up and running. 
    124 
    13 [[PageOutline(1-2,,inline)]] 
    14  
    15 This Tutorial is written from the perspective of a fresh quick-started project, but almost everything applies for existing projects as well. 
     5This Tutorial is written from the perspective of a fresh quick-started project 
    166 
    177= Part I: Identity Basics = 
     
    2515}}} 
    2616 
    27 Name your project "identity_tutorial" and set the database uri in "identity_tutorial/dev.cfg" to point to a server and database you want to use. 
    28 Refer to the [http://www.turbogears.org/docs/wiki20/ Wiki in 20 Minutes Tutorial] for details. 
     17Name your project "identity_tutorial" and set the database uri in "identity_tutorial/dev.cfg" to point to a server and database you want to use.   
    2918 
    3019After you specified the project name. a identity prompt will pop up: 
     
    3423}}} 
    3524 
    36 We want identity, so type "yes". Now we can select one of providers:  
     25This tutorial wouldn't go very far if we didn't enable identity, so go ahead and type "yes". Next, it will ask us to select one of providers:  
    3726 
    3827{{{ 
     
    4029}}} 
    4130 
    42 this will generate the identity-related code.  
     31We should choose SQL Objectthis will generate the identity-related code.  
    4332 
    4433 
     
    5140To take advantage of identity, we need enable it. 
    5241 
    53 === Step 1: Enabling Identity === 
    54  
    55 By default, Identity is turned off in quickstarted templates. The first step is therefore to edit your app.cfg file to turn on identity management: 
    56  
    57 Edit identity_tutorial/config/app.cfg to turn on visit and identity. Edit the failure url as well: 
    58  
    59 {{{ 
    60 #!python 
    61 # visit.on=False 
    62 visit.on=True 
    63  
    64 # identity.on=False 
    65 identity.on = True 
    66  
    67 # identity.failure_url=None 
    68 identity.failure_url = "/login" 
    69  
    70 }}} 
    71  
    72 === Step 2 - Testing the login === 
     42 
     43=== Step 1 - Testing the login === 
    7344Now let's check whether we have all set up correctly so far. Start the project as usual: 
     45 
    7446{{{ 
    7547#!python 
     
    8153You can access any other page without trouble, because we haven't protected those pages yet. 
    8254 
    83 === Step 3 - Import the identity models === 
    84 Identity uses three tables to store user, group, and permission information. 
    85 We need to import these tables into our model. 
    86  
    87 Modify identity_tutorial/model.py to import the TG_User, TG_Group, TG_Permission model classes: 
    88  
    89 {{{ 
    90 #!python 
    91 # Uncomment the following line if you wish to use Identity and SO_Provider 
    92 from turbogears.identity.soprovider import TG_User, TG_Group, TG_Permission 
    93 }}} 
    94  
    95 === Step 4 - Adding an initial user and group === 
     55=== Step 2 - Adding an initial user and group === 
    9656 
    9757Of course, we will need at least one group and one user account to work with. Let's create these with CatWalk 
     
    13191Click the expansion triangle in front of "groups". This will reveal a "Manage Relations" link. Click on it. CatWalk will display two lists. Select the new user on the right list and click on "Add Selected" to move it to the left list. Then click "Save" to confirm the change. 
    13292 
     93 
    13394== C. Using Identity in the Controller == 
    13495 
     
    281242 
    282243{{{ 
     244 
    283245#!python 
    284246class MyController(controllers.Controller, identity.SecureResource): 
     
    324286You can customize your own classes for users, groups, and/or permissions -- to add a few attributes to the user class, say an image of the user and a phone number -- or even a complete replacement. 
    325287 
    326 === 1. Create SQL tables === 
    327  
    328 If you are going to ''inherit'' the standard Identity classes, make sure that you run the application once before you implement your own classes.  
    329 This will create the TG_* tables. 
    330  
    331 === 2. Edit identity_tutorial/config/app.cfg === 
    332  
    333 Edit app.cfg, remove the comments from "identity.soprovider" lines.  
    334  
    335 {{{ 
    336 #!python 
    337 # The classes you wish to use for your Identity model. Leave these commented out 
    338 # to use the default classes for SqlObjectIdentityProvider. Or set them to the 
    339 # classes in your model. NOTE: These aren't TG_* because the TG prefix is 
    340 # reserved for classes created by TurboGears. 
    341 identity.soprovider.model.user="identity_tutorial.model.User" 
    342 identity.soprovider.model.group="identity_tutorial.model.Group" 
    343 identity.soprovider.model.permission="identity_tutorial.model.Permission" 
    344 }}} 
    345  
    346 Change model."User", "Group", "Permission" to whatever you prefer.  
    347  
    348 === 3. Run the application === 
    349  
    350 Run the application 
    351  
    352 {{{ 
    353 #!python 
    354 $ start-identity_tutorial 
    355 }}} 
    356  
    357 Then you can use your classes to manipulate TurboGears Identity Management. 
    358  
    359  * refer [http://groups.google.com/group/turbogears/browse_thread/thread/37fc2c8a1a2155ed/be061d37b3f1ba4c#be061d37b3f1ba4c  here] and refer [http://groups.google.com/group/turbogears/browse_thread/thread/6073ff1ceb3ba9c9/0ccbeead93a80f3a#0ccbeead93a80f3a here](conclusion)  
    360 ---- 
     288There are some elements of the tables that you should not remove or rename.    
     289 
    361290== B. Retrieve logged users' identity infomation == 
    362291 
     
    421350>>> 
    422351}}} 
    423  
    424 == C. Random Notes == 
    425 Setting identity by config has not implement yet. 
    426  
    427 Using tg-admin shell to add identity user/group is not work under 0.9a2. patch is [http://groups.google.com/group/turbogears/browse_thread/thread/e1cd7e5e8cb26bba/9f8ae06fbe07bd5a here] 
    428  
    429 ---- 
    430  
    431  
    432  
    433 #TODO using SQLAlchemy instead of SQLObject 
    434  
    435 #TODO LdapIdentityProvider 
    436  
    437 === Saving the identity in a cookie === 
    438  
    439 Is it possible to store the identity information in a cookie? So that the user does not have to login each and everytime he or she visits the protected page? 
    440