Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3144)

Unified Diff: third_party/buildbot_7_12/buildbot/status/web/auth.py

Issue 12207158: Bye bye buildbot 0.7.12. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/buildbot_7_12/buildbot/status/web/auth.py
diff --git a/third_party/buildbot_7_12/buildbot/status/web/auth.py b/third_party/buildbot_7_12/buildbot/status/web/auth.py
deleted file mode 100644
index ebd81bfbff05aa2a6723c5b292c76d99902be0d8..0000000000000000000000000000000000000000
--- a/third_party/buildbot_7_12/buildbot/status/web/auth.py
+++ /dev/null
@@ -1,95 +0,0 @@
-
-import os
-from zope.interface import Interface, implements
-from buildbot.status.web.base import HtmlResource
-
-class IAuth(Interface):
- """Represent an authentication method."""
-
- def authenticate(self, user, passwd):
- """Check whether C{user} / C{passwd} are valid."""
-
- def errmsg(self):
- """Get the reason authentication failed."""
-
-class AuthBase:
- err = ""
-
- def errmsg(self):
- return self.err
-
-class BasicAuth(AuthBase):
- implements(IAuth)
- """Implement basic authentication against a list of user/passwd."""
-
- userpass = []
- """List of user/pass tuples."""
-
- def __init__(self, userpass):
- """C{userpass} is a list of (user, passwd)."""
- for item in userpass:
- assert isinstance(item, tuple)
- u, p = item
- assert isinstance(u, str)
- assert isinstance(p, str)
- self.userpass = userpass
-
- def authenticate(self, user, passwd):
- """Check that C{user}/C{passwd} is a valid user/pass tuple."""
- if not self.userpass:
- self.err = "Bad self.userpass data"
- return False
- for u, p in self.userpass:
- if user == u and passwd == p:
- self.err = ""
- return True
- self.err = "Invalid username or password"
- return False
-
-class HTPasswdAuth(AuthBase):
- implements(IAuth)
- """Implement authentication against an .htpasswd file."""
-
- file = ""
- """Path to the .htpasswd file to use."""
-
- def __init__(self, file):
- """C{file} is a path to an .htpasswd file."""
- assert os.path.exists(file)
- self.file = file
-
- def authenticate(self, user, passwd):
- """Authenticate C{user} and C{passwd} against an .htpasswd file"""
- if not os.path.exists(self.file):
- self.err = "No such file: " + self.file
- return False
- # Fetch each line from the .htpasswd file and split it into a
- # [user, passwd] array.
- lines = [l.rstrip().split(':', 1)
- for l in file(self.file).readlines()]
- # Keep only the line for this login
- lines = [l for l in lines if l[0] == user]
- if not lines:
- self.err = "Invalid user/passwd"
- return False
- # This is the DES-hash of the password. The first two characters are
- # the salt used to introduce disorder in the DES algorithm.
- hash = lines[0][1]
- from crypt import crypt
- res = hash == crypt(passwd, hash[0:2])
- if res:
- self.err = ""
- else:
- self.err = "Invalid user/passwd"
- return res
-
-class AuthFailResource(HtmlResource):
- title = "Authentication Failed"
-
- def body(self, request):
- data = ''
- data += '<h1>Authentication Failed</h1>\n'
- data += '<p>The username or password you entered were not correct. Please go back and try again.</p>\n'
-
- return data
-
« no previous file with comments | « third_party/buildbot_7_12/buildbot/status/web/ansi2html.py ('k') | third_party/buildbot_7_12/buildbot/status/web/base.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698