| 24 | | header = req.get_header('Authorization') |
|---|
| 25 | | if header is None: |
|---|
| 26 | | self.log.info('HTTPAuthFilter: No authentication data given, returing 403') |
|---|
| 27 | | return self # Run HTTP auth |
|---|
| 28 | | else: |
|---|
| 29 | | token = header.split()[1] |
|---|
| 30 | | user, passwd = base64.b64decode(token).split(':', 1) |
|---|
| 31 | | if AccountManager(self.env).check_password(user, passwd): |
|---|
| 32 | | self.log.debug('HTTPAuthFilter: Authentication okay') |
|---|
| 33 | | req.__user = user |
|---|
| 34 | | else: |
|---|
| 35 | | self.log.info('HTTPAuthFilter: Bad authentication data given, returing 403') |
|---|
| 36 | | return self # Failed auth |
|---|
| 37 | | |
|---|
| | 27 | check = True |
|---|
| | 28 | break |
|---|
| | 29 | if req.args.get('format') in self.formats: |
|---|
| | 30 | check = True |
|---|
| | 31 | if check and not self._check_password(req): |
|---|
| | 32 | self.log.info('HTTPAuthFilter: No/bad authentication data given, returing 403') |
|---|
| | 33 | return self |
|---|
| 62 | | try: |
|---|
| 63 | | return req.__user |
|---|
| 64 | | except AttributeError: |
|---|
| 65 | | return None # Bail out |
|---|
| | 58 | user = self._check_password(req) |
|---|
| | 59 | if user: |
|---|
| | 60 | self.log.debug('HTTPAuthFilter: Authentication okay for %s', user) |
|---|
| | 61 | return user |
|---|
| | 62 | |
|---|
| | 63 | # Internal methods |
|---|
| | 64 | def _check_password(self, req): |
|---|
| | 65 | header = req.get_header('Authorization') |
|---|
| | 66 | if header: |
|---|
| | 67 | token = header.split()[1] |
|---|
| | 68 | user, passwd = base64.b64decode(token).split(':', 1) |
|---|
| | 69 | if AccountManager(self.env).check_password(user, passwd): |
|---|
| | 70 | return user |
|---|