RIPAGlobal / scimitar

A SCIM v2 API endpoint implementation
MIT License
61 stars 43 forks source link

/Schemas reports readonly attributes as readWrite #119

Closed gsar closed 4 months ago

gsar commented 7 months ago

Our scim_attributes_map has several attributes that can only be read (no foo= accessor for writing) however this is not being reflected in the output of /Schemas, making it a bit useless for auto-discovery.

pond commented 5 months ago

@gsar A question about this one. The endpoint describes the schemas and so is currently nice and simple; it reports the SCIM specification schemas, or a custom schema.

A custom schema's mutability descriptions of attribues should obviously match the actual mutability of the mapped attributes. Meanwhile, the RFC schema would surely require the specified mutability to be obeyed. The server shouldn't have to worry about a non-standard client, just sending what it wants to send to that client with the client mapping or dropping attributes as it sees fit.

I can't see anything in the RFCs stating that a standard schema attribute described as readWrite is actually optionally mutable and might be read-only - but I might be wrong about that. I'd be prepared to put the (significant) work in to rewrite the Schemas endpoint to read the attribute map and override the schema definitions, but only if we can find a good RFC reason for doing so. Otherwise, just add write accessors that ignore the value.

gsar commented 4 months ago

@pond some SCIM implementations out there are capable of reading the /Schemas endpoint to determine what features of SCIM are supported. i tried to get this working with Microsoft's implementation but couldn't. some sections of the doc there suggest clients can try to discover the schema, so it would be great to have a way for /Schemas to report what is actually implemented (as opposed to what's in the standard). maybe it is easier to do this with configuration instead of the code trying to automatically figure it out? that would be sufficient, i think.

relevant section of the RFC says this about things marked readWrite: MAY be updated and read at any time, so adding an accessor that ignores the modification (as opposed to raising) would make it a non-compliant implementation.

image

pond commented 4 months ago

@gsar As I think about implementation here, questions arise.

Perhaps the way forward is something that you do to override the underlying schema itself, actually updating its predefined attribute map in the Scimitar initializer. That feels a bit like adding a third kind of declaration LOL but kinda not, it's more modifying the out-of-box schema config in some reasonable way.

gsar commented 4 months ago

@pond broadly agree with your "bottom-line" assessment. /Schemas endpoint should render based on the same attribute map that is being used as the source of truth to handle requests.

pond commented 4 months ago

@gsar How does https://github.com/RIPAGlobal/scimitar/pull/135 look?

pond commented 4 months ago

Gone ahead with this and published it as v2.9.0 (Rails 7) and v1.10.0 (Rails 6).