Exemplo n.º 1
0
        private static void LoadCustomSettings(int portalId, PackageInfo package, AuthenticationInfo authSystem, AuthSystemPackageDetailDto detail)
        {
            var hasCustomSettings = !string.IsNullOrEmpty(authSystem.SettingsControlSrc);

            if (hasCustomSettings)
            {
                detail.SettingUrl = GetSettingUrl(portalId, package.PackageID);
            }

            // special case for DNN provided external authentication systems
            switch (detail.AuthenticationType.ToLowerInvariant())
            {
            case "facebook":
            case "google":
            case "live":
            case "twitter":
                var config = OAuthConfigBase.GetConfig(detail.AuthenticationType, portalId);
                if (config != null)
                {
                    detail.AppId      = config.APIKey;
                    detail.AppSecret  = config.APISecret;
                    detail.AppEnabled = config.Enabled;
                }
                break;
            }
        }
Exemplo n.º 2
0
 public override void UpdateSettings()
 {
     if (SettingsEditor.IsValid && SettingsEditor.IsDirty)
     {
         var config = (OAuthConfigBase)SettingsEditor.DataSource;
         OAuthConfigBase.UpdateConfig(config);
     }
 }
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            OAuthConfigBase.ClearConfig(AuthSystemApplicationName, PortalId);
            var config = AzureConfig.GetConfig(AuthSystemApplicationName, PortalId);

            SettingsEditor.DataSource = config;
            SettingsEditor.DataBind();
        }
Exemplo n.º 4
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            try
            {
                OAuthConfigBase config = OAuthConfigBase.GetConfig("LinkedIn", PortalId);
                SettingsEditor.DataSource = config;
                SettingsEditor.DataBind();
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Exemplo n.º 5
0
        private static void SaveCustomSettings(PackageSettingsDto packageSettings)
        {
            // special case for specific DNN provided external authentication systems
            string authType;

            if (packageSettings.EditorActions.TryGetValue("authenticationType", out authType))
            {
                switch (authType.ToLowerInvariant())
                {
                case "facebook":
                case "google":
                case "live":
                case "twitter":
                    var    dirty = false;
                    string value;
                    var    config = OAuthConfigBase.GetConfig(authType, packageSettings.PortalId);

                    if (packageSettings.EditorActions.TryGetValue("appId", out value) &&
                        config.APIKey != value)
                    {
                        config.APIKey = value;
                        dirty         = true;
                    }

                    if (packageSettings.EditorActions.TryGetValue("appSecret", out value) &&
                        config.APISecret != value)
                    {
                        config.APISecret = value;
                        dirty            = true;
                    }

                    if (packageSettings.EditorActions.TryGetValue("appEnabled", out value) &&
                        config.Enabled.ToString().ToUpperInvariant() != value.ToUpperInvariant())
                    {
                        config.Enabled = "TRUE".Equals(value, StringComparison.OrdinalIgnoreCase);
                        dirty          = true;
                    }

                    if (dirty)
                    {
                        OAuthConfigBase.UpdateConfig(config);
                    }
                    break;
                }
            }
        }
        public RedditOauthClient(int portalId, AuthMode mode)
            : base(portalId, mode, RedditService)
        {
            _redditConnectorManager = new RedditConnectorManager(portalId);
            if (!_redditConnectorManager.HasConfig)
            {
                return;
            }
            else
            {
                AuthorizationEndpoint = new Uri(_redditConnectorManager.AuthorizationEndpoint);
                Scope                    = _redditConnectorManager.ApiScope;
                TokenMethod              = HttpMethod.POST;
                TokenEndpoint            = new Uri(_redditConnectorManager.AccessTokenEndpoint);
                MeGraphEndpoint          = new Uri(_redditConnectorManager.MeGraphEndpoint);
                RedditApiTokenCookieName = _redditConnectorManager.AccessTokenCookieName;
                OAuthConfigBase.GetConfig(Service, portalId).APIKey    = _redditConnectorManager.ClientId;
                OAuthConfigBase.GetConfig(Service, portalId).APISecret = _redditConnectorManager.ClientSecret;
            }

            AuthTokenName   = "RedditUserToken";
            OAuthHeaderCode = "Basic";
            OAuthVersion    = "2.0";
        }