Extract credential handling into its own module
Will be used in Docker V1 and APPR protocols
This commit is contained in:
parent
4a5626e64b
commit
6f3d9a6fce
5 changed files with 94 additions and 49 deletions
|
@ -13,6 +13,7 @@ class AuthKind(Enum):
|
|||
basic = 'basic'
|
||||
oauth = 'oauth'
|
||||
signed_grant = 'signed_grant'
|
||||
credentials = 'credentials'
|
||||
|
||||
|
||||
class ValidateResult(object):
|
||||
|
@ -56,6 +57,11 @@ class ValidateResult(object):
|
|||
if self.identity:
|
||||
identity_changed.send(app, identity=self.identity)
|
||||
|
||||
def with_kind(self, kind):
|
||||
""" Returns a copy of this result, but with the kind replaced. """
|
||||
return ValidateResult(kind, self.missing, self.user, self.token, self.oauthtoken, self.robot,
|
||||
self.signed_data, self.error_message)
|
||||
|
||||
@property
|
||||
def authed_user(self):
|
||||
""" Returns the authenticated user, whether directly, or via an OAuth token. """
|
||||
|
|
Reference in a new issue