Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsOther Extension...Other Extension...Settings for new authentication system providerSettings for new authentication system provider
Previous
 
Next
New Post
9/29/2017 9:20 PM
 

Hello guys.

I'm trying to create a new authentication system provider (for authenticating users through SAML form post) and I'm a little stuck on how to make the settings form look like the settings of the other providers (login and logoff are already working well). 

The first thing I'd like to know is what do I need to do in order for my settings dialog have the same look as the one that standard authentication services settings have. For instance, here's how my settings look now:

 I'd like them to look like this 

I've tried to reproduce the code used by the Google authentication system provider, but I'm surely missing something because the results are completely different (just compare the previous images). The first question I have is how do I get those beautiful styles applied to my settings form? In my case, I've ended up only with a single button and the controls aren't styled like the ones generated by the google authentication settings. 

The second question I have is why do I have that blue header (chrome dev tools show that it's a fieldset) at the top?

The third question is how does the google authentication settings manage to get away with those labels names (App Id and App Secret - notice that these names are different from the property names of the settings class that is bound to the PropertyEditorControl). I've tried looking for attributes that might influence this, but haven't found any. In order to change the labels shown by my custom settings forms, I've ended setting the AutoGenerate property of the PropertyEditorControl to false and I had to handle the OnItemCreated event of the FieldEditorControl. BTW, How can I change the help text that's shown? In my case, it ends up showing the same value as the name of the property...

Is there any support for related properties? For instance, in my case, one of the setting properties should have the same value as one of the lines of another setting's property. Is there any easy way for performing this setup? How am I supposed to validate this?

I've tried to base my code on the one used by the out of the box oauth authentication system providers. Since my provider is not an OAuth provider, I didn't reuse the base classes, but I've ported most of the code. Here's my settings class that is bound to the PropertyEditorControl:

namespace Pagesp.Authentication.CartaoCidadao.Components {
    public class CartaoCidadaoConfigBase : AuthenticationConfigBase {
        private const string _cacheKey = "CCAuthentication";
        public CartaoCidadaoConfigBase(string service, int portalId) : base(portalId) {
            Service = service;
            Thumbprint = PortalController.GetPortalSetting(Service + "_Thumbprint", portalId, "");
            //other properties initialized in similar way
        }

        protected string Service { get; set; }
        public string Thumbprint { get; set; }
       //other properties are similar
        private static string GetCacheKey(string service, int portalId) {
            return _cacheKey + "." + service + "_" + portalId;
        }
        public static void ClearConfig(string service, int portalId) {
            DataCache.RemoveCache(GetCacheKey(service, portalId));
        }
        public static CartaoCidadaoConfigBase GetConfig(string service, int portalId) {
            var key = GetCacheKey(service, portalId);
            var config = (CartaoCidadaoConfigBase) DataCache.GetCache(key);
            if (config == null) {
                config = new CartaoCidadaoConfigBase(service, portalId);
                DataCache.SetCache(key, config);
            }
            return config;
        }
        public static void UpdateConfig(CartaoCidadaoConfigBase config) {
            PortalController.UpdatePortalSetting(config.PortalID, config.Service + "_Thumbprint", config.Thumbprint);
            // other properties saved in similar fashion
            ClearConfig(config.Service, config.PortalID);
        }
    }
}

Since I didn't find a way to change the way the PropertyEditorControl renders the labels, I've decided to use FieldEditorControl entries for setting up the properties:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Settings.ascx.cs" Inherits="Pagesp.Authentication.CartaoCidadao.Settings" %>
<%@ Register TagPrefix="dnn" Namespace="DotNetNuke.UI.WebControls" Assembly="DotNetNuke" %>
<%@ Register TagPrefix="cc" Namespace="Pagesp.Authentication.CartaoCidadao.Components" Assembly="Pagesp.Authentication.CartaoCidadao" %>
<dnn:propertyeditorcontrol id="SettingsEditor" runat="Server" 
                           helpstyle-cssclass="dnnFormHelpContent dnnClear" 
                           labelstyle-cssclass="SubHead"     
                           editmode="Edit"
                           SortMode="SortOrderAttribute" 
    AutoGenerate="False">
    <Fields>
        <dnn:FieldEditorControl runat="server"  DataField="Provider" 
            Required="True" OnItemCreated="HandleItemCreated"></dnn:FieldEditorControl>
<!-- Other FieldEditorControls are similar -->
    </Fields>
</dnn:propertyeditorcontrol>

And here's the codebehind file:

namespace Pagesp.Authentication.CartaoCidadao {
    public partial class Settings : AuthenticationSettingsBase {
        protected PropertyEditorControl SettingsEditor;
        public string AuthSystemApplicationName => "CartaoCidadao";
        //Used for mapping prop names into different labels
        public static readonly Dictionary<string, string> _mapeamentos = new Dictionary<string, string> {
                                           {"Provider", "Nome do Provider"},
//other mappings removed

                                       };
           public override void UpdateSettings() {
               if (SettingsEditor.IsValid && SettingsEditor.IsDirty) {
                   var config = (CartaoCidadaoConfigBase) SettingsEditor.DataSource;
                   CartaoCidadaoConfigBase.UpdateConfig(config);
               }
           }
           protected override void (EventArgs e) {
               base. (e);
               var config = CartaoCidadaoConfigBase.GetConfig(AuthSystemApplicationName, PortalId);
               SettingsEditor.DataSource = config;
               SettingsEditor.DataBind();
           }
           protected void HandleItemCreated(object sender, PropertyEditorItemEventArgs e) {
               if (_mapeamentos.TryGetValue(e.Editor.Name, out var label)) {
                   e.Editor.Name = label;
               }
           }
    }
}

So, any help on how to solve this? 

Thanks!

 

Regards,

Luis


 

 

 
New Post
10/2/2017 1:33 PM
 
Hello guys.

Answering some of my previous questions after some digging around the source code :)

Regarding the label names and help feedback, the answer is rather simple: just add the required entries to the resource files associated with the settings user control. For instance, if you're binding the property grid to a class named MySettings, which has a property named Info, just add and entry named MySettings_Info.Text for setting the label's text and an entry named MySettings_Info.Help for setting the help text (shown when the user hovers over the help icon).

Now, there's still the styles question...anyone knows how do the google and facebook authentication providers get away with that look? I've tried to follow the source code, but it looks like it's using the PropertyEditorControl. However, the results are really different...

Thanks.

Regards,
Luis
 
New Post
10/3/2017 8:51 AM
 
Not sure on what happened to the previous reply, so here it goes again...

Regarding the label names and help text, I've found the solution after digging in the source code. So, if you provide a resource file and if there are entries on the form ClassName_Property.Text and ClassName_Property.Help, those entries will be used for the label and help respectively...

Now, only need to understand how those styles are generated...
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsOther Extension...Other Extension...Settings for new authentication system providerSettings for new authentication system provider


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out