def upgrade():
    con = migrate_engine.raw_connection()

    if migrate_engine.name == 'sqlite':
        store = SQLiteStore(con);
    else:
        store = MySQLStore(con);
    
    store.createTables()
Example #2
0
def upgrade():
    con = migrate_engine.raw_connection()

    #    if config['sqlalchemy.url'].find('mysql:') != -1:
    #        store = MySQLStore(con);
    #    else:
    #        store = SQLiteStore(con);
    store = SQLiteStore(con)
    store.createTables()
Example #3
0
	def __init__(self, request, link_on_success, link_on_fail):
		# making sure that the db connection is open
		connection.cursor()
		self._store = SQLiteStore(connection.connection)
		self._consumer = Consumer(request.session, self._store)
		self._realm = "http://%s" % request.get_host()
		self._required_extensions = ["nickname", "email", "fullname"]
		self.link_on_success = link_on_success
		self.link_on_fail = link_on_fail
Example #4
0
 def _getStore(self, db):
     scheme, rest = self.connection_uri.split(':', 1)
     if scheme == 'mysql':
         return MySQLStore(db.cnx.cnx)
     elif scheme == 'postgres':
         return PostgreSQLStore(db.cnx.cnx)
     elif scheme == 'sqlite':
         return SQLiteStore(db.cnx.cnx)
     else:
         return MemoryStore()
Example #5
0
def getServer(url_root):
    openidstore = SQLiteStore(sqlite3.connect('/tmp/cstore.db'))
    oserver = server.Server(openidstore, url_root + '/openidserver')
    return oserver
Example #6
0
class OpenID():
	"""
	Consumer class that interacts with the OpenID provider
	and authenticates the user..

	"""
	
	def __init__(self, request, link_on_success, link_on_fail):
		# making sure that the db connection is open
		connection.cursor()
		self._store = SQLiteStore(connection.connection)
		self._consumer = Consumer(request.session, self._store)
		self._realm = "http://%s" % request.get_host()
		self._required_extensions = ["nickname", "email", "fullname"]
		self.link_on_success = link_on_success
		self.link_on_fail = link_on_fail
	
	def _get_full_url(self, url):
		if not url.startswith("http://"):
			url = self._realm + url
		return url
	
	def _parse_response(self, response):
		"""
		parses the response and return a dict of
		parameters.. the dict will be returned to 
		the view to redirect the user to some specific
		page..
		
		only caring about SUCCESS since i classify all
		other statuses as failure.

		"""
		
		params = {}
		
		if response.status == SUCCESS:
			sreg_response = SRegResponse.fromSuccessResponse(response)
			
			params["identifier"] = response.identity_url
			params["user_info"] = {} if not sreg_response else sreg_response.data
			params["link"] = self.link_on_success
		else:
			params["message"] = OPENID_FAILURE_MESSAGE
			params["link"] = self.link_on_fail
		
		return params
	
	def authenticate(self, identifier, return_to):
		# constructing a full return to address
		return_to = self._get_full_url(return_to)
		
		try:
			self._auth = self._consumer.begin(identifier)
			if not openid_user_exists(identifier):
				self._auth.addExtension(SRegRequest(required=self._required_extensions))
		except UnicodeDecodeError:
			# it seems that there's a problem with the OpenID provider..
			# warning the user might be a good idea..
			raise OpenIDProviderFailedError
		except OperationalError:
			# the openid store tables are not found, so create them
			# and redo everything..
			self._store.createTables()
			return self.authenticate(identifier, return_to)
		except DiscoveryFailure:
			raise OpenIDDiscoveryError
		provider_url = self._auth.redirectURL(realm=self._realm, return_to=return_to)
		return provider_url
	
	def complete(self, params, return_to):
		# constructing a full return to address
		return_to = self._get_full_url(return_to)
		openid_response = self._consumer.complete(params, return_to)
		return self._parse_response(openid_response)