@ -1,4 +1,6 @@
namespace eShopOnContainers.Core
using System ;
namespace eShopOnContainers.Core
{
public class GlobalSetting
{
@ -6,39 +8,60 @@
public const string MockTag = "Mock" ;
public const string DefaultEndpoint = "http://YOUR_IP_OR_DNS_NAME" ; // i.e.: "http://YOUR_IP" or "http://YOUR_DNS_NAME"
private string _baseEndpoint ;
private static readonly GlobalSetting _instance = new GlobalSetting ( ) ;
private string _baseIdentityEndpoint ;
private string _baseGatewayShoppingEndpoint ;
private string _baseGatewayMarketingEndpoint ;
public GlobalSetting ( )
{
AuthToken = "INSERT AUTHENTICATION TOKEN" ;
BaseEndpoint = DefaultEndpoint ;
BaseIdentityEndpoint = DefaultEndpoint ;
BaseGatewayShoppingEndpoint = DefaultEndpoint ;
BaseGatewayMarketingEndpoint = DefaultEndpoint ;
}
public static GlobalSetting Instance
public static GlobalSetting Instance { get ; } = new GlobalSetting ( ) ;
public string BaseIdentityEndpoint
{
get { return _instance ; }
get { return _baseIdentityEndpoint ; }
set
{
_baseIdentityEndpoint = value ;
UpdateEndpoint ( _baseIdentityEndpoint ) ;
}
}
public string BaseEndpoint
public string BaseGatewayShopping Endpoint
{
get { return _baseEndpoint ; }
get { return _baseGatewayShopping Endpoint ; }
set
{
_baseEndpoint = value ;
UpdateEndpoint ( _baseEndpoint ) ;
_baseGatewayShopping Endpoint = value ;
UpdateGatewayShopping Endpoint ( _baseGatewayShopping Endpoint ) ;
}
}
public string ClientId { get { return "xamarin" ; } }
public string BaseGatewayMarketingEndpoint
{
get { return _baseGatewayMarketingEndpoint ; }
set
{
_baseGatewayMarketingEndpoint = value ;
UpdateGatewayMarketingEndpoint ( _baseGatewayMarketingEndpoint ) ;
}
}
public string ClientId { get { return "xamarin" ; } }
public string ClientSecret { get { return "secret" ; } }
public string ClientSecret { get { return "secret" ; } }
public string AuthToken { get ; set ; }
public string RegisterWebsite { get ; set ; }
public string IdentityEndpoint { get ; set ; }
public string Authorize Endpoint { get ; set ; }
public string UserInfoEndpoint { get ; set ; }
@ -46,23 +69,45 @@
public string LogoutEndpoint { get ; set ; }
public string Identity Callback { get ; set ; }
public string Callback { get ; set ; }
public string LogoutCallback { get ; set ; }
private void UpdateEndpoint ( string baseEndpoint )
public string GatewayShoppingEndpoint { get ; set ; }
public string GatewayMarketingEndpoint { get ; set ; }
private void UpdateEndpoint ( string endpoint )
{
var identityBaseEndpoint = $"{baseEndpoint}/identity" ;
RegisterWebsite = $"{identityBaseEndpoint}/Account/Register" ;
LogoutCallback = $"{identityBaseEndpoint}/Account/Redirecting" ;
RegisterWebsite = $"{endpoint}/Account/Register" ;
LogoutCallback = $"{endpoint}/Account/Redirecting" ;
var connectBaseEndpoint = $"{id entityBaseE ndpoint}/connect" ;
Identity Endpoint = $"{connectBaseEndpoint}/authorize" ;
var connectBaseEndpoint = $"{endpoint}/connect" ;
Authorize Endpoint = $"{connectBaseEndpoint}/authorize" ;
UserInfoEndpoint = $"{connectBaseEndpoint}/userinfo" ;
TokenEndpoint = $"{connectBaseEndpoint}/token" ;
LogoutEndpoint = $"{connectBaseEndpoint}/endsession" ;
IdentityCallback = $"{baseEndpoint}/xamarincallback" ;
var baseUri = ExtractBaseUri ( endpoint ) ;
Callback = $"{baseUri}/xamarincallback" ;
}
private void UpdateGatewayShoppingEndpoint ( string endpoint )
{
GatewayShoppingEndpoint = $"{endpoint}" ;
}
private void UpdateGatewayMarketingEndpoint ( string endpoint )
{
GatewayMarketingEndpoint = $"{endpoint}" ;
}
private string ExtractBaseUri ( string endpoint )
{
var uri = new Uri ( endpoint ) ;
var baseUri = uri . GetLeftPart ( System . UriPartial . Authority ) ;
return baseUri ;
}
}
}