mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-16 06:22:59 +00:00
Add lengths to all Unicode() ones
- Otherwise does not work with MySQL - Change JSONDict to be TEXT (Unbounded) rather than VARCHAR. This makes most sense, since you can't index these anyway. - The 'ip' field in Server is set to 255, since that is the max allowed length of DNS entries. - Most of the rest of the Unicodes have approximately high values that most people should not mostly run into (famous last words).
This commit is contained in:
@@ -12,7 +12,7 @@ from tornado import gen
|
||||
from tornado.log import app_log
|
||||
from tornado.httpclient import HTTPRequest, AsyncHTTPClient
|
||||
|
||||
from sqlalchemy.types import TypeDecorator, VARCHAR
|
||||
from sqlalchemy.types import TypeDecorator, TEXT
|
||||
from sqlalchemy import (
|
||||
inspect,
|
||||
Column, Integer, ForeignKey, Unicode, Boolean,
|
||||
@@ -39,7 +39,7 @@ class JSONDict(TypeDecorator):
|
||||
|
||||
"""
|
||||
|
||||
impl = VARCHAR
|
||||
impl = TEXT
|
||||
|
||||
def process_bind_param(self, value, dialect):
|
||||
if value is not None:
|
||||
@@ -64,11 +64,11 @@ class Server(Base):
|
||||
"""
|
||||
__tablename__ = 'servers'
|
||||
id = Column(Integer, primary_key=True)
|
||||
proto = Column(Unicode, default='http')
|
||||
ip = Column(Unicode, default='')
|
||||
proto = Column(Unicode(15), default='http')
|
||||
ip = Column(Unicode(255), default='') # could also be a DNS name
|
||||
port = Column(Integer, default=random_port)
|
||||
base_url = Column(Unicode, default='/')
|
||||
cookie_name = Column(Unicode, default='cookie')
|
||||
base_url = Column(Unicode(255), default='/')
|
||||
cookie_name = Column(Unicode(255), default='cookie')
|
||||
|
||||
def __repr__(self):
|
||||
return "<Server(%s:%s)>" % (self.ip, self.port)
|
||||
@@ -178,6 +178,7 @@ class Proxy(Base):
|
||||
self.log.info("Adding user %s to proxy %s => %s",
|
||||
user.name, user.proxy_path, user.server.host,
|
||||
)
|
||||
|
||||
if user.spawn_pending:
|
||||
raise RuntimeError(
|
||||
"User %s's spawn is pending, shouldn't be added to the proxy yet!", user.name)
|
||||
@@ -295,7 +296,7 @@ class User(Base):
|
||||
"""
|
||||
__tablename__ = 'users'
|
||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
name = Column(Unicode)
|
||||
name = Column(Unicode(1023))
|
||||
# should we allow multiple servers per user?
|
||||
_server_id = Column(Integer, ForeignKey('servers.id'))
|
||||
server = relationship(Server, primaryjoin=_server_id == Server.id)
|
||||
@@ -303,7 +304,7 @@ class User(Base):
|
||||
last_activity = Column(DateTime, default=datetime.utcnow)
|
||||
|
||||
api_tokens = relationship("APIToken", backref="user")
|
||||
cookie_id = Column(Unicode, default=new_token)
|
||||
cookie_id = Column(Unicode(1023), default=new_token)
|
||||
state = Column(JSONDict)
|
||||
|
||||
other_user_cookies = set([])
|
||||
@@ -350,8 +351,8 @@ class APIToken(Base):
|
||||
return Column(Integer, ForeignKey('users.id'))
|
||||
|
||||
id = Column(Integer, primary_key=True)
|
||||
hashed = Column(Unicode)
|
||||
prefix = Column(Unicode)
|
||||
hashed = Column(Unicode(1023))
|
||||
prefix = Column(Unicode(1023))
|
||||
prefix_length = 4
|
||||
algorithm = "sha512"
|
||||
rounds = 16384
|
||||
|
Reference in New Issue
Block a user