Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make meta.location a full and valid URI #797

Closed
itineric opened this issue Feb 3, 2025 · 3 comments
Closed

Make meta.location a full and valid URI #797

itineric opened this issue Feb 3, 2025 · 3 comments

Comments

@itineric
Copy link

itineric commented Feb 3, 2025

I am not sure this is an issue but I cannot figure out how to make it work.

In my custom-resource.json I have a meta.location defined as follows:

{
  "meta": {
    "resourceType": "ResourceType",
    "created": "2025-02-03T13:50:00+01:00",
    "lastModified": "2025-02-03T13:50:00+01:00",
    "location": "/ResourceTypes/MyResource"
  }
}

When requesting /ResourceTypes on my server, the meta.location is provided as is. But I was expecting some valid URL http://localhost:8080/scim/v2/ResourceTypes/MyResource.

In detail:

  • http://localhost:8080 -> where my webapp is hosted
  • /scim/v2 -> the sub-URI the webapp is accessed
  • /ResourceTypes/MyResource -> the part that is found in the json file
@Captain-P-Goldfish
Copy link
Owner

The URL is resolved from the Context-object. Did you try to override its behaviour in some way?
The ResourceEndpoint adds additional information to your Context-object, that is used to resolve the resource-URLs:

private Context getEffectiveContext(UriInfos uriInfos, String requestBody, Context context)
  {
    Context effectiveContext = Optional.ofNullable(context).orElse(new Context(null));
    effectiveContext.setUriInfos(uriInfos);
    effectiveContext.setResourceReferenceUrl(id -> {
      return super.getReferenceUrlSupplier(uriInfos::getBaseUri).apply(id, uriInfos.getResourceType().getName());
    });
    effectiveContext.setCrossResourceReferenceUrl((id, resourceName) -> {
      return super.getReferenceUrlSupplier(uriInfos::getBaseUri).apply(id, resourceName);
    });
    effectiveContext.setRequestBodySupplier(() -> {
      return requestBody;
    });
    return effectiveContext;
  }

This code is always executed and used. So I can only imagine that you messed with this object in some way.

@Captain-P-Goldfish
Copy link
Owner

Captain-P-Goldfish commented Feb 4, 2025

Oh, there is another possibiltiy.
Do not set the location-attribute yourself. If you did, the SCIM-SDK assumes that you did this on purpose and will not override your value. This applies also to the value in the .json-file. Simply remove the location from it.

@itineric
Copy link
Author

itineric commented Feb 4, 2025

It was as simple as that. I removed the values from my json file, it works.
I think many (all?) examples specify the meta entries so I just added them in the first place.

Thanks.

@itineric itineric closed this as completed Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants