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

[WIP] Add commit metadata from User-Agent #115

Closed
wants to merge 1 commit into from

Conversation

chrysn
Copy link

@chrysn chrysn commented Nov 23, 2019

This is a work-in-progress PR demonstrating the direction in which I'd like to fix #113.

To represent the attributes of the requester, an Author class (name may not fit perfectly, but it aligns with what the variable is called all around so far) is introduced. This will (in later authenticated cases) contain the user identifier, but primarily now contains the User-Agent. Unless xandikos does authentication itself, it won't contain authentication information.

To support Xanthikos' modular approach, interaction with it is centered around named access functions; for the (currently only supported?) case of a WebDav front-end on a Git back-end, an Author can be created from_request (extracting the User-Agent, and in future things like the user name / OpenID / certificate details). Back-ends would use dedicated formaters to place the information in whatever they take for storage. For git, both trailers and commit author information can be populated; additional fields may make sense later (eg. extracting the author time stamp's time zone into the change timestamp, if that's sent by user agents).

Plan for the development of this PR is to (hereby) ask for preliminary review of the approach taken (primarily the presence and use of the Author class), and to add author argument passing-along where the chain of author=author arguments is incomplete yet.

This introduces an Author class that carries and formats author
metadata, in particular (and initially here) its User-Agent header.

As the author is not passed around everywhere yet, this only works for
item deletion so far.
@jelmer
Copy link
Owner

jelmer commented Nov 23, 2019

Thanks! Just a quick note to say I like the overall approach.

@chrysn
Copy link
Author

chrysn commented Nov 23, 2019

I'm a bit in doubt about the passing of author through the xandikos.web functions -- that's a lot of def ...(author=None) calling ...(author=author) without doing anything else with it. (delete_member alone needed three different implementations changed to pass it through).

The Resource objects are rather ephemeral, are they not? If so, it might make sense to create them with an author (think "This represents /foo/calendards/cal as accessed by foo's web browser*"), so they have an author available. (If, of course, the Resource objects are up for caching of objects, that would be a bit counter-productive).

edit: I think I'll try to split the PR up branch-wise to have the essential functionality at the base and then just try out both versions, unless you have any particular design line to follow here.

@jelmer
Copy link
Owner

jelmer commented Nov 24, 2019

The Resource objects are currently indeed ephemeral, but they may not be in the future. I've played with the idea of e.g. caching them (and the associated Git objects), but have not yet had a need to implement that (since performance is reasonable). Of course, we could cache by (author, href), but the cache would be less useful at that point.

The other consideration here is what happens when we add fine-grained authorization at some point in the future (i.e. can user X make changes to resource Y?). I think we'd want to do that based on some object representing the user that is taking the action. This is very similar to what author would be, at least in the middle layers of the stack. And the middle layers would actually have to do more than just pass the object along.

Perhaps this is an argument for renaming Author to something like User or Actor (i.e. something that does not imply making a modification), with the idea that eventually this object will be passed to most middle layer functions.

@jelmer jelmer marked this pull request as draft October 29, 2020 23:17
@jelmer
Copy link
Owner

jelmer commented Jul 23, 2021

Any news on this, or can I close it for the moment?

@jelmer
Copy link
Owner

jelmer commented Mar 10, 2022

Closing this since it's stale. Still happy to land something like this, feel free to reopen.

@jelmer jelmer closed this Mar 10, 2022
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.

Store User-Agent in commit messages
2 participants