Skip to main content

External Authentication customization

Comments

5 comments

  • cPanelDavidN
    Hi CostasK You're basically correct. All authorization providers are managed through Perl modules located in /usr/local/cpanel/Cpanel/Security/Authn/Provider/ . If you modify one that is shipped by cPanel, then yes, it will be overwritten on future upgrades. However, if you copy the WHMCS.pm and rename to something unique, it should persist and never by overwritten. Your custom module can define the button color, button text, and logo. Once you have a custom module in that directory, it should appear in the WHM External Authentication interface for you to enable/disable, just like the ones shipped by cPanel. As a side note, it is more ideal that your customization actually inherit from WHMCS.pm (or OpenIdConnectBase.pm, cPanelID.pm, etc). This is better because any upstream changes that cPanel ships will automatically be a part of your module, and only the properties (such as text, logo, color) will be unique to your module. Here's an example of 'CostasK' where in the Display Name has changed to 'CostasK' and the button background is orange. This would be saved as CostasK.pm in that directory: ======== package Cpanel::Security::Authn::Provider::CostasK; # cpanel - Cpanel/Security/Authn/Provider/CostasK.pm use strict; use parent 'Cpanel::Security::Authn::Provider::WHMCS'; sub _DISPLAY_NAME { return 'CostasK'; } sub _PROVIDER_NAME { return 'costask'; } sub _BUTTON_COLOR { return 'FE9900'; } sub _BUTTON_TEXT_COLOR { return 'FFFFFF'; } 1; ======== The mechanics of Perl inheritance (at least for this scope of this conversation) is straight forward. Simply "use parent " and redefine any property or subroutine as necessary. The ones of note are going to be the ones at the top of the module like 'sub _ALL_CAPS {}'. You can reference the cPanel documentation on making custom modules for OpenID here: Guide to External Authentication - OpenID Connect - Software Development Kit - cPanel Documentation
    0
  • CostasK

    Hi cPanelDavidN, Thank you!
    0
  • Damian
    Hello, I'm trying to use the example above and whilst my custom button appears on the login screen and I can enter valid WHMCS user credentials that's as far as it goes. When submitted the server returns a 500 error. I am not sure where or what to look at.
    0
  • cPanelMichael
    Hello, I'm trying to use the example above and whilst my custom button appears on the login screen and I can enter valid WHMCS user credentials that's as far as it goes. When submitted the server returns a 500 error. I am not sure where or what to look at.

    Hello, Could you review /usr/local/cpanel/logs/error_log when this happens and let us know the output? Thank you.
    0
  • AndrewH.
    As a heads up, in 58 we have released API's that allow you to update the display configuration of the login buttons for external authentication.
    set_provider_display_configurations - $args - { 'service_name' => 'cpaneld' - which service to set provider configurations for 'provider_id' => 'google' - which provider to set configurations for 'configurations' => '{"field":"value"}' - JSON encoded string of field values for a specific provider }
    For now the documentation isn't live(should be by end of month) but for future readers it will be what you use.
    0

Please sign in to leave a comment.