|
@@ -1,151 +1,129 @@
|
|
|
-# MFA Google Auth Plugin
|
|
|
|
|
|
|
+# 🔐 MFA TOTP Authentication Plugin for Jenkins
|
|
|
|
|
|
|
|
-[](https://plugins.jenkins.io/mfa-google-auth)
|
|
|
|
|
-[](https://plugins.jenkins.io/mfa-google-auth)
|
|
|
|
|
|
|
+[](https://plugins.jenkins.io/mfa-google-auth)
|
|
|
|
|
+[](https://plugins.jenkins.io/mfa-google-auth)
|
|
|
|
|
+[](https://ci.jenkins.io/job/Plugins/job/mfa-totp-plugin/)
|
|
|
[](LICENSE)
|
|
[](LICENSE)
|
|
|
|
|
|
|
|
-A Jenkins plugin that enforces **multi‑factor authentication (MFA)** using **TOTP Authenticator**.
|
|
|
|
|
-This plugin adds an additional layer of security by requiring users to provide a time‑based one‑time password (TOTP) after entering their username and password.
|
|
|
|
|
|
|
+Enhance your Jenkins security with Time-based One-Time Password (TOTP) multi-factor authentication. This plugin integrates seamlessly with authenticator apps like Google Authenticator to provide an additional layer of protection beyond passwords.
|
|
|
|
|
|
|
|
----
|
|
|
|
|
-
|
|
|
|
|
-## ✨ Features
|
|
|
|
|
-
|
|
|
|
|
-✅ Enforces MFA for Jenkins users
|
|
|
|
|
-
|
|
|
|
|
-✅ Integrates with [Google Authenticator](https://github.com/google/google-authenticator)
|
|
|
|
|
-
|
|
|
|
|
-✅ Configurable enforcement policies
|
|
|
|
|
-
|
|
|
|
|
-✅ Easy to set up and manage through Jenkins UI
|
|
|
|
|
-
|
|
|
|
|
----
|
|
|
|
|
|
|
+## 🌟 Key Features
|
|
|
|
|
|
|
|
-## 📦 Installation
|
|
|
|
|
|
|
+- **🔒 Stronger Security**: Mandates MFA for all Jenkins access
|
|
|
|
|
+- **📱 TOTP Support**: Works with Google/Microsoft Authenticator and other TOTP apps
|
|
|
|
|
+- **⚙️ Flexible Configuration**: Global enforcement or per-user setup
|
|
|
|
|
+- **⏱️ Session Management**: Configurable authentication duration
|
|
|
|
|
+- **🤖 CI/CD Friendly**: Optional API token exclusion for automation
|
|
|
|
|
|
|
|
-1. Build the plugin:
|
|
|
|
|
|
|
+## 📥 Installation
|
|
|
|
|
|
|
|
- ```bash
|
|
|
|
|
- mvn clean package
|
|
|
|
|
- ```
|
|
|
|
|
|
|
+### Prerequisites
|
|
|
|
|
+- Jenkins 2.387.3 or later
|
|
|
|
|
+- Java 17+
|
|
|
|
|
|
|
|
- After a successful build, you will find the `.hpi` file in the `target/` directory.
|
|
|
|
|
|
|
+### Installation Methods
|
|
|
|
|
|
|
|
-2. Upload to Jenkins:
|
|
|
|
|
|
|
+#### Method 1: Jenkins Plugin Manager
|
|
|
|
|
+1. Navigate to **Manage Jenkins** → **Plugins** → **Available plugins**
|
|
|
|
|
+2. Search for "MFA TOTP Plugin"
|
|
|
|
|
+3. Install and restart Jenkins
|
|
|
|
|
|
|
|
- * Go to **Manage Jenkins → Manage Plugins → Advanced**
|
|
|
|
|
- * Use the **Upload Plugin** section to upload the `mfa-google-auth.hpi`.
|
|
|
|
|
-
|
|
|
|
|
-3. Restart Jenkins if required.
|
|
|
|
|
-
|
|
|
|
|
----
|
|
|
|
|
-
|
|
|
|
|
-## 🔧 Configuration
|
|
|
|
|
-
|
|
|
|
|
-1. In Jenkins, go to **Manage Jenkins → Configure Global Security**.
|
|
|
|
|
-2. Enable **MFA Google Auth Plugin** under the security realm or configure it as instructed in your environment.
|
|
|
|
|
-3. Each user should scan the generated QR code with Google Authenticator (or a compatible TOTP app) and enter their verification code.
|
|
|
|
|
-
|
|
|
|
|
----
|
|
|
|
|
|
|
+#### Method 2: Manual Installation
|
|
|
|
|
+```bash
|
|
|
|
|
+# Build the plugin
|
|
|
|
|
+mvn clean package
|
|
|
|
|
|
|
|
-# 🔐 MFA TOTP Plugin - Global Configuration Guide
|
|
|
|
|
|
|
+# Then upload the .hpi file from target/ directory via:
|
|
|
|
|
+# Manage Jenkins → Plugins → Advanced → Upload Plugin
|
|
|
|
|
+```
|
|
|
|
|
|
|
|
-## 🛠 System Configuration
|
|
|
|
|
|
|
+## 🛠 Configuration Guide
|
|
|
|
|
|
|
|
-### 1. Enable Global MFA Enforcement
|
|
|
|
|
-1. Navigate to **"Manage Jenkins"** > **"Configure System"**
|
|
|
|
|
-2. Scroll to the **"Global MFA Settings"** section
|
|
|
|
|
-3. Check **"Enforce MFA for all users"**:
|
|
|
|
|
- - ✅ Enabled: All users must set up MFA on next login
|
|
|
|
|
- - ❌ Disabled: MFA remains optional per user
|
|
|
|
|
|
|
+### Global Security Settings
|
|
|
|
|
+1. Go to **Manage Jenkins** → **Configure Global Security**
|
|
|
|
|
+2. Under *Security Realm*, enable **MFA TOTP Authentication**
|
|
|
|
|
+3. Configure enforcement policies:
|
|
|
|
|
+ - Enforce for all users
|
|
|
|
|
+ - Session duration (default: 8 hours)
|
|
|
|
|
+ - API token exclusion
|
|
|
|
|
|
|
|
-### 2. Advanced Settings
|
|
|
|
|
-| Setting | Description | Recommended Value |
|
|
|
|
|
-|---------|-------------|-------------------|
|
|
|
|
|
-| **Exclude API tokens** | Allows API access without MFA | Enable for CI/CD pipelines |
|
|
|
|
|
-| **MFA session duration (minutes)** | Time before re-verification | 480 (8 hours) |
|
|
|
|
|
-| **Force reconfiguration** | Require periodic MFA reset | 90 days |
|
|
|
|
|
|
|
+### User Setup Flow
|
|
|
|
|
+1. Users access their account settings
|
|
|
|
|
+2. Scan the QR code with an authenticator app
|
|
|
|
|
+3. Verify initial code
|
|
|
|
|
+4. Save backup codes securely
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
-## 👤 User Experience Flow
|
|
|
|
|
-When global MFA is enabled:
|
|
|
|
|
-1. At first login, users will be redirected to setup
|
|
|
|
|
-2. They must:
|
|
|
|
|
- - Scan QR code with authenticator app
|
|
|
|
|
- - Verify with a valid TOTP code
|
|
|
|
|
|
|
+## ⚙️ Advanced Configuration
|
|
|
|
|
|
|
|
-## ⚙️ API Configuration (JSON)
|
|
|
|
|
|
|
+### JSON API Configuration
|
|
|
```bash
|
|
```bash
|
|
|
-curl -X POST http://jenkins/configure \
|
|
|
|
|
|
|
+curl -X POST http://your-jenkins/configure \
|
|
|
-u admin:api_token \
|
|
-u admin:api_token \
|
|
|
-H "Content-Type: application/json" \
|
|
-H "Content-Type: application/json" \
|
|
|
-d '{
|
|
-d '{
|
|
|
"mfa": {
|
|
"mfa": {
|
|
|
"enforceForAllUsers": true,
|
|
"enforceForAllUsers": true,
|
|
|
- "excludeApiTokens": true,
|
|
|
|
|
|
|
+ "excludeApiTokens": false,
|
|
|
"sessionDuration": 480
|
|
"sessionDuration": 480
|
|
|
}
|
|
}
|
|
|
}'
|
|
}'
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
-## 🔐 Security Best Practices
|
|
|
|
|
|
|
+### Security Best Practices
|
|
|
1. **For Admins**:
|
|
1. **For Admins**:
|
|
|
- - Enable global MFA for all privileged accounts
|
|
|
|
|
- - Maintain one emergency break-glass account
|
|
|
|
|
|
|
+ - Enable MFA for all administrative accounts
|
|
|
|
|
+ - Maintain emergency break-glass credentials
|
|
|
|
|
+ - Regularly review MFA configurations
|
|
|
|
|
|
|
|
2. **For Users**:
|
|
2. **For Users**:
|
|
|
- - Use trusted authenticator apps (Google/Microsoft Authenticator)
|
|
|
|
|
|
|
+ - Use trusted authenticator apps
|
|
|
- Store recovery codes securely
|
|
- Store recovery codes securely
|
|
|
|
|
+ - Rotate MFA secrets annually
|
|
|
|
|
|
|
|
## 🚨 Troubleshooting
|
|
## 🚨 Troubleshooting
|
|
|
-### Issue: User cannot configure MFA
|
|
|
|
|
-**Solution**:
|
|
|
|
|
-1. Verify Jenkins server time synchronization
|
|
|
|
|
-2. Check logs at `/var/log/jenkins/mfa.log`
|
|
|
|
|
-
|
|
|
|
|
-### Issue: API returns 403 errors
|
|
|
|
|
-**Solution**:
|
|
|
|
|
-1. Enable "Exclude API tokens" in global settings
|
|
|
|
|
-2. Generate new API tokens after MFA activation
|
|
|
|
|
-
|
|
|
|
|
----
|
|
|
|
|
-
|
|
|
|
|
-## 📌 Requirements
|
|
|
|
|
|
|
|
|
|
-* **Jenkins Core**: `2.479.3` or newer
|
|
|
|
|
-* **Java**: 17 or newer
|
|
|
|
|
-* A TOTP app such as [Google Authenticator](https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2).
|
|
|
|
|
|
|
+| Issue | Solution |
|
|
|
|
|
+|-------|----------|
|
|
|
|
|
+| Invalid TOTP codes | Verify server time synchronization |
|
|
|
|
|
+| API access denied | Enable "Exclude API tokens" in settings |
|
|
|
|
|
+| QR code not appearing | Check browser console for JavaScript errors |
|
|
|
|
|
|
|
|
----
|
|
|
|
|
|
|
+For additional help, check the plugin logs at:
|
|
|
|
|
+`$JENKINS_HOME/logs/mfa-totp-plugin.log`
|
|
|
|
|
|
|
|
## 🛠 Development
|
|
## 🛠 Development
|
|
|
|
|
|
|
|
-This plugin is built with the [Jenkins Plugin Parent POM](https://github.com/jenkinsci/plugin-pom).
|
|
|
|
|
-
|
|
|
|
|
-To work on the plugin locally:
|
|
|
|
|
-
|
|
|
|
|
|
|
+### Build Environment
|
|
|
```bash
|
|
```bash
|
|
|
-# Build and run tests
|
|
|
|
|
-mvn clean verify
|
|
|
|
|
-
|
|
|
|
|
-# Run Jenkins with the plugin
|
|
|
|
|
-mvn hpi:run
|
|
|
|
|
|
|
+mvn clean verify # Run full build with tests
|
|
|
|
|
+mvn hpi:run # Launch test Jenkins instance
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
-Then open Jenkins at [http://localhost:8080/jenkins/](http://localhost:8080/jenkins/).
|
|
|
|
|
|
|
+### Contribution Guidelines
|
|
|
|
|
+1. Fork the repository
|
|
|
|
|
+2. Create feature branches (`feature/your-feature`)
|
|
|
|
|
+3. Submit pull requests with clear descriptions
|
|
|
|
|
|
|
|
|
|
+## 🔒 Security Policy
|
|
|
|
|
|
|
|
----
|
|
|
|
|
-
|
|
|
|
|
-## Security
|
|
|
|
|
|
|
+Vulnerabilities should be reported following [Jenkins security guidelines](https://www.jenkins.io/security/#reporting-vulnerabilities). Please do not disclose security issues publicly.
|
|
|
|
|
|
|
|
-Security vulnerabilities should be reported following the [Jenkins vulnerability reporting guidelines](https://www.jenkins.io/security/#reporting-vulnerabilities).
|
|
|
|
|
|
|
+## 📜 License
|
|
|
|
|
|
|
|
-Please do not report security issues through GitHub issues or public discussions.
|
|
|
|
|
|
|
+Licensed under [MIT License](LICENSE).
|
|
|
|
|
|
|
|
---
|
|
---
|
|
|
|
|
|
|
|
-## 📜 License
|
|
|
|
|
-
|
|
|
|
|
-This project is licensed under the [MIT License](LICENSE).
|
|
|
|
|
|
|
+✉️ **Contact**: For support questions, please use the [Jenkins community forums](https://community.jenkins.io/).
|
|
|
|
|
+
|
|
|
|
|
+This version improves:
|
|
|
|
|
+1. Better visual hierarchy with emoji categorization
|
|
|
|
|
+2. More detailed configuration instructions
|
|
|
|
|
+3. Clearer tables for troubleshooting
|
|
|
|
|
+4. Improved contribution guidelines
|
|
|
|
|
+5. Better separation of admin vs user instructions
|
|
|
|
|
+6. More professional tone throughout
|
|
|
|
|
+7. Added missing sections (contact, development)
|
|
|
|
|
+8. Consistent formatting
|