private static object ResolveSqlDb(ResourceResolutionContext context)
        {
            return(new Func <string, string>(user => {
                string serverName = Utils.GetServerName(context.Resource);

                if (String.Equals(user, "admin", StringComparison.OrdinalIgnoreCase))
                {
                    // Resolve the admin account
                    var cstr = new SqlConnectionStringBuilder(context.Resource.Value);
                    cstr.UserID = Utils.GetAdminUserName(context.Resource, context.Service.Datacenter);
                    cstr.Password = context.GetSecretValueOrDefault("sqldb." + serverName + ":admin");
                    return cstr.ConnectionString;
                }
                else
                {
                    // Look up the current user name
                    var login = context.GetSecretValueOrDefault("sqldb." + serverName + ":serviceUsers." + context.Service.Name);

                    // Look up the password for that user
                    var password = context.GetSecretValueOrDefault("sqldb." + serverName + ":logins." + login);

                    // Generate a connection string
                    var builder = new SqlConnectionStringBuilder(context.Resource.Value);
                    builder.UserID = login;
                    builder.Password = password;
                    return builder.ConnectionString;
                }
            }));
        }
Esempio n. 2
0
        private static object ResolveSqlDb(ResourceResolutionContext context)
        {
            return new Func<string, string>(user => {
                string serverName = Utils.GetServerName(context.Resource);

                if (String.Equals(user, "admin", StringComparison.OrdinalIgnoreCase))
                {
                    // Resolve the admin account
                    var cstr = new SqlConnectionStringBuilder(context.Resource.Value);
                    cstr.UserID = Utils.GetAdminUserName(context.Resource, context.Service.Datacenter);
                    cstr.Password = context.GetSecretValueOrDefault("sqldb." + serverName + ":admin");
                    return cstr.ConnectionString;
                }
                else
                {
                    // Look up the current user name
                    var login = context.GetSecretValueOrDefault("sqldb." + serverName + ":serviceUsers." + context.Service.Name);

                    // Look up the password for that user
                    var password = context.GetSecretValueOrDefault("sqldb." + serverName + ":logins." + login);

                    // Generate a connection string
                    var builder = new SqlConnectionStringBuilder(context.Resource.Value);
                    builder.UserID = login;
                    builder.Password = password;
                    return builder.ConnectionString;
                }
            });
        }
Esempio n. 3
0
 private static object ResolveOAuth(ResourceResolutionContext context)
 {
     return new Dictionary<string, object>() {
         {"id", context.Resource.Value},
         {"secret", context.GetSecretValueOrDefault("oauth." + context.Resource.Name + ":secret")}
     };
 }
 private static object ResolveOAuth(ResourceResolutionContext context)
 {
     return(new Dictionary <string, object>()
     {
         { "id", context.Resource.Value },
         { "secret", context.GetSecretValueOrDefault("oauth." + context.Resource.Name + ":secret") }
     });
 }
Esempio n. 5
0
 private static object ResolveUri(ResourceResolutionContext context)
 {
     Func<string> userNameThunk = () => context.GetSecretValueOrDefault("uri." + context.Resource.Name + ":username");
     Func<string> passwordThunk = () => context.GetSecretValueOrDefault("uri." + context.Resource.Name + ":password");
     return new Dictionary<string, object>() 
     {
         {"value", context.Resource.Value},
         {"username", new DeferredString(userNameThunk)},
         {"password", new DeferredString(passwordThunk)},
         {"absoluteUri", new DeferredString(() => new UriBuilder(context.Resource.Value) {
             UserName = WebUtility.UrlEncode(userNameThunk()),
             Password = passwordThunk()
         }.Uri.AbsoluteUri)}
     };
 }
        private static object ResolveUri(ResourceResolutionContext context)
        {
            Func <string> userNameThunk = () => context.GetSecretValueOrDefault("uri." + context.Resource.Name + ":username");
            Func <string> passwordThunk = () => context.GetSecretValueOrDefault("uri." + context.Resource.Name + ":password");

            return(new Dictionary <string, object>()
            {
                { "value", context.Resource.Value },
                { "username", new DeferredString(userNameThunk) },
                { "password", new DeferredString(passwordThunk) },
                { "absoluteUri", new DeferredString(() => new UriBuilder(context.Resource.Value)
                    {
                        UserName = WebUtility.UrlEncode(userNameThunk()),
                        Password = passwordThunk()
                    }.Uri.AbsoluteUri) }
            });
        }
 private static object ResolveAzureStorage(ResourceResolutionContext context)
 {
     return(new DeferredString(() =>
                               // Get the connection string, it's in the secret store
                               context.GetSecretValueOrDefault("azureStorage." + context.Resource.Value)));
 }
Esempio n. 8
0
 private static object ResolveAzureStorage(ResourceResolutionContext context)
 {
     return new DeferredString(() =>
         // Get the connection string, it's in the secret store
         context.GetSecretValueOrDefault("azureStorage." + context.Resource.Value));
 }