Welcome Guest, Not a member yet? Register   Sign In
Google Two-Factor Authentication Module for Shield

As the title explains I've created a module for use with Shield that provides two-factor authentication using the Google Authenticator app. I explain in more detail on a thread regarding Docker. Instead of using email or SMS, this uses an on-screen QR code to generate Time-Based One-Time Passwords. It is a fork whose repository structure and code have been modified to act as a pluggable module. It has two Composer prerequisites: Google2FA, and BaconQRCode.

I called it Halberd, and I hope it helps.

It sounds great I will give it a try!!!!!
Do Codeigniter Before Do You!


@grimpirate Good job,

I took a look at your code, why is forked from Shield, you have to configure your own composer.js file.

Read here for more information.

Also, the license must be in your name, not Lonnie Ezell Smile :

Thank you for sharing.

Yes, your package could be more easily installed,
just one composer  command.

(This post was last modified: 02-22-2023, 11:38 AM by grimpirate.)

@datamweb I forked it from Shield because the Actions that I created are modifications of the Email Actions provided by default by shield. So as a matter of complying with the MIT license I left the file there untouched. Figure if there's a trail of where the code was mostly derived from it can help others derive similar Authentication modules, and it's just good open source transparency in my opinion.

@datamweb & @kenjis Learning how to make a composer package is my next step. I know how to use composer, but don't know how to author with it as yet.

I've created a composer package for the module
composer require grimpirate/halberd:dev-main

This package is separate from Shield, so you can issue a license in your own name.

Forking from Shield is a wrong thing, you should create all the files from scratch and register them in your own name.

Please change the namespace from Halberd to Grimpirate/Halberd.

@grimpirate Oh, great! Now grimpirate/halberd can be installed via Composer!

But forking from Shield is not good. Because you can have only one fork for one repository.
You cannot (or it is very difficult) send to a PR to Shield if you want.
I recommend you remove the current repository and create new one with the same name.

I've imported and renamed the repository to unfork it, that way the contributions to the project remain.

(This post was last modified: 02-23-2023, 01:21 PM by datamweb.)

It is not a good practice to load the helper through composer, it is better to manually load the helper file wherever you need it. In Shield, the situation is different.

The use of namespace is not required in the language file, so remove it.

Oh, you used Registrar to set the actions, that's a disaster, please remove it and explain in the docs how you can apply the actions option in the file Auth.php(shield).

(This post was last modified: 02-23-2023, 02:50 PM by grimpirate.)

@datamweb thank you for the callouts regarding namespace and the helper functions. However, I fail to see the benefit of setting the actions manually.

If the person elected to use Halberd, it follows that they will always populate those two actions with the Halberd classes (otherwise you'd be using something other than Halberd). The login action can't work without the register action, and using only the register action essentially makes it function like an overly complicated CAPTCHA test (no one should want to do this).

If they wanted to stop using Halberd then they could use composer to remove it without affecting the overall Shield system and leaving Auth.php in a state that requires no editing. That seems a better and more modular approach to me.

If at some point I code the login action to function independently of the register action then your approach makes sense to me. In its present state however, I believe it's functioning as it should.

Theme © iAndrew 2016 - Forum software by © MyBB