[1.0.x] TFA Headless

Created on 13 May 2024, 6 months ago

Tfa Headless is a module that creates endpoints that can be used to use the Google Authenticator flow for Headless use. It depends on the TFA module: https://www.drupal.org/project/tfa .
This headless functionality was not possible using other modules (or this one). In the future there will be other methods added, depending on the requests from users.

https://www.drupal.org/project/tfa_headless

📌 Task
Status

Needs review

Component

module

Created by

🇳🇱Netherlands arlanschouwstra

Live updates comments and jobs are added and updated live.
  • Security

    It is used for security vulnerabilities which do not need a security advisory. For example, security issues in projects which do not have security advisory coverage, or forward-porting a change already disclosed in a security advisory. See Drupal’s security advisory policy for details. Be careful publicly disclosing security vulnerabilities! Use the “Report a security vulnerability” link in the project page’s sidebar. See how to report a security issue for details.

Sign in to follow issues

Comments & Activities

  • Issue created by @arlanschouwstra
  • 🇮🇳India vishal.kadam Mumbai

    Thank you for applying!

    Please read Review process for security advisory coverage: What to expect for more details and Security advisory coverage application checklist to understand what reviewers look for. Tips for ensuring a smooth review gives some hints for a smoother review.

    The important notes are the following.

    • If you have not done it yet, you should run phpcs --standard=Drupal,DrupalPractice on the project, which alone fixes most of what reviewers would report.
    • For the time this application is open, only your commits are allowed.
    • The purpose of this application is giving you a new drupal.org role that allows you to opt projects into security advisory coverage, either projects you already created, or projects you will create. The project status won't be changed by this application and no other user will be able to opt projects into security advisory policy.
    • We only accept an application per user. If you change your mind about the project to use for this application, or it is necessary to use a different project for the application, please update the issue summary with the link to the correct project and the issue title with the project name and the branch to review.

    To the reviewers

    Please read How to review security advisory coverage applications , Application workflow , What to cover in an application review , and Tools to use for reviews .

    The important notes are the following.

    • It is preferable to wait for a Code Review Administrator before commenting on newly created applications. Code Review Administrators will do some preliminary checks that are necessary before any change on the project files is suggested.
    • Reviewers should show the output of a CLI tool only once per application.
    • It may be best to have the applicant fix things before further review.

    For new reviewers, I would also suggest to first read In which way the issue queue for coverage applications is different from other project queues .

  • 🇺🇸United States cmlara

    To Reviewers:

    Please ensure this module has mitigated the concerns raised in SA-CONTRIB-2023-030 when considering if this module properly uses Drupal API’s.

    The TFA policy is that REST and similar authentication should be disabled with the 8.x-1.x branch for a secure deployment due to known architectural issues that the 2.x branch has been addressing.

    Also worth mentioning a feature request that exists in the TFA module queue TFA module with headless Drupal Active which notes part of this module may be unnecessary with the 2.x branch and is looking for scoping details for the remainder of the issue.

    I have performed no review of the submitted modules code.

  • Status changed to Needs work 6 months ago
  • 🇮🇳India vishal.kadam Mumbai

    1. main will be a supported branch in future, but for the moment it is better not to use it. It is not wrong, but it is not completely supported on drupal.org. For now, the branch names must follow what is reported in Release branches .

    2. FILE: tfa_headless.info.yml

    core_version_requirement: ^8 || ^9 || ^10

    The Drupal Core versions before 8.7.7 do not recognize the core_version_requirement key.

    3. FILE: src/Service/TfaHeadlessService.php

      /**
       * Class constructor.
       *
       * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
       *   The configuration factory.
       * @param \Drupal\Core\Session\AccountInterface $current_user
       *   The current user.
       * @param \Drupal\user\UserDataInterface $user_data
       *   The user data.
       * @param \Drupal\encrypt\EncryptionProfileManagerInterface $encryption_profile_manager
       *   Encryption profile manager.
       * @param \Drupal\encrypt\EncryptServiceInterface $encrypt_service
       *   Encryption service.
       * @param \Drupal\Component\Datetime\TimeInterface $time
       *   The time service.
       */
      public function __construct(

    FILE: src/Plugin/rest/resource/Generate.php

      /**
       * Class constructor.
       *
       * @param array $configuration
       *   The configuration array.
       * @param string $plugin_id
       *   The plugin id.
       * @param array $plugin_definition
       *   The plugin definition.
       * @param array $serializer_formats
       *   The serializer formats.
       * @param \Psr\Log\LoggerInterface $logger
       *   The plugin logger service.
       * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
       *   The configuration factory.
       * @param \Drupal\Core\Session\AccountInterface $current_user
       *   The current user.
       */
      public function __construct(

    FILE: src/Plugin/rest/resource/Login.php

      /**
       * Class constructor.
       *
       * @param array $configuration
       *   The configuration array.
       * @param string $plugin_id
       *   The plugin id.
       * @param array $plugin_definition
       *   The plugin definition.
       * @param array $serializer_formats
       *   The serializer formats.
       * @param \Psr\Log\LoggerInterface $logger
       *   The plugin logger service.
       * @param \Drupal\tfa_headless\Service\TfaHeadlessService $tfa_service
       *   The Headless TFA service.
       * @param \Drupal\Core\Session\AccountInterface $current_user
       *   The current user.
       */
      public function __construct(

    FILE: src/Plugin/rest/resource/Register.php

      /**
       * Class constructor.
       *
       * @param array $configuration
       *   The configuration array.
       * @param string $plugin_id
       *   The plugin id.
       * @param array $plugin_definition
       *   The plugin definition.
       * @param array $serializer_formats
       *   The serializer formats.
       * @param \Psr\Log\LoggerInterface $logger
       *   The plugin logger service.
       * @param \Drupal\tfa_headless\Service\TfaHeadlessService $tfa_service
       *   The Headless TFA service.
       * @param \Drupal\Core\Session\AccountInterface $current_user
       *   The current user.
       */
      public function __construct(

    FILE: src/Plugin/rest/resource/Status.php

      /**
       * Class constructor.
       *
       * @param array $configuration
       *   The configuration array.
       * @param string $plugin_id
       *   The plugin id.
       * @param array $plugin_definition
       *   The plugin definition.
       * @param array $serializer_formats
       *   The serializer formats.
       * @param \Psr\Log\LoggerInterface $logger
       *   The plugin logger service.
       * @param \Drupal\Core\Session\AccountInterface $current_user
       *   The current user.
       * @param \Drupal\user\UserDataInterface $user_data
       *   The user data.
       */
      public function __construct(

    The documentation comment for constructors is not mandatory anymore, If it is given, the description must be Constructs a new [class name] object. where [class name] includes the class namespace.

  • 🇳🇱Netherlands arlanschouwstra

    @vishal.kadam I updated everything based on your feedback.

    I also removed Drupal 8 support from the 1.0.x branch, as

  • 🇮🇳India vishal.kadam Mumbai

    Rest looks fine to me.

    Let’s wait for a Code Review Administrator to take a look and if everything goes fine, you will get the role.

  • Status changed to Needs review 6 months ago
  • Status changed to Needs work 6 months ago
  • 🇺🇸United States cmlara

    I’ve given a very cursory glance at the code and would like to see some documentation on how this is suppose to be deployed given the TFA module policy that REST authentication should be prohibited.

  • Status changed to Needs review 5 months ago
  • 🇳🇱Netherlands arlanschouwstra

    Im sorry, but I don't see any policy regarding this topic. Can you provide further information regarding this topic?
    This module utilizes the logic of you TFA module, so it can be used for headless applications. Are you implying that headless TFA is prohibited?

    For documentation how you can access/enable the endpoints, this is provided in on the module page and inside the readme. Is there anything more you want to see?

  • Status changed to Needs work 5 months ago
  • 🇺🇸United States cmlara

    Are you implying that headless TFA is prohibited?

    As part of

    ">SA-CONTRIB-2023-030 the TFA module locked down authentication and advised all sites to disable additional login methods (such as REST) due to known faults where TFA was not enforcing authentication. This advice is still current for the 1.x branch (the 2.x branch is believed to no longer have this constraint and I’ve spent the time since that announcement last year overhauling TFA’s architecture).

    To the best of my knowledge that generally prohibits a headless deployment with the 1.x branch of TFA as only the login form properly enforces the use of second factor authentication.

    Im sorry, but I don't see any policy regarding this topic. Can you provide further information regarding this?

    My concern is based on the limited documentation in the module their either is a step to secure TFA to work in a headless environment that is not documented (users will need to know this), that code exists in your repo that provides this protection (that on a cursory review I’m not seeing) or that the TFA module is being (accidentally) encouraged to be used in a setup that is known insecure.

    I’m trying to give benefit of the doubt and assume there is something in how you or another skilled user may deploy this that renders the concerns of the security advisory not relevant that if provided here would help this review process move forward.

    Ensuring that code is used correctly and securely is a critical part of this review process. While I would not necessarily consider any of the above to be direct security vulnerability in TFA Headless (as TFA holds initial responsibility for securing the platform) if no additional lockdown is provided it would appear the module would either be non-functional or that key information related to the secure use of the TFA is missing. Both directly relate to securely using the TFA modules public methods.

  • 🇮🇳India vishal.kadam Mumbai

    I am changing priority as per Issue priorities .

  • 🇮🇳India rushiraval

    This thread has been idle, in the needs work state with no activity for several months. Therefore, I am assuming that you are no longer pursuing this application. If you are no longer pursuing this application then I mark it as Closed (won't fix).

    If this is incorrect, and you are still pursuing this application, then please feel free to set the issue status to Needs work or Needs review, depending on the current status of your code.

Production build 0.71.5 2024