Source code for gws.common.auth.provider

import gws.config

import gws.types as t

from . import user


[docs]class Config(t.WithType): """Auth provider config.""" allowedMethods: t.Optional[t.List[str]]
#:export IAuthProvider
[docs]class Object(gws.Object, t.IAuthProvider):
[docs] def configure(self): super().configure() self.allowed_methods: t.List[str] = self.var('allowedMethods')
[docs] def get_user(self, user_uid: str) -> t.Optional[t.IUser]: pass
[docs] def authenticate(self, method: t.IAuthMethod, login: str, password: str, **kwargs) -> t.Optional[t.IUser]: pass
[docs] def user_from_dict(self, d: dict) -> t.IUser: return user.ValidUser().init_from_data(self, d['user_uid'], d['roles'], d['attributes'])
[docs] def user_to_dict(self, u: t.IUser) -> dict: return { 'provider_uid': self.uid, 'user_uid': u.uid, 'roles': list(u.roles), 'attributes': u.attributes }