Skip to content

luci-plugin-2fa: init checkin#8280

Merged
systemcrash merged 1 commit intoopenwrt:masterfrom
Tokisaki-Galaxy:tokisaki-luci-app-otp
Apr 7, 2026
Merged

luci-plugin-2fa: init checkin#8280
systemcrash merged 1 commit intoopenwrt:masterfrom
Tokisaki-Galaxy:tokisaki-luci-app-otp

Conversation

@Tokisaki-Galaxy
Copy link
Copy Markdown
Contributor

@Tokisaki-Galaxy Tokisaki-Galaxy commented Jan 29, 2026

2026-02-04.180055.mp4
image

the app must changed LuCI core file because:

  • No hook point exists between password verification and session creation
  • External packages cannot inject authentication logic
  • No plugin discovery mechanism in the original code

Security Measures

Constant-time string comparison to prevent timing attacks
Username sanitization to prevent command injection
Array-based popen to prevent shell injection
OTP format validation (exactly 6 digits)
Session destroyed if 2FA verification fails
Uses authenticated session username to prevent bypass attacks

origin repo https://github.com/Tokisaki-Galaxy/luci-app-2fa

@github-actions

This comment has been minimized.

@Neustradamus
Copy link
Copy Markdown

@Tokisaki-Galaxy: Nice, good job!

Do not forget to solve:

🔶 Author name (Tokisaki-Galaxy) seems to be a nickname or an alias
🔶 Committer name (Tokisaki-Galaxy) seems to be a nickname or an alias

@stangri
Copy link
Copy Markdown
Member

stangri commented Jan 29, 2026

Looks very polished @Tokisaki-Galaxy!

Does this use TOTP? If the OpenWrt device doesn't have RTC and is offline or generally doesn't have correct time, does SSH become the only option to login?

Is there a README/instructions (ideally a hint on failed attempt) on how to disable 2FA from SSH/CLI for people who may be locked out of WebUI and can't read code ahead of time?

@Tokisaki-Galaxy
Copy link
Copy Markdown
Contributor Author

Tokisaki-Galaxy commented Jan 30, 2026

@stangri

Please refer to the newly added video at the top of the description section for details.

The plugin can choose either TOTP or HOTP, but TOTP is recommended.
For RTC clock that is not synchronized (for example, the year is 1970), users can choose the 2fa behavior (strict mode) through options. By default, LAN areas are allowed to bypass 2FA for login, while non-LAN areas are prohibited. It can be configured to allow anyone to bypass 2FA for login.

Regarding the documentation for SSH/CLI, I'm not quite sure where it should be placed. Should it be directly included in the web UI? But if users don't read it carefully, they might not be able to log in and it would be impossible to see the result. Do you have any suggestions?

Previously, it was planned to add backup code, but this was abandoned because it would cause the bitward auto-fill function to become unusable and the complexity would be too high.

Tokisaki-Galaxy

This comment was marked as outdated.

@Tokisaki-Galaxy Tokisaki-Galaxy changed the title [WIP] luci-app-2fa: init checkin luci-app-2fa: init checkin Feb 2, 2026
@Tokisaki-Galaxy Tokisaki-Galaxy force-pushed the tokisaki-luci-app-otp branch 2 times, most recently from d55e8c5 to 0e97b5b Compare February 2, 2026 04:46
@github-actions

This comment has been minimized.

@Tokisaki-Galaxy Tokisaki-Galaxy force-pushed the tokisaki-luci-app-otp branch 2 times, most recently from fe02937 to bed757a Compare February 2, 2026 09:50
@systemcrash systemcrash mentioned this pull request Mar 16, 2026
10 tasks
@systemcrash
Copy link
Copy Markdown
Contributor

@Tokisaki-Galaxy let's see whether the plugin structure needs some modifications to handle 2FA stuff.

@Tokisaki-Galaxy
Copy link
Copy Markdown
Contributor Author

@systemcrash
branch have update

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@Tokisaki-Galaxy Tokisaki-Galaxy force-pushed the tokisaki-luci-app-otp branch from 6561e45 to ef1dfdd Compare April 1, 2026 11:45
@Tokisaki-Galaxy Tokisaki-Galaxy force-pushed the tokisaki-luci-app-otp branch 2 times, most recently from e3d2761 to f91d3eb Compare April 2, 2026 01:58
@Tokisaki-Galaxy
Copy link
Copy Markdown
Contributor Author

Tokisaki-Galaxy commented Apr 2, 2026

Refactored generate_otp.uc to leverage ucode native modules and built-in features. replaces the manual implementations, improving performance

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@systemcrash
Copy link
Copy Markdown
Contributor

OK - thanks for your patience. This is looking good now. LGTM.

@Tokisaki-Galaxy
Copy link
Copy Markdown
Contributor Author

Thank you so much for your patience and thorough review!
To be honest, I’m truly grateful—this is the first time I’ve had someone review my PRs with such care and provide such constructive feedback.

As a non-CS university student with no professional work experience yet, I’ve learned a lot through this process. This project has given me my first real taste of large-scale team collaboration, and your guidance has been invaluable in helping me improve.
Thank you again for your time and for helping me grow!

@Tokisaki-Galaxy Tokisaki-Galaxy force-pushed the tokisaki-luci-app-otp branch from 1d9eaf6 to a54c74d Compare April 5, 2026 15:31
@github-actions

This comment has been minimized.

@Tokisaki-Galaxy Tokisaki-Galaxy marked this pull request as ready for review April 6, 2026 15:55
@systemcrash
Copy link
Copy Markdown
Contributor

To highlight that this is a plugin, how about naming it luci-plugin-2fa?

@Tokisaki-Galaxy Tokisaki-Galaxy force-pushed the tokisaki-luci-app-otp branch 2 times, most recently from c1a9e39 to 28bcab6 Compare April 7, 2026 10:30
@Tokisaki-Galaxy
Copy link
Copy Markdown
Contributor Author

great! I have rename and rebase commit

Co-authored-by: Christian Marangi <ansuelsmth@gmail.com>
Signed-off-by: Han Yiming <moebest@outlook.jp>

luci-app-2fa: add priority option and QR code display

This update adds a priority option and enables QR code display for 2FA.

luci-app-2fa: native ubus IPvalid fsLOCK and log

use native ubus IP validation instead of custom regex
and parsing, use native fs lock instead of popen-call
and add log for logging auth events.

now, will clean stale rate limit entries on each check
and log when entries are removed due to staleness.
This prevents the rate limit file from growing
indefinitely with old entries.

luci-app-2fa: move dir and sync sysfixtime

move to the new location. update the default time
calibration threshold to sync sysfixtime.

luci-app-2fa: native hex and more readable

use native hex and base32 decoding functions

Signed-off-by: Han Yiming <moebest@outlook.jp>
@Tokisaki-Galaxy Tokisaki-Galaxy force-pushed the tokisaki-luci-app-otp branch from 28bcab6 to 1833462 Compare April 7, 2026 13:37
@Tokisaki-Galaxy
Copy link
Copy Markdown
Contributor Author

Tokisaki-Galaxy commented Apr 7, 2026 via email

@systemcrash systemcrash changed the title luci-app-2fa: init checkin luci-plugin-2fa: init checkin Apr 7, 2026
@systemcrash
Copy link
Copy Markdown
Contributor

OK - let's see how it works :)

@systemcrash systemcrash merged commit b1450ce into openwrt:master Apr 7, 2026
5 checks passed
@Tokisaki-Galaxy Tokisaki-Galaxy deleted the tokisaki-luci-app-otp branch April 7, 2026 14:02
@Tokisaki-Galaxy
Copy link
Copy Markdown
Contributor Author

Thank you very much!

@Neustradamus
Copy link
Copy Markdown

@Tokisaki-Galaxy: Thanks for your good work and thanks to @systemcrash for merging!

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 8, 2026

Warning

Some formality checks failed.

Consider (re)reading submissions guidelines.

Failed checks

Issues marked with an ❌ are failing checks.

Commit 1833462

  • 🔶 Commit(ter) name must be either a real name 'firstname lastname' or a nickname/alias/handle
    Actual: GitHub seems to be a nickname or an alias
    Expected: a real name 'firstname lastname'

For more details, see the full job log.

Something broken? Consider providing feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants