PHPackages                             tarohida/tfa-custom - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Security](/categories/security)
4. /
5. tarohida/tfa-custom

ActiveDrupal-module[Security](/categories/security)

tarohida/tfa-custom
===================

TFAモジュールのカスタマイズ - ログイン後のリダイレクト先指定とメール送信制御

v1.1.0(7mo ago)0107MITPHPPHP &gt;=8.1

Since Oct 27Pushed 7mo agoCompare

[ Source](https://github.com/tarohida/tfa-custom)[ Packagist](https://packagist.org/packages/tarohida/tfa-custom)[ Docs](https://github.com/tarohida/tfa-custom)[ RSS](/packages/tarohida-tfa-custom/feed)WikiDiscussions main Synced 2w ago

READMEChangelogDependencies (2)Versions (8)Used By (0)

TFA Custom
==========

[](#tfa-custom)

[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE.txt)[![Drupal](https://camo.githubusercontent.com/3557da63b0992cb25b9e114bf60578bbf4a672fddc794131410d541d8a7742ca/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f64727570616c2d313025323025374325323031312d626c75652e737667)](https://www.drupal.org)

Drupal の Two-Factor Authentication (TFA) モジュールの動作をカスタマイズするモジュールです。

概要
--

[](#概要)

このモジュールは、Drupal の TFA モジュールに以下の機能を追加します：

- **ログイン後のリダイレクト先を自由に設定** - TFA 検証後の遷移先を管理画面から指定可能
- **メール送信の制御** - TFA 有効化/無効化時のメール通知を個別に ON/OFF 可能

主な機能
----

[](#主な機能)

### 1. カスタムリダイレクト

[](#1-カスタムリダイレクト)

TFA 検証成功後のリダイレクト先を管理画面から設定できます。

- デフォルト: `/` (フロントページ)
- 設定例: `/user`, `/dashboard`, `/admin` など
- パスワードリセット時の動作は元のまま維持

### 2. メール送信制御

[](#2-メール送信制御)

TFA の有効化/無効化時に送信される通知メールを個別に制御できます。

- TFA 有効化時のメール送信: ON/OFF 可能
- TFA 無効化時のメール送信: ON/OFF 可能

要件
--

[](#要件)

- **Drupal**: 10.x または 11.x
- **PHP**: 8.1 以上
- **依存モジュール**: [TFA (Two-Factor Authentication)](https://www.drupal.org/project/tfa)

インストール
------

[](#インストール)

### Composer 経由（推奨）

[](#composer-経由推奨)

```
composer require tarohida/tfa-custom
```

モジュールを有効化：

```
drush en tfa_custom -y
drush cr
```

### 手動インストール

[](#手動インストール)

1. このリポジトリをダウンロード
2. `web/modules/contrib/tfa_custom` または `web/modules/custom/tfa_custom` に配置
3. モジュールを有効化：

```
drush en tfa_custom -y
drush cr
```

設定方法
----

[](#設定方法)

1. **管理画面にアクセス**

    - URL: `/admin/config/people/tfa`
    - または: 設定 → ユーザー → TFA
2. **「Custom設定」タブをクリック**
3. **設定項目**

    **ログイン後のリダイレクト先**

    - TFA 検証後の遷移先を指定
    - 例: ``, `/user`, `/dashboard`, `/admin`

    **TFA有効化時にメールを送信**

    - チェックを入れる: メール送信する（デフォルト）
    - チェックを外す: メール送信しない

    **TFA無効化時にメールを送信**

    - チェックを入れる: メール送信する（デフォルト）
    - チェックを外す: メール送信しない
4. **「設定を保存」をクリック**

使用例
---

[](#使用例)

### 例1: ログイン後にダッシュボードへリダイレクト

[](#例1-ログイン後にダッシュボードへリダイレクト)

```
ログイン後のリダイレクト先: /dashboard

```

### 例2: メール送信を完全に無効化

[](#例2-メール送信を完全に無効化)

```
☐ TFA有効化時にメールを送信
☐ TFA無効化時にメールを送信

```

### Drush からの設定

[](#drush-からの設定)

```
# リダイレクト先を変更
drush config:set tfa_custom.settings redirect_after_login '/dashboard' -y

# メール送信を無効化
drush config:set tfa_custom.settings send_email_on_enable false -y
drush config:set tfa_custom.settings send_email_on_disable false -y

# キャッシュクリア
drush cr
```

技術仕様
----

[](#技術仕様)

### アーキテクチャ

[](#アーキテクチャ)

- **リダイレクト制御**: `hook_form_alter()` で TFA エントリーフォームにカスタム submit ハンドラーを追加
- **メール送信制御**: `hook_mail_alter()` でメール送信を動的に抑制
- **設定管理**: Drupal Configuration API を使用（`tfa_custom.settings`）

### ディレクトリ構成

[](#ディレクトリ構成)

```
tfa_custom/
├── composer.json                 # Composer パッケージ定義
├── LICENSE.txt                   # ライセンスファイル
├── README.md                     # このファイル
├── tfa_custom.info.yml          # モジュール情報
├── tfa_custom.module            # フック実装
├── tfa_custom.routing.yml       # ルート定義
├── tfa_custom.links.task.yml    # タブリンク定義
├── config/
│   ├── install/
│   │   └── tfa_custom.settings.yml    # デフォルト設定
│   └── schema/
│       └── tfa_custom.schema.yml      # 設定スキーマ
└── src/
    └── Form/
        └── TfaCustomSettingsForm.php  # 設定フォーム

```

トラブルシューティング
-----------

[](#トラブルシューティング)

### 設定が反映されない

[](#設定が反映されない)

キャッシュをクリアしてください：

```
drush cr
```

### 無効なパスを設定した場合

[](#無効なパスを設定した場合)

自動的にフロントページにリダイレクトされ、エラーログに記録されます：

```
drush watchdog:show --type=tfa_custom
```

関連モジュール
-------

[](#関連モジュール)

### TFA Message Japanese

[](#tfa-message-japanese)

TFA のエラーメッセージを日本語に対応させるモジュール：

- [tfa\_message\_ja](https://github.com/tarohida/tfa-message-ja)
- TFA エラーメッセージ内の時間表記を自動的に日本語化（"5 min" → "5分"）
- このモジュールと併用することで、より快適な日本語環境を実現

```
composer require tarohida/tfa-message-ja
drush en tfa_message_ja -y
```

セキュリティ上の注意
----------

[](#セキュリティ上の注意)

メール送信を無効化すると、ユーザーが TFA 設定変更の通知を受け取れなくなります。セキュリティポリシーを考慮の上、慎重に設定してください。

コントリビューション
----------

[](#コントリビューション)

バグ報告や機能リクエストは [GitHub Issues](https://github.com/tarohida/tfa-custom/issues) までお願いします。

プルリクエストも歓迎します！

ライセンス
-----

[](#ライセンス)

このプロジェクトは MIT ライセンスの下で公開されています。詳細は [LICENSE.txt](LICENSE.txt) をご覧ください。

作者
--

[](#作者)

- **tarohida** - [GitHub](https://github.com/tarohida)

リンク
---

[](#リンク)

- [GitHub リポジトリ](https://github.com/tarohida/tfa-custom)
- [Issue トラッカー](https://github.com/tarohida/tfa-custom/issues)
- [TFA モジュール (Drupal.org)](https://www.drupal.org/project/tfa)

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance64

Regular maintenance activity

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~3 days

Total

7

Last Release

217d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7699412498f9a0b5142cc26a8f79bb838b08de2a83227bca74c5dccc6e1ea961?d=identicon)[tarohida](/maintainers/tarohida)

---

Top Contributors

[![tarohida](https://avatars.githubusercontent.com/u/25278268?v=4)](https://github.com/tarohida "tarohida (15 commits)")

---

Tags

securitydrupalTwo Factor Authenticationtfa

### Embed Badge

![Health badge](/badges/tarohida-tfa-custom/health.svg)

```
[![Health](https://phpackages.com/badges/tarohida-tfa-custom/health.svg)](https://phpackages.com/packages/tarohida-tfa-custom)
```

###  Alternatives

[phpseclib/phpseclib

PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.

5.6k455.2M1.5k](/packages/phpseclib-phpseclib)[defuse/php-encryption

Secure PHP Encryption Library

3.9k170.7M239](/packages/defuse-php-encryption)[robrichards/xmlseclibs

A PHP library for XML Security

41582.2M138](/packages/robrichards-xmlseclibs)[spatie/laravel-csp

Add CSP headers to the responses of a Laravel app

86110.6M23](/packages/spatie-laravel-csp)[tzsk/otp

A secure, database-free One-Time Password (OTP) generator and verifier for PHP and Laravel.

243661.0k1](/packages/tzsk-otp)[mxr576/ddqg-composer-audit

Drupal Dependency Quality Gate Composer Audit plugin

1060.6k3](/packages/mxr576-ddqg-composer-audit)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
