core.bones.captcha ================== .. py:module:: core.bones.captcha Classes ------- .. autoapisummary:: core.bones.captcha.CaptchaBone Module Contents --------------- .. py:class:: CaptchaBone(*, publicKey = None, privateKey = None, score_threshold = 0.5, **kwargs) Bases: :py:obj:`viur.core.bones.base.BaseBone` The CaptchaBone is used to ensure that a user is not a bot. The Captcha bone uses the Google reCAPTCHA API to perform the Captcha validation and supports v2 and v3. .. seealso:: Option :attr:`core.config.Security.captcha_default_credentials` for global security settings. Option :attr:`core.config.Security.captcha_enforce_always` for developing. Initializes a new CaptchaBone. `publicKey` and `privateKey` can be omitted, if they are set globally in :attr:`core.config.Security.captcha_default_credentials`. :param publicKey: The public key for the Captcha validation. :param privateKey: The private key for the Captcha validation. :score_threshold: If reCAPTCHA v3 is used, the score must be at least this threshold. For reCAPTCHA v2 this property will be ignored. .. py:attribute:: type :value: 'captcha' .. py:attribute:: privateKey :value: None .. py:attribute:: score_threshold :value: 0.5 .. py:attribute:: required :value: True .. py:method:: serialize(skel, name, parentIndexed) Serializing the Captcha bone is not possible so it return False .. py:method:: unserialize(skel, name) Stores the publicKey in the SkeletonInstance :param skel: The target :class:`SkeletonInstance`. :param name: The name of the CaptchaBone in the :class:`SkeletonInstance`. :returns: boolean, that is true, as the Captcha bone is always unserialized successfully. .. py:method:: fromClient(skel, name, data) Load the reCAPTCHA token from the provided data and validate it with the help of the API. reCAPTCHA provides the token via callback usually as "g-recaptcha-response", but to fit into the skeleton logic, we support both names. So the token can be provided as "g-recaptcha-response" or the name of the CaptchaBone in the Skeleton. While the latter one is the preferred name.