コード例 #1
0
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            CloudTableClient cloudTableClientAdmin = this.StorageAccount.CreateCloudTableClient();
            var photoContextAdmin = new PhotoDataServiceContext(cloudTableClientAdmin);

            if (this.User.Identity.IsAuthenticated)
            {
                this.AuthenticatedTableSas = photoContextAdmin.GetSas(this.User.Identity.Name, "admin");
                this.PublicTableSas = photoContextAdmin.GetSas("Public", "admin");
                this.QueueSas = this.StorageAccount.CreateCloudQueueClient().GetQueueReference("messagequeue").GetSharedAccessSignature(
                        new SharedAccessQueuePolicy() {  },
                        "add"
                        );
            }
            else
            {
                this.PublicTableSas = photoContextAdmin.GetSas("Public", "edit");
                this.AuthenticatedTableSas = null;
                this.QueueSas = null;
            }
        }
コード例 #2
0
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            CloudTableClient cloudTableClientAdmin = this.StorageAccount.CreateCloudTableClient();
            var photoContextAdmin = new PhotoDataServiceContext(cloudTableClientAdmin);

            if (this.User.Identity.IsAuthenticated)
            {
                this.AuthenticatedTableSas = photoContextAdmin.GetSas(this.User.Identity.Name, SharedAccessTablePermissions.Add | SharedAccessTablePermissions.Delete | SharedAccessTablePermissions.Query | SharedAccessTablePermissions.Update);
                this.PublicTableSas = photoContextAdmin.GetSas("Public", SharedAccessTablePermissions.Add | SharedAccessTablePermissions.Delete | SharedAccessTablePermissions.Query | SharedAccessTablePermissions.Update);
                this.QueueSas = this.StorageAccount.CreateCloudQueueClient().GetQueueReference("messagequeue").GetSharedAccessSignature(
                   new SharedAccessQueuePolicy() { Permissions = SharedAccessQueuePermissions.Add | SharedAccessQueuePermissions.Read, SharedAccessExpiryTime = DateTime.UtcNow.AddMinutes(15) },
                   null
                   );
            }
            else
            {
                this.PublicTableSas = photoContextAdmin.GetSas("Public", SharedAccessTablePermissions.Add | SharedAccessTablePermissions.Update | SharedAccessTablePermissions.Query);
                this.AuthenticatedTableSas = null;
                this.QueueSas = null;
            }
        }
コード例 #3
0
        public void RefreshAccessCredentials()
        {
            if ((Session["ExpireTime"] as DateTime? == null) || ((DateTime)Session["ExpireTime"] < DateTime.UtcNow))
            {
                CloudTableClient cloudTableClientAdmin = this.StorageAccount.CreateCloudTableClient();
                var photoContextAdmin = new PhotoDataServiceContext(cloudTableClientAdmin);

                Session["Sas"] = photoContextAdmin.GetSas("readonly", "Public");

                if (this.User != null)
                {
                    Session["MySas"] = photoContextAdmin.GetSas("admin", this.User.Identity.Name);
                    Session["Sas"] = photoContextAdmin.GetSas("admin", "Public");
                }

                Session["ExpireTime"] = DateTime.UtcNow.AddMinutes(15);
            }
        }