コード例 #1
0
 def Authenticate(self):
     if not 'Authorization' in self.headers:
         raise Json.RestException(401, 'No authorization header')
     h = self.headers['Authorization']
     d = str(base64.b64decode(h[6:len(h)]), 'utf-8')
     s = d.split(':')
     c = conn.cursor()
     r = c.execute("select count(*) from user where uname='" + s[0] +
                   "' and password='******'").fetchone()
     if int(r[0]) != 1:
         raise Json.RestException(401, 'Not authenticated')
     return