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

Allow requesting specific attributes #102

Merged

Conversation

xjunior
Copy link
Contributor

@xjunior xjunior commented Feb 1, 2024

  • Remove nil attributes from response
  • Allow to selectively serialize attributes with to_scim
  • Request specific attributes through ActiveRecordBackedResourcesController

Closes #89

Comment on lines 176 to 180
def record_to_scim(record)
record.to_scim(location: url_for(action: :show, id: record.send(@id_column)))
record.to_scim(
location: url_for(action: :show, id: record.send(@id_column)),
attributes: params.fetch(:attributes, "").split(",")
)
Copy link
Contributor Author

@xjunior xjunior Feb 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this method could be pushed up to ResourcesController, and let the specializations like ActiveRecordBackedResourcesController be responsible for supplying objects that respond to to_scim.

@xjunior xjunior force-pushed the request-attributes branch from 2a1d6ed to 2a2e126 Compare February 1, 2024 18:26
@xjunior
Copy link
Contributor Author

xjunior commented Feb 5, 2024

Please, let me know if there's anything that I'm missing or could be better.

@xjunior
Copy link
Contributor Author

xjunior commented Feb 14, 2024

Hello, @pond 😄 ! We're looking forward to having this feature in our SCIM endpoint. Do you think we could move forward with this PR?

@xjunior
Copy link
Contributor Author

xjunior commented Feb 28, 2024

I'm really sorry to bother you with PR's, but we're looking to incorporate this feature in our SCIM server, and we might not be able to wait much longer. We're looking for feedback on this and perhaps move this work forward. Thank you

@xjunior
Copy link
Contributor Author

xjunior commented Mar 7, 2024

Can I get a review on this PR?

@web-kat
Copy link

web-kat commented Mar 8, 2024

Hi @pond we would really love to use this feature in our SCIM implementation. How can we move forward with this PR?

@pond
Copy link
Member

pond commented Mar 13, 2024

I've been too busy to get to this, but looking at it today.

Please do remember that anyone at any time can fork a gem with their own additions, to incorporate something that they have as a PR but is waiting on a maintainer. Your Gemfile just references the fork.

gem 'foo', git: 'https://github.com/myaccount/forked-gem-name.git', branch: 'something'

...so you don't need to wait on me to use a gem modification; you can in the short term use a fork or PR branch directly.

@xjunior
Copy link
Contributor Author

xjunior commented Mar 22, 2024

@pond we'll come to a deadline next week, so I was wondering if you think this PR could make it until then? I believe you want to complete #109 first since they overlap.

@xjunior
Copy link
Contributor Author

xjunior commented Mar 22, 2024

The other option is, of course, to fork meanwhile as you suggested. We were trying to avoid the overhead of doing it as much as we could hold.

@pond
Copy link
Member

pond commented Mar 25, 2024

@xjunior

we'll come to a deadline next week, so I was wondering if you think this PR could make it until then

Well I can't be held to external third party unspecified deadlines, obviously. I misread this as being related to #109 originally - I'm juggling a great many things at the mo., sorry for the confusion if you saw the pre-edit version of this comment via a notification or similar.

I might be able to get to it - if we can clear #109, I can get this as next-cab-off-rank.

(That said I really don't see how getting a full JSON set back vs a small number of fields is particularly a deal-breaker, and always considered this a feature that's as likely to use enough CPU / RAM on the server side to be more expensive than bandwidth saved, assuming enough requests are coming in to make the bandwidth savings worthwhile).

@pond pond mentioned this pull request Mar 25, 2024
@pond
Copy link
Member

pond commented Mar 25, 2024

@xjunior OK, so this now has a lot of conflicts (as expected) after #109 went in.

I can't fix these as your new attributes parameter is undocumented. I don't know whether that's meant to be local data model attributes, SCIM attributes, if the latter whether that's described as dotted paths, arrays, or whatever, and whether it requires Symbols, Strings, etc...

...so, first thing, since you've added a new parameter to an already parameter-heavy back end method, please do take care to follow the existing commentary and indentation style to document your new parameter. Then we're in a position to assess how flexible that is, and how it should be applied to the heavily updated from-SCIM backend code.

(NB As is often said, the two hardest problems in computing are cache expiry, naming things and off-by-one errors. The parameter name attributes is very generic and confusing in the face of other very similar sounding attributes post-#109, so perhaps a bit of a rename is on the cards there, too?)

EDITED TO ADD: Yes, I see from reading tests and the reference to #89 that we're talking about https://datatracker.ietf.org/doc/html/rfc7644#section-3.10 representation here, but that needs documenting, String-vs-Symbol needs clarifying in the methods with the new parameter and I'm not sure if you handle schema prefixes in this patch. A good name by the way could be include_attributes since there's also not-done-in-this-PR excludedAttributes (https://datatracker.ietf.org/doc/html/rfc7644#section-3.9) and if we were to want to support that in future, include_attributes / exclude_attributes parameter naming in the lower levels would make life a lot easier.

@xjunior
Copy link
Contributor Author

xjunior commented Mar 25, 2024

@pond I'll work on fixing these conflicts and following your suggestions, thank you!

@pond
Copy link
Member

pond commented Mar 26, 2024

@xjunior Thanks. I don't mind this PR being a smaller implementation where e.g. it only handles non-schema prefix attributes etc., it's fine to take baby steps, but yeah defo please do the docs & have a think about parameter names with an eye to potential future changes.

I'll try to expedite a review, timezones permitting, once you give me a shout that it's ready for another look.

@xjunior xjunior marked this pull request as draft April 1, 2024 18:37
@xjunior xjunior marked this pull request as ready for review April 8, 2024 13:33
@xjunior
Copy link
Contributor Author

xjunior commented Apr 10, 2024

I'm not sure if you handle schema prefixes in this patch

I did not. It seems by that prefixes are not required, but recommended:

clients MAY omit core schema attribute URN prefixes but SHOULD fully qualify extended attributes with the associated schema extension URN to avoid naming conflicts.
Section – 3.10

This implementation supports extension attributes, and the nature of the attribute mapping today doesn't allow a name conflict, but it does not support prefixing extension attributes with their schemas. Would that hold shipping this initial implementation?

@pond pond changed the base branch from main to feature/request-attributes June 11, 2024 22:14
@pond
Copy link
Member

pond commented Jun 11, 2024

Merging this into a feature branch for further experimentation and hopefully inclusion in a release.

@pond pond merged commit 009b5c2 into RIPAGlobal:feature/request-attributes Jun 11, 2024
5 checks passed
pond added a commit that referenced this pull request Jun 12, 2024
Allow requesting specific attributes (derived from #102)
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

Successfully merging this pull request may close these issues.

Add support for selecting specific attributes
3 participants