sanskrit_data.schema.users

Intro

  • For general context and class diagram, refer to schema.
class sanskrit_data.schema.users.AuthenticationInfo[source]

Bases: sanskrit_data.schema.common.JsonObject

VEDAVAAPI_AUTH = 'vedavaapi'
check_password(plain_password)[source]
classmethod from_details(auth_user_id, auth_provider, auth_secret_hashed=None)[source]
schema = {'properties': {'auth_secret_plain': {'type': 'string', 'description': 'This should NEVER be set when stored in a database; but is good for client-server transmission purposes.'}, 'auth_provider': {'enum': ['google', 'vedavaapi'], 'type': 'string'}, 'auth_user_id': {'type': 'string'}, 'auth_secret_bcrypt': {'type': 'string', 'description': 'This should be hashed, and merits being stored in a database.'}, 'jsonClass': {'enum': ['AuthenticationInfo'], 'type': 'string', 'description': 'A hint used by json libraries to deserialize json data to an object of the appropriate type. This is necessary for sub-objects to have as well (to ensure that the deserialization functions as expected).'}}, 'required': ['jsonClass'], 'type': 'object'}
set_bcrypt_password()[source]
validate_schema()[source]
class sanskrit_data.schema.users.User[source]

Bases: sanskrit_data.schema.common.JsonObject

Represents a user of our service.

check_permission(service, action)[source]
classmethod from_details(user_type, auth_infos, permissions=None)[source]
get_first_user_id_or_none()[source]
get_user_ids()[source]
is_admin(service)[source]
is_human()[source]
schema = {'properties': {'jsonClass': {'enum': ['User'], 'type': 'string', 'description': 'A hint used by json libraries to deserialize json data to an object of the appropriate type. This is necessary for sub-objects to have as well (to ensure that the deserialization functions as expected).'}, 'user_type': {'enum': ['human', 'bot'], 'type': 'string'}, 'authentication_infos': {'items': {'required': ['jsonClass'], 'type': 'object', 'properties': {'auth_secret_plain': {'type': 'string', 'description': 'This should NEVER be set when stored in a database; but is good for client-server transmission purposes.'}, 'auth_provider': {'enum': ['google', 'vedavaapi'], 'type': 'string'}, 'auth_user_id': {'type': 'string'}, 'auth_secret_bcrypt': {'type': 'string', 'description': 'This should be hashed, and merits being stored in a database.'}, 'jsonClass': {'enum': ['AuthenticationInfo'], 'type': 'string', 'description': 'A hint used by json libraries to deserialize json data to an object of the appropriate type. This is necessary for sub-objects to have as well (to ensure that the deserialization functions as expected).'}}}, 'type': 'array'}, 'permissions': {'items': {'required': ['jsonClass'], 'type': 'object', 'properties': {'actions': {'items': {'enum': ['read', 'write', 'admin'], 'type': 'string'}, 'type': 'array', 'description': 'Should be an enum in the future.'}, 'service': {'type': 'string', 'description': 'Allowable values should be predetermined regular expressions.'}, 'jsonClass': {'enum': ['UserPermission'], 'type': 'string', 'description': 'A hint used by json libraries to deserialize json data to an object of the appropriate type. This is necessary for sub-objects to have as well (to ensure that the deserialization functions as expected).'}}}, 'type': 'array'}}, 'required': ['jsonClass'], 'type': 'object'}
validate_schema()[source]
class sanskrit_data.schema.users.UserPermission[source]

Bases: sanskrit_data.schema.common.JsonObject

classmethod from_details(service, actions)[source]
schema = {'properties': {'service': {'type': 'string', 'description': 'Allowable values should be predetermined regular expressions.'}, 'actions': {'items': {'enum': ['read', 'write', 'admin'], 'type': 'string'}, 'type': 'array', 'description': 'Should be an enum in the future.'}, 'jsonClass': {'enum': ['UserPermission'], 'type': 'string', 'description': 'A hint used by json libraries to deserialize json data to an object of the appropriate type. This is necessary for sub-objects to have as well (to ensure that the deserialization functions as expected).'}}, 'required': ['jsonClass'], 'type': 'object'}
sanskrit_data.schema.users.hash_password(plain_password)[source]