internal Authentication(string domain, JObject config, string application) { authServiceEndpoint = Validate(config, "authServiceEndpoint"); applicationScope = Validate(config, "applicationScope"); marketplaceScope = "http://" + domain + "/"; authServiceScope = Validate(config, "authServiceScope"); var providers = Validate <JObject>(config, "identityProviders"); foreach (var prop in providers.Properties()) { IIdentityProvider instance; var ip = prop.Value as JObject; var protocol = Validate(ip, "protocol"); switch (protocol.ToLower()) { case "wrapv0.9": instance = new WRAPv09IdentityProvider(); break; case "adfs": instance = new ADFSWSTrustIdentityProvider(); break; case "ws-trus": instance = new ADFSWSTrustIdentityProvider(); break; default: throw new Exception("Invalid Identity Provider protocol: " + protocol); } var ipConfig = new IdentityProviderConfig { protocol = protocol, authServiceScope = authServiceScope, ipEndpoint = Validate(ip, "endpoint"), applicationScope = applicationScope, marketplaceScope = marketplaceScope, authServiceEndpoint = authServiceEndpoint, key = prop.Name, instance = instance }; var serviceBus = ip.Value <JObject>("serviceBus"); if (serviceBus != null) { ipConfig.serviceBusIpScope = Validate(serviceBus, "ipScope"); ipConfig.serviceBusEndpoint = Validate(serviceBus, "endpoint"); ipConfig.serviceBusScope = Validate(serviceBus, "scope"); } identityProviders.AddOrUpdate(prop.Name, ipConfig, (key, current) => ipConfig); } }
static internal async Task<KZUser> Authenticate(IdentityProviderConfig config) { try { var ipToken = await config.instance.RequestToken(new Uri(config.ipEndpoint), config.authServiceScope); var kzTokenUser = await RequestKidoTokenAsync(config.authServiceEndpoint, config.applicationScope, ipToken.Token); var kzMarketplaceTokenUser = await RequestKidoTokenAsync(config.authServiceEndpoint, config.marketplaceScope, ipToken.Token); RequestTokenResult kzTokenSB = null; //if (!string.IsNullOrWhiteSpace(config.serviceBusIpScope)) //{ // ipToken = await config.instance.RequestToken(new Uri(config.ipEndpoint), config.serviceBusIpScope); // kzTokenSB = await RequestKidoTokenAsync(config.serviceBusEndpoint, config.serviceBusScope, ipToken.Token); //} return createUser(kzTokenUser, kzTokenSB, kzMarketplaceTokenUser); } catch (Exception e) { throw new Exception("User could not be authenticated.", e); } }
static internal async Task <KZUser> Authenticate(IdentityProviderConfig config) { try { var ipToken = await config.instance.RequestToken(new Uri(config.ipEndpoint), config.authServiceScope); var kzTokenUser = await RequestKidoTokenAsync(config.authServiceEndpoint, config.applicationScope, ipToken.Token); var kzMarketplaceTokenUser = await RequestKidoTokenAsync(config.authServiceEndpoint, config.marketplaceScope, ipToken.Token); RequestTokenResult kzTokenSB = null; //if (!string.IsNullOrWhiteSpace(config.serviceBusIpScope)) //{ // ipToken = await config.instance.RequestToken(new Uri(config.ipEndpoint), config.serviceBusIpScope); // kzTokenSB = await RequestKidoTokenAsync(config.serviceBusEndpoint, config.serviceBusScope, ipToken.Token); //} return(createUser(kzTokenUser, kzTokenSB, kzMarketplaceTokenUser)); } catch (Exception e) { throw new Exception("User could not be authenticated.", e); } }
public void RegisterIdentityProvider(string key, string protocol, string endpoint, string scope, IIdentityProvider provider, string serviceBusIpScope = null, string serviceBusEndpoint = null, string serviceBusScope = null) { if (string.IsNullOrWhiteSpace(key)) { throw new ArgumentNullException("key"); } if (string.IsNullOrWhiteSpace(protocol)) { throw new ArgumentNullException("protocol"); } if (string.IsNullOrWhiteSpace(endpoint)) { throw new ArgumentNullException("endpoint"); } if (provider == null) { throw new ArgumentNullException("provider"); } var ipConfig = new IdentityProviderConfig { authServiceScope = scope, ipEndpoint = endpoint, applicationScope = applicationScope, authServiceEndpoint = authServiceEndpoint, marketplaceScope = marketplaceScope, serviceBusIpScope = serviceBusIpScope, serviceBusEndpoint = serviceBusEndpoint, serviceBusScope = serviceBusScope, key = key, protocol = protocol, instance = provider }; identityProviders.AddOrUpdate(key, ipConfig, (k, current) => ipConfig); }
public void Configure(IdentityProviderConfig configuration) { }