The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

External Authentication customization

Discussion in 'User Experience' started by CostasK, Jan 29, 2016.

  1. CostasK

    CostasK Registered

    Joined:
    Jan 22, 2016
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Cyprus
    cPanel Access Level:
    Root Administrator
    Hello,

    Wondering how properly can I change label at cPanel login page for external auth.
    The default button looks like this one
    i.imgur.com/Jk7ZJ4j.png

    And I would like to make it like this one:

    i.imgur.com/Bc2Fhc0.png

    This is important for many hosting companies, as a WHMCS Client Area name differs on different providers and I am sure no one shows to clients that they use WHMCS as billing platform.
    I have managed to edit /usr/local/cpanel/Cpanel/Security/Authn/Provider/ file for a Label row, but I suspect after cPanel/WHM upgrade it changed again to the default. So, what is a proper way to edit it?
     
    #1 CostasK, Jan 29, 2016
    Last edited by a moderator: Jan 29, 2016
  2. cPanelDavidN

    cPanelDavidN Integration Developer
    Staff Member

    Joined:
    Dec 17, 2009
    Messages:
    571
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    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
     
  3. CostasK

    CostasK Registered

    Joined:
    Jan 22, 2016
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Cyprus
    cPanel Access Level:
    Root Administrator
  4. Damian

    Damian Well-Known Member

    Joined:
    Oct 1, 2001
    Messages:
    95
    Likes Received:
    1
    Trophy Points:
    8
    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.
     
  5. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    648
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello,

    Could you review /usr/local/cpanel/logs/error_log when this happens and let us know the output?

    Thank you.
     
  6. cPAndrewHodge

    cPAndrewHodge cPanel UI Developer
    Staff Member

    Joined:
    Dec 10, 2012
    Messages:
    52
    Likes Received:
    3
    Trophy Points:
    8
    cPanel Access Level:
    Root Administrator
    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.

    Code:
    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.
     

Share This Page