403 Forbidden - Restore through client library


#1

Hello!

I’m trying to hit the new PostRestoreAsync() method in the client library now. It’s returning a 403 forbidden, I assume because the client credentials I am using are from an app.

EDIT:
Right now I am using client credentials from an app to attempt to manage the entire instance we have set up. I am not sure if that will work for tasks that require admin permissions like restores.

  1. How can I give my app client admin permissions
  2. OR: How can I get client credentials for an actual user so that I can perform admin tasks?

#3

Why have you withdrawn this post?


#4

I am preparing a commit that allows you to create an admin client via config.


#5

I added a commit: https://github.com/Squidex/squidex/commit/c437d096eeb724137fe541437de162d51fc9a27f

You can create an admin client with these settings: https://github.com/Squidex/squidex/blob/c437d096eeb724137fe541437de162d51fc9a27f/src/Squidex/appsettings.json#L274


#6

@Sebastian awesome, didn’t mean to withdraw the post, I just edited it and maybe it caused that.

Will check it out now, thanks!


#7

Hey @Sebastian

I am getting this error when doing restores now. It seems like they restore fine, but they always “fail” at the very end producing this:

{
  "logLevel": "Error",
  "action": "retore",
  "status": "failed",
  "operationId": "50ae5b05-942e-42ff-ba9f-cd114bf91f3f",
  "url": "http://localhost:5000/api/apps/master-app-testing/backups/c9665ac9-64b3-4860-a210-ffa820524057",
  "profiler": {
    "mongoContentRepository/WriteAsync": {
      "elapsedMsTotal": 33954,
      "elapsedMsAvg": 78,
      "count": 434
    },
    "backupApps/CompleteRestoreAsync": {
      "elapsedMsTotal": 295,
      "elapsedMsAvg": 295,
      "count": 1
    },
    "Download": {
      "elapsedMsTotal": 4700,
      "elapsedMsAvg": 4700,
      "count": 1
    },
    "backupApps/RestoreAsync": {
      "elapsedMsTotal": 682,
      "elapsedMsAvg": 682,
      "count": 1
    },
    "backupRules/RestoreAsync": {
      "elapsedMsTotal": 153,
      "elapsedMsAvg": 153,
      "count": 1
    },
    "backupRules/CompleteRestoreAsync": {
      "elapsedMsTotal": 0,
      "elapsedMsAvg": 0,
      "count": 1
    },
    "backupContents/RestoreAsync": {
      "elapsedMsTotal": 59187,
      "elapsedMsAvg": 59187,
      "count": 1
    },
    "ReadEvents": {
      "elapsedMsTotal": 161567,
      "elapsedMsAvg": 161567,
      "count": 1
    },
    "mongoContentRepository/ReadAsync": {
      "elapsedMsTotal": 11874,
      "elapsedMsAvg": 27,
      "count": 434
    },
    "mongoAssetRepository/ReadAsync": {
      "elapsedMsTotal": 346,
      "elapsedMsAvg": 43,
      "count": 8
    },
    "backupSchemas/CompleteRestoreAsync": {
      "elapsedMsTotal": 0,
      "elapsedMsAvg": 0,
      "count": 1
    },
    "appProvider/GetSchemaAsyncById": {
      "elapsedMsTotal": 2164,
      "elapsedMsAvg": 166,
      "count": 13
    },
    "mongoAssetRepository/WriteAsync": {
      "elapsedMsTotal": 234,
      "elapsedMsAvg": 29,
      "count": 8
    },
    "backupContents/CompleteRestoreAsync": {
      "elapsedMsTotal": 0,
      "elapsedMsAvg": 0,
      "count": 1
    },
    "mongoSnapshotStore`2/ReadAsync": {
      "elapsedMsTotal": 1051,
      "elapsedMsAvg": 58,
      "count": 18
    },
    "mongoSnapshotStore`2/WriteAsync": {
      "elapsedMsTotal": 762,
      "elapsedMsAvg": 108,
      "count": 7
    },
    "backupSchemas/RestoreAsync": {
      "elapsedMsTotal": 140,
      "elapsedMsAvg": 140,
      "count": 1
    },
    "mongoEventStore/QueryAsync": {
      "elapsedMsTotal": 11864,
      "elapsedMsAvg": 26,
      "count": 456
    },
    "backupAssets/RestoreAsync": {
      "elapsedMsTotal": 2453,
      "elapsedMsAvg": 2453,
      "count": 1
    },
    "backupAssets/CompleteRestoreAsync": {
      "elapsedMsTotal": 0,
      "elapsedMsAvg": 0,
      "count": 1
    },
    "mongoEventStore/AppendAsync": {
      "elapsedMsTotal": 134337,
      "elapsedMsAvg": 67,
      "count": 1994
    }
  },
  "exception": {
    "type": "Squidex.Infrastructure.DomainObjectNotFoundException",
    "message": "Domain object 'Default' not found on Squidex.Domain.Apps.Entities.Apps.IAppEntity.Contributors",
    "stackTrace": "   at Squidex.Domain.Apps.Entities.Apps.Guards.GuardAppContributors.<>c__DisplayClass0_0.<<CanAssign>b__1>d.MoveNext() in C:\\Users\\Blake\\Desktop\\SeqTek\\squidex\\src\\Squidex.Domain.Apps.Entities\\Apps\\Guards\\GuardAppContributors.cs:line 45\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at Squidex.Infrastructure.Validate.It(Func`1 message, Func`2 action) in C:\\Users\\Blake\\Desktop\\SeqTek\\squidex\\src\\Squidex.Infrastructure\\Validate.cs:line 54\r\n   at Squidex.Domain.Apps.Entities.Apps.AppGrain.<ExecuteAsync>b__5_1(AssignContributor c) in C:\\Users\\Blake\\Desktop\\SeqTek\\squidex\\src\\Squidex.Domain.Apps.Entities\\Apps\\AppGrain.cs:line 73\r\n   at Squidex.Infrastructure.Commands.DomainObjectGrainBase`1.InvokeAsync[TCommand](TCommand command, Func`2 handler, Mode mode) in C:\\Users\\Blake\\Desktop\\SeqTek\\squidex\\src\\Squidex.Infrastructure\\Commands\\DomainObjectGrainBase.cs:line 182\r\n   at Squidex.Infrastructure.Commands.DomainObjectGrainBase`1.ExecuteAsync(J`1 command) in C:\\Users\\Blake\\Desktop\\SeqTek\\squidex\\src\\Squidex.Infrastructure\\Commands\\DomainObjectGrainBase.cs:line 224\r\n   at Squidex.Domain.Apps.Entities.Apps.OrleansCodeGenAppGrainMethodInvoker.Invoke(IAddressable grain, InvokeMethodRequest request) in C:\\Users\\Blake\\Desktop\\SeqTek\\squidex\\src\\Squidex.Domain.Apps.Entities\\obj\\Debug\\netstandard2.0\\Squidex.Domain.Apps.Entities.orleans.g.cs:line 35\r\n   at Orleans.Runtime.GrainMethodInvoker.Invoke() in D:\\build\\agent\\_work\\25\\s\\src\\Orleans.Runtime\\Core\\GrainMethodInvoker.cs:line 91\r\n   at Squidex.Infrastructure.Orleans.LocalCacheFilter.Invoke(IIncomingGrainCallContext context) in C:\\Users\\Blake\\Desktop\\SeqTek\\squidex\\src\\Squidex.Infrastructure\\Orleans\\LocalCacheFilter.cs:line 32\r\n   at Orleans.Runtime.GrainMethodInvoker.Invoke() in D:\\build\\agent\\_work\\25\\s\\src\\Orleans.Runtime\\Core\\GrainMethodInvoker.cs:line 71\r\n   at OrleansDashboard.Metrics.GrainProfiler.Invoke(IIncomingGrainCallContext context)\r\n   at Orleans.Runtime.GrainMethodInvoker.Invoke() in D:\\build\\agent\\_work\\25\\s\\src\\Orleans.Runtime\\Core\\GrainMethodInvoker.cs:line 71\r\n   at Orleans.Runtime.InsideRuntimeClient.Invoke(IAddressable target, IInvokable invokable, Message message) in D:\\build\\agent\\_work\\25\\s\\src\\Orleans.Runtime\\Core\\InsideRuntimeClient.cs:line 351\r\n   at Orleans.OrleansTaskExtentions.<ToTypedTask>g__ConvertAsync|4_0[T](Task`1 asyncTask) in D:\\build\\agent\\_work\\23\\s\\src\\Orleans.Core\\Async\\TaskExtensions.cs:line 100\r\n   at Squidex.Infrastructure.Commands.GrainCommandMiddleware`2.ExecuteCommandAsync(TCommand typedCommand) in C:\\Users\\Blake\\Desktop\\SeqTek\\squidex\\src\\Squidex.Infrastructure\\Commands\\GrainCommandMiddleware.cs:line 41\r\n   at Squidex.Infrastructure.Commands.GrainCommandMiddleware`2.HandleAsync(CommandContext context, Func`1 next) in C:\\Users\\Blake\\Desktop\\SeqTek\\squidex\\src\\Squidex.Infrastructure\\Commands\\GrainCommandMiddleware.cs:line 29\r\n   at Squidex.Domain.Apps.Entities.Apps.Indexes.AppsByNameIndexCommandMiddleware.HandleAsync(CommandContext context, Func`1 next) in C:\\Users\\Blake\\Desktop\\SeqTek\\squidex\\src\\Squidex.Domain.Apps.Entities\\Apps\\Indexes\\AppsByNameIndexCommandMiddleware.cs:line 48\r\n   at Squidex.Domain.Apps.Entities.Apps.Indexes.AppsByNameIndexCommandMiddleware.HandleAsync(CommandContext context, Func`1 next) in C:\\Users\\Blake\\Desktop\\SeqTek\\squidex\\src\\Squidex.Domain.Apps.Entities\\Apps\\Indexes\\AppsByNameIndexCommandMiddleware.cs:line 68\r\n   at Squidex.Infrastructure.Commands.GrainCommandMiddleware`2.HandleAsync(CommandContext context, Func`1 next) in C:\\Users\\Blake\\Desktop\\SeqTek\\squidex\\src\\Squidex.Infrastructure\\Commands\\GrainCommandMiddleware.cs:line 34\r\n   at Squidex.Domain.Apps.Entities.Assets.AssetCommandMiddleware.HandleAsync(CommandContext context, Func`1 next) in C:\\Users\\Blake\\Desktop\\SeqTek\\squidex\\src\\Squidex.Domain.Apps.Entities\\Assets\\AssetCommandMiddleware.cs:line 102\r\n   at Squidex.Domain.Apps.Entities.Apps.InviteUserCommandMiddleware.HandleAsync(CommandContext context, Func`1 next) in C:\\Users\\Blake\\Desktop\\SeqTek\\squidex\\src\\Squidex.Domain.Apps.Entities\\Apps\\InviteUserCommandMiddleware.cs:line 47\r\n   at Squidex.Pipeline.CommandMiddlewares.EnrichWithSchemaIdCommandMiddleware.HandleAsync(CommandContext context, Func`1 next) in C:\\Users\\Blake\\Desktop\\SeqTek\\squidex\\src\\Squidex\\Pipeline\\CommandMiddlewares\\EnrichWithSchemaIdCommandMiddleware.cs:line 54\r\n   at Squidex.Pipeline.CommandMiddlewares.ETagCommandMiddleware.HandleAsync(CommandContext context, Func`1 next) in C:\\Users\\Blake\\Desktop\\SeqTek\\squidex\\src\\Squidex\\Pipeline\\CommandMiddlewares\\ETagCommandMiddleware.cs:line 31\r\n   at Squidex.Infrastructure.Commands.InMemoryCommandBus.PublishAsync(ICommand command) in C:\\Users\\Blake\\Desktop\\SeqTek\\squidex\\src\\Squidex.Infrastructure\\Commands\\InMemoryCommandBus.cs:line 40\r\n   at Squidex.Domain.Apps.Entities.Backup.RestoreGrain.AssignContributorAsync() in C:\\Users\\Blake\\Desktop\\SeqTek\\squidex\\src\\Squidex.Domain.Apps.Entities\\Backup\\RestoreGrain.cs:line 241\r\n   at Squidex.Domain.Apps.Entities.Backup.RestoreGrain.ProcessAsync() in C:\\Users\\Blake\\Desktop\\SeqTek\\squidex\\src\\Squidex.Domain.Apps.Entities\\Backup\\RestoreGrain.cs:line 189"
  },
  "app": {
    "name": "Squidex",
    "version": "1.0.0.0",
    "sessionId": "2c4d0e4f-2389-48ba-a601-d8b7f8c4e7f9"
  },
  "timestamp": "2019-02-04T21:01:18Z"
}

#8

Damn, I know what the problem is.


#9

I will test the full flow tomorrow again and push the change.


#10

I pushed a potential fix.