Powered by SmartDoc

Authorization

Session expiration time

Session has expiration time. Exception SessionTimeoutError is raised when accessed with expired session.

Session expiration time is specified with seconds in "timeout" attribute of CKApplication. Timeout is time progressed with seconds than "timeout" after last accessed time for the session. You make sessions postpone indefinitely by setting 0 for "timeout" attribute. Sessions that session IDs don't exist is also timeout.

Browsers and IP addresses

Sessions can authorize by browsers and IP addresses. Exception SessionAuthorizationError is raised when accessed with browser or IP address that are different from ones when a session created.

Set up methods of authorization with the following attributes. If the attributes is true, the mechanism is enabled.

Methods for authorizing sessions (CKApplication class)
Attribute Default Description
auth_by_user_agent false Authorizes by browser.
auth_by_remote_addr false Authorizes by IP address.

Handling session errors

To process for handling session errors, override CKApplication#handle_session_errorand return a component to display. The hook method is called when errors for timeout or authorization are raised.

class CKApplication
  def handle_error( error )
    if error.class == CKSession::SessionTimeoutError then
      # ... code for timeout
    elsif error.class == CKSession::SessionAuthorizationError then
      # ... code for authorizaion error
    end

    error_page       = page @error_page
    error_page.error = error
    error_page.debug = @debug
    error_page
  end
end