Show More
@@ -211,7 +211,7 b' def request_view(request):' | |||
|
211 | 211 | # now check if token is valid for API |
|
212 | 212 | auth_token = request.rpc_api_key |
|
213 | 213 | token_match = api_user.authenticate_by_token( |
|
214 |
auth_token, roles=[UserApiKeys.ROLE_API] |
|
|
214 | auth_token, roles=[UserApiKeys.ROLE_API]) | |
|
215 | 215 | invalid_token = not token_match |
|
216 | 216 | |
|
217 | 217 | log.debug('Checking if API KEY is valid with proper role') |
@@ -1218,7 +1218,7 b' class LoginRequired(object):' | |||
|
1218 | 1218 | else: |
|
1219 | 1219 | roles = [UserApiKeys.ROLE_HTTP] |
|
1220 | 1220 | token_match = db_user.authenticate_by_token( |
|
1221 |
_auth_token, roles=roles |
|
|
1221 | _auth_token, roles=roles) | |
|
1222 | 1222 | else: |
|
1223 | 1223 | log.debug('Unable to fetch db instance for auth user: %s', user) |
|
1224 | 1224 | token_match = False |
@@ -603,8 +603,7 b' class User(Base, BaseModel):' | |||
|
603 | 603 | UserApiKeys.role == UserApiKeys.ROLE_ALL)) |
|
604 | 604 | return tokens.all() |
|
605 | 605 | |
|
606 |
def authenticate_by_token(self, auth_token, roles=None |
|
|
607 | include_builtin_token=False): | |
|
606 | def authenticate_by_token(self, auth_token, roles=None): | |
|
608 | 607 | from rhodecode.lib import auth |
|
609 | 608 | |
|
610 | 609 | log.debug('Trying to authenticate user: %s via auth-token, ' |
@@ -623,14 +622,10 b' class User(Base, BaseModel):' | |||
|
623 | 622 | |
|
624 | 623 | tokens_q = tokens_q.filter(UserApiKeys.role.in_(roles)) |
|
625 | 624 | |
|
626 | maybe_builtin = [] | |
|
627 | if include_builtin_token: | |
|
628 | maybe_builtin = [AttributeDict({'api_key': self.api_key})] | |
|
629 | ||
|
630 | 625 | plain_tokens = [] |
|
631 | 626 | hash_tokens = [] |
|
632 | 627 | |
|
633 |
for token in tokens_q.all() |
|
|
628 | for token in tokens_q.all(): | |
|
634 | 629 | if token.api_key.startswith(crypto_backend.ENC_PREF): |
|
635 | 630 | hash_tokens.append(token.api_key) |
|
636 | 631 | else: |
General Comments 0
You need to be logged in to leave comments.
Login now