Getting OAuth settings from env var with full stop in key Getting OAuth settings from env var with full stop in key docker docker

Getting OAuth settings from env var with full stop in key


You can provide your own custom AppSettings provider or use the DictionarySettings and populate it with a mapped environment variable that's suitable to use in Docker, e.g:

Use underscore separators in Docker:

environment:  - oauth_RedirectUrl=http://example.com  - oauth_CallbackUrl=http://example.com/auth/{0}  - oauth_basecamp_ConsumerKey=fgshghfdhfghgfdhf  - oauth_basecamp_ConsumerSecret=fdghfdghdfghgdfhdfghfgd

Then create a new Dictionary AppSettings using the keys ServiceStack expects, e.g:

string env(string key) =>     Environment.GetEnvironmentVariable(key.Replace(".","_"));var envSettings = new DictionarySettings(new Dictionary<string,string> {    ["oauth.RedirectUrl"] = env("oauth.RedirectUrl"),    ["oauth.CallbackUrl"] = env("oauth.CallbackUrl"),    ["oauth.basecamp.ConsumerKey"] = env("oauth.basecamp.ConsumerKey"),    ["oauth.basecamp.ConsumerSecret"] = env("oauth.basecamp.ConsumerSecret"),});

Then use that in your Auth Providers, e.g:

new MyAuthProvider(envSettings)