You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Pyramid 2, the concepts of authentication and authorization was replaced by a single one: security policies. The concept of principals was replaced with the concept of identity.
In Kinto, the authorization is implemented in core, and the authentication via plugins.
In order to support the new system, Kinto would have to setup a single security policy, whose authorization part would be similar to what we currently have, and the authentication part from pyramid-multiauth could be rewritten as a helper (composition pattern).
frompyramid_multiauthimportMultipleAuthenticationHelperclassKintoSecurityPolicy:
def__init__(self, settings):
self.helper=MultipleAuthenticationHelper(settings)
defidentity(self, request):
# Will iterate through all configured authentication methodsuserid=self.helper.authenticated_userid(request)
ifuseridisNone:
returnNonereturnuserid# tuple with chosen policy and useriddefauthenticated_userid(self, request):
principals=self.identity(request)
ifprincipalsisNone:
returnprincipalsreturnprincipals[0]
defprincipals(self, request, identity):
principals= [Everyone]
ifrequest.identityisnotNone:
principals.append(Authenticated)
chosenauthn, userid=request.identityprincipals.append(f"{chosenauthn}:{userid}")
# Look up groups too...returnprincipalsdefpermits(self, request, context, permission):
# Use current authorization code here.# ...defremember(request, userid, **kw):
returnself.helper.remember(request, userid, **kw)
defforget(request, **kw):
returnself.helper.forget(request, **kw)
Yes, pyramid official docs recommended did it in this way. But in my projects i still stuck with old api :)
Here is also some examples from the core: AuthTktCookieHelper, SessionAuthenticationHelper.
In Pyramid 2, the concepts of authentication and authorization was replaced by a single one: security policies. The concept of principals was replaced with the concept of identity.
Kinto continues to work thanks to this backward compatibility layer
LegacySecurityPolicy
.In Kinto, the authorization is implemented in core, and the authentication via plugins.
In order to support the new system, Kinto would have to setup a single security policy, whose authorization part would be similar to what we currently have, and the authentication part from
pyramid-multiauth
could be rewritten as a helper (composition pattern)./cc @slav0nic
The text was updated successfully, but these errors were encountered: