Ei kuvausta

Allan Barcelos 858cdb699e Update 'README.md' 4 tuntia sitten
.github 9bc145d9c0 fixes 4 kuukautta sitten
.mvn 9bc145d9c0 fixes 4 kuukautta sitten
.vscode 1c77faa011 first version, working 1 vuosi sitten
src 77396d8ead style: apply spotless so mvn verify passes on CI 4 tuntia sitten
.gitignore 1c77faa011 first version, working 1 vuosi sitten
DEVELOPMENT.md 88c106eca1 many fixes 1 vuosi sitten
Jenkinsfile 142501e6b1 ci: publish HPI from workspace, skip stash on built-in 4 tuntia sitten
LICENSE.md 1c77faa011 first version, working 1 vuosi sitten
README.md 92b3d9ab6b Update 'README.md' 4 tuntia sitten
SECURITY.md 88c106eca1 many fixes 1 vuosi sitten
ci.yaml a67a4b7cf5 ci: publish HPI to Gogs Releases on main 4 tuntia sitten
pom.xml 91b439a1ce fix bom 4 kuukautta sitten

README.md

🔐 MFA TOTP Authentication Plugin for Jenkins

Jenkins Plugin Jenkins Plugin Installs Build Status MIT License

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.

🌟 Key Features

  • 🔒 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

📥 Installation

Prerequisites

  • Jenkins 2.387.3 or later
  • Java 17+

Installation Methods

Method 1: Jenkins Plugin Manager

  1. Navigate to Manage JenkinsPluginsAvailable plugins
  2. Search for "MFA TOTP Plugin"
  3. Install and restart Jenkins

Method 2: Manual Installation

# Build the plugin
mvn clean package

# Then upload the .hpi file from target/ directory via:
# Manage Jenkins → Plugins → Advanced → Upload Plugin

🛠 Configuration Guide

Global Security Settings

  1. Go to Manage JenkinsConfigure 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

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

Configuration Screenshot

⚙️ Advanced Configuration

JSON API Configuration

curl -X POST http://your-jenkins/configure \
  -u admin:api_token \
  -H "Content-Type: application/json" \
  -d '{
    "mfa": {
      "enforceForAllUsers": true,
      "excludeApiTokens": false,
      "sessionDuration": 480
    }
  }'

Security Best Practices

  1. For Admins:

    • Enable MFA for all administrative accounts
    • Maintain emergency break-glass credentials
    • Regularly review MFA configurations
  2. For Users:

    • Use trusted authenticator apps
    • Store recovery codes securely
    • Rotate MFA secrets annually

🚨 Troubleshooting

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

Build Environment

mvn clean verify       # Run full build with tests
mvn hpi:run            # Launch test Jenkins instance

CI/CD (Gogs + Jenkins)

Pipeline is Jenkinsfile (contract also in ci.yaml).

On push to main and on pull requests targeting main, Jenkins:

  1. Runs mvn verify (unit + plugin tests) inside Docker
  2. Packages the .hpi
  3. Archives the plugin as a build artifact

Successful push to main also publishes the .hpi as a Gogs release.

Contribution Guidelines

  1. Fork the repository
  2. Create feature branches (feature/your-feature)
  3. Submit pull requests with clear descriptions

🔒 Security Policy

Vulnerabilities should be reported following Jenkins security guidelines. Please do not disclose security issues publicly.

📜 License

Licensed under MIT License.


✉️ Contact: For support questions, please use the Jenkins community forums.

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