Beispiel #1
0
        private void ExecuteSecuredOperation(string userId)
        {
            string operation = "operation";

            using (var s = store.OpenSession(DatabaseName))
            {
                client::Raven.Bundles.Authorization.Model.AuthorizationUser user = new client::Raven.Bundles.Authorization.Model.AuthorizationUser {
                    Id = userId, Name = "Name"
                };
                user.Permissions = new List <client::Raven.Bundles.Authorization.Model.OperationPermission>
                {
                    new client::Raven.Bundles.Authorization.Model.OperationPermission {
                        Allow = true, Operation = operation
                    }
                };
                s.Store(user);

                s.SaveChanges();
            }

            using (var s = store.OpenSession(DatabaseName))
            {
                var authorizationUser = s.Load <client::Raven.Bundles.Authorization.Model.AuthorizationUser>(userId);
                Assert.True(client::Raven.Client.Authorization.AuthorizationClientExtensions.IsAllowed(s, authorizationUser, operation));
            }
        }
Beispiel #2
0
		private void ExecuteSecuredOperation(string userId)
		{
			string operation = "operation";
			using (var s = store.OpenSession(DatabaseName))
			{
				client::Raven.Bundles.Authorization.Model.AuthorizationUser user = new client::Raven.Bundles.Authorization.Model.AuthorizationUser { Id = userId, Name = "Name" };
				user.Permissions = new List<client::Raven.Bundles.Authorization.Model.OperationPermission>
				{
					new client::Raven.Bundles.Authorization.Model.OperationPermission {Allow = true, Operation = operation}
				};
				s.Store(user);

				s.SaveChanges();
			}

            using (var s = store.OpenSession(DatabaseName))
			{
				var authorizationUser = s.Load<client::Raven.Bundles.Authorization.Model.AuthorizationUser>(userId);
				Assert.True(client::Raven.Client.Authorization.AuthorizationClientExtensions.IsAllowed(s, authorizationUser, operation));
			}
		}