OpenID + AuthKit + Pylons (simple)

I try to post simple example how to use OpenID with AuthKit 0.4.3 and Pylons 0.9.7. by adapting example from AuthKit. So I just create new Pylons app named “topenid” and modify it as follow:

  1. development.ini:
    These lines below are added to development.ini

    authkit.setup.enable = true
    authkit.setup.method = openid, cookie = file =
    authkit.openid.charset = UTF-8
    authkit.openid.path.signedin = /auth/signin
    authkit.cookie.signoutpath = /auth/signout = http://localhost:5000
    authkit.cookie.secret = somesecret
  2. midddleware
    import authkit.authenticate # this line is added
        app = PylonsApp()
        app = authkit.authenticate.middleware(app, app_conf) # this line is added
  3. topenid/controllers/
    import logging
    from pylons import request, response, session, tmpl_context as c
    from pylons.controllers.util import abort, redirect_to
    from authkit.permissions import RemoteUser
    from authkit.authorize.pylons_adaptors import authorize
    from topenid.lib.base import BaseController, render
    log = logging.getLogger(__name__)
    class AuthController(BaseController):
        def index(self):
            return 'Hello World'
        def test(self):
            return 'test'
        def signout(self):
            return 'signout'
        def signin(self):
            return 'signed in'

These are all modifications. I can access http://localhost:5000/auth/index as expect and http://localhost:5000/auth/test is redirected to an OpenID signin page. And I can sign out by visiting http://localhost:5000/auth/signout.

This example seems to work well but I need something more complex for example every user doesn’t have the same role. So I may post another more complex example soon.

2 thoughts on “OpenID + AuthKit + Pylons (simple)

  1. ถ้าผมต้องการที่จะใช้ AuthKit แต่ต้องการที่จะเขียนวิธีการตรวจสอบ username และ password จากดาต้าเบสเเอง ไม่ทราบว่าจะต้องใช้ method forward หรือเปล่าครับ แล้วมีคู่มือการคอนฟิกหรือเปล่าครับ


Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / เปลี่ยนแปลง )

Twitter picture

You are commenting using your Twitter account. Log Out / เปลี่ยนแปลง )

Facebook photo

You are commenting using your Facebook account. Log Out / เปลี่ยนแปลง )

Google+ photo

You are commenting using your Google+ account. Log Out / เปลี่ยนแปลง )

Connecting to %s