Hi Demis,
We need to allow our customers to setup their social accounts in runtime using our app control panel.
But the current OAuth2 Provider implementation loads the key, secrets, etc in the constructor:
using System.Net;
using DotNetOpenAuth.Messaging;
using DotNetOpenAuth.OAuth2;
using ServiceStack.Auth;
using ServiceStack.Configuration;
namespace ServiceStack.Authentication.OAuth2
{
[Obsolete("Use built-in OAuth2Provider in ServiceStack.Auth")]
public abstract class OAuth2Provider : AuthProvider
{
protected OAuth2Provider(IAppSettings appSettings, string realm, string provider)
: base(appSettings, realm, provider)
{
this.ConsumerKey = appSettings.GetString("oauth.{0}.ClientId".Fmt(provider))
?? appSettings.GetString("oauth.{0}.ConsumerKey".Fmt(provider))
?? FallbackConfig(appSettings.GetString("oauth.ConsumerKey"));
this.ConsumerSecret = appSettings.GetString("oauth.{0}.ClientSecret".Fmt(provider))
?? appSettings.GetString("oauth.{0}.ConsumerSecret".Fmt(provider))
?? FallbackConfig(appSettings.GetString("oauth.ConsumerSecret"));
var scopes = appSettings.GetString("oauth.{0}.Scopes".Fmt(provider))
Any suggestion on how to update these settings in runtime (without restarting the app)?
mythz
June 19, 2015, 2:12am
2
Whilst configuration is only meant to be set in AppHost.Configure()
and remain immutable thereafter you should still be able to access the AuthProvider at runtime and update it’s properties with something like:
var authProvider = (GoogleOAuth2Provider)AuthenticateService.GetAuthProvider(GoogleOAuth2Provider.Name);
authProvider.ConsumerKey = "...";