Giter Club home page Giter Club logo

Comments (8)

johanndev avatar johanndev commented on July 20, 2024

I tried to align my sample with the acceptance tests located in tests/SimpleIdServer.Scim.Host.Acceptance.Tests/

  1. I removed the route attribute from my controller
  2. I added the call to e.UseStandardScimEdp("CustomResources", false); before the call to e.UseScim()

Now I get an 404 Not Found response when trying to call the custom resource endpoint.

from simpleidserver.

simpleidserver avatar simpleidserver commented on July 20, 2024

Hello :)

Your custom controller cannot be found because the function "UseStandardScimEdp" must be used before "UseScim". Otherwise, the routes "catchAllGet" and "catchAllPut" will catch all the HTTP requests.

Your code should look something like this:

o.UseStandardScimEdp("CustomResources", false);
o.UseScim(opts.EnableRealm);

from simpleidserver.

johanndev avatar johanndev commented on July 20, 2024

Thanks for your reply :)

That's what I tried, I placed the call configuring my custom resource before the UseScim() call.

I'll check it again tomorrow, maybe my build cache wasn't up to date.

from simpleidserver.

johanndev avatar johanndev commented on July 20, 2024

@simpleidserver I checked my code again, the order of the endpoints seems to be correct to me :/

I published my reproduction sample here: https://github.com/johanndev/sid-issue-762

EDIT: I included a http testing file for quickly testing the endpoints. A call to /Users works as expected, so the general setup seems to be correct.

from simpleidserver.

johanndev avatar johanndev commented on July 20, 2024

If I list all ActionDescriptors via:

[Route("ActionDescriptors")]
public class ActionDescriptorsController(IActionDescriptorCollectionProvider provider) : Controller
{
    [HttpGet]
    public IActionResult Get() {
        var res = provider.ActionDescriptors.Items.Select(i => i.DisplayName);
        return new OkObjectResult(res);
    }
}

I get the following result:

[
  "SCIM.API.ActionDescriptorsController.Get (SCIM.API)",
  "SimpleIdServer.Scim.Api.BulkController.Index (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.DefaultController.Get (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.DefaultController.Put (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.DefaultController.Post (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.DefaultController.Delete (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.DefaultController.Patch (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.GroupsController.GetAll (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.GroupsController.Search (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.GroupsController.Get (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.GroupsController.Add (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.GroupsController.Delete (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.GroupsController.Update (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.GroupsController.Patch (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.ResourceTypesController.GetAll (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.ResourceTypesController.Get (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.SchemasController.GetAll (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.SchemasController.Get (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.ServiceProviderConfigController.Get (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.UsersController.GetAll (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.UsersController.Search (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.UsersController.Get (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.UsersController.Add (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.UsersController.Delete (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.UsersController.Update (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.UsersController.Patch (SimpleIdServer.Scim)"
]

Notice that the CustomResourcesController is missing, although it's registered exactly like the Users and Groups Controllers.

EDIT: The endpoints are correctly added to the ScimEndpointStore:

[HttpGet("scimendpoints")]
public IActionResult Get()
{
    var res = scimEndpointStore.Routes.Select(r => r.RouteName);
    return new OkObjectResult(res);
}

Result:

[
  "getCustomResources",
  "searchCustomResources",
  "getUniqueCustomResources",
  "addCustomResources",
  "deleteCustomResources",
  "updateCustomResources",
  "patchCustomResources",
  "getResourceTypes",
  "getResourceType",
  "getSchemas",
  "getSchema",
  "getServiceProviderConfig",
  "bulk",
  "getUsers",
  "searchUsers",
  "getUniqueUsers",
  "addUsers",
  "deleteUsers",
  "updateUsers",
  "patchUsers",
  "getGroups",
  "searchGroups",
  "getUniqueGroups",
  "addGroups",
  "deleteGroups",
  "updateGroups",
  "patchGroups"
]

from simpleidserver.

johanndev avatar johanndev commented on July 20, 2024

I made a stupid mistake creating the CustomResourcesController: I created it directly at the bottom of the Program.cs and subsequently used the "Move to File" Refactoring in VS. Unfortunately, VS nested the controller inside a partial program class. Removing the partial class fixes the route registration/action descriptors:

[
  "SCIM.API.ActionDescriptorsController.GetActionDescriptors (SCIM.API)",
  "SCIM.API.ActionDescriptorsController.Get (SCIM.API)",
  "SCIM.API.CustomResourcesController.GetAll (SCIM.API)", 		🥳
  "SCIM.API.CustomResourcesController.Search (SCIM.API)", 	🥳
  "SCIM.API.CustomResourcesController.Get (SCIM.API)", 		🥳
  "SCIM.API.CustomResourcesController.Add (SCIM.API)" 		🥳,
  "SCIM.API.CustomResourcesController.Delete (SCIM.API)", 	🥳
  "SCIM.API.CustomResourcesController.Update (SCIM.API)", 	🥳
  "SCIM.API.CustomResourcesController.Patch (SCIM.API)", 		🥳
  "SimpleIdServer.Scim.Api.BulkController.Index (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.DefaultController.Get (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.DefaultController.Put (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.DefaultController.Post (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.DefaultController.Delete (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.DefaultController.Patch (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.GroupsController.GetAll (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.GroupsController.Search (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.GroupsController.Get (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.GroupsController.Add (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.GroupsController.Delete (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.GroupsController.Update (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.GroupsController.Patch (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.ResourceTypesController.GetAll (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.ResourceTypesController.Get (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.SchemasController.GetAll (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.SchemasController.Get (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.ServiceProviderConfigController.Get (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.UsersController.GetAll (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.UsersController.Search (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.UsersController.Get (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.UsersController.Add (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.UsersController.Delete (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.UsersController.Update (SimpleIdServer.Scim)",
  "SimpleIdServer.Scim.Api.UsersController.Patch (SimpleIdServer.Scim)"
]

.... but I still get a 404 when trying to call /CustomResources 😢

from simpleidserver.

johanndev avatar johanndev commented on July 20, 2024

I found the error:
var customResource = SCIMSchemaBuilder.Create("urn:customresource", "CustomResources", "CustomResources")

The 's' at the end of the resource type was the culprit 🙈

Removing it and reseeding the db fixed the problem.

from simpleidserver.

simpleidserver avatar simpleidserver commented on July 20, 2024

Hello, and sorry for my late reply :)

I'm glad you found the issue! Don't hesitate to create GitHub tickets if you have other questions.

from simpleidserver.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.