Kirok

From Codefool

Jump to: navigation, search
  1. Kirok must be fast.
  2. Kirok must be secure.
  3. Kirok must provide for open-ended documents
    1. That are private (from everyone, even robots)
    2. That are restricted to a group
    3. That are available to everyone

To the first end I shall abandon my romantic notion of classes as it inteferes with speed.

Tasks that need to be completed on every page load:

  1. Verify that the OTP is valid and not expired
  2. Verify that the IP address is tied to this session
  3. Load the session and user information from the database
  • A missing or invalid OTP results in the GUEST home page.
  • An invalid OTP results in a log of the IP address of the offender.
  • An expired OTP is a tricky thing. It can be caused by someone trying to spoof, or a legitimate user taking too long to submit the page. We must err on the side of usability, however, with security. So an expired OTP results in the user's access level being bumped to RESTRICTED, which means they're technically a GUEST with thier user preferences in place. To access any non-public content, they must log in again. In this mode, the login widget is on the page, so the most they will have to do is specify their password again.

All of these need to be completed with a single query to the database.

table.user table.user.id = int table.user.moniker = varchar( 64 ) table.user.ipaddr_last = uint32 table.user.last_seen = datetime table.user.name = varchar( 64 )

table.session table.session.id = int table.session.sessid = int // http session id table.session.userid = int table.session.ipaddr = uint32 table.session.otp = char( 32 ) //md5 table.session.otp_expire = datetime


SELECT k_session. * , k_user. * FROM k_session INNER JOIN k_user ON u_id = s_userid WHERE s_sessid =12345 AND s_ipaddr = 0x12345678 AND s_otp = '01234567890abcdef01234567890abcdef' AND s_otp_expire >= NOW( )

One Time Pad

The One Time Pad (OTP) is a mechanism through which we attempt to defeat spoofing by embedding a sequence number in each generated page. This sequence number gives the page an expiration time. The OTP is tied to the session in progress, so is only good once (hence the name). This prevents someone from submitting arbitrary queries to Kirok. A query submitted with a non-existent or expired OTP is summarilly rejected and logged.


Guest User

The Guest user has a userid of zero. The guest user can read all public areas, but cannot post.

Personal tools