Change app registry to use the credentials verification system
Allows for tokens, OAuth tokens and robot accounts to be used as well Fixes https://jira.prod.coreos.systems/browse/QS-36
This commit is contained in:
parent
aa49b37ad2
commit
3bf8973fd9
3 changed files with 13 additions and 7 deletions
|
@ -11,6 +11,7 @@ from cnr.exception import (
|
|||
from flask import jsonify, request
|
||||
|
||||
from auth.auth_context import get_authenticated_user
|
||||
from auth.credentials import validate_credentials
|
||||
from auth.decorators import process_auth
|
||||
from auth.permissions import CreateRepositoryPermission, ModifyRepositoryPermission
|
||||
from endpoints.appr import appr_bp, require_app_repo_read, require_app_repo_write
|
||||
|
@ -56,11 +57,11 @@ def login():
|
|||
if not username or not password:
|
||||
raise InvalidUsage('Missing username or password')
|
||||
|
||||
user, err = User.get_user(username, password)
|
||||
if err is not None:
|
||||
raise UnauthorizedAccess(err)
|
||||
result, _ = validate_credentials(username, password)
|
||||
if not result.auth_valid:
|
||||
raise UnauthorizedAccess(result.error_message)
|
||||
|
||||
return jsonify({'token': "basic " + b64encode("%s:%s" % (user.username, password))})
|
||||
return jsonify({'token': "basic " + b64encode("%s:%s" % (username, password))})
|
||||
|
||||
|
||||
# @TODO: Redirect to S3 url
|
||||
|
|
Reference in a new issue