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

MSC2461: Proposal for Authenticated Content Repository API #2461

Open
wants to merge 4 commits into
base: old_master
Choose a base branch
from

Conversation

SyrupThinker
Copy link

Signed-off-by: Valentin Anger <syrupthinker@gryphno.de>
@SyrupThinker SyrupThinker changed the title Proposal for Authenticated Content Repository API MSC2461: Proposal for Authenticated Content Repository API Mar 15, 2020
@turt2live turt2live added proposal A matrix spec change proposal proposal-in-review labels Mar 15, 2020
@turt2live turt2live self-requested a review March 15, 2020 06:04
Copy link
Contributor

@Sorunome Sorunome left a comment

Choose a reason for hiding this comment

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

Nice idea, a few things aren't clear to soru, though

| ---------- | ----------- |
| null / missing | All content can be accessed unauthenticated |
| m.cached | Only cached content can be accessed unauthenticated |
| m.local | Only content with an authority the server is responsible for can be accessed unauthenticated |
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this mean? Basically all users in the room can see it, but noone else?

Copy link
Author

Choose a reason for hiding this comment

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

See other comment.
Does the new context clarify the meaning of this?
Because to me it is phrased very clearly.

| Enum value | Description |
| ---------- | ----------- |
| null / missing | All content can be accessed unauthenticated |
| m.cached | Only cached content can be accessed unauthenticated |
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this even needed? It sounds odd - someone in the room accesses the content and then suddenly everyone can as it is cached

Copy link
Author

Choose a reason for hiding this comment

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

Replying to the first part of the question, as the latter is unrelated as clarified elsewhere.
This is based on Mathew's comment in synapse#2133.
One possible use case for m.cached is that a server admin knows that all users are responsible and allows content that they accessed (and then for exampled didn't report) to be accessed by older clients and to be directly linked to for bridges or download links.


### Configuration
To allow clients to predetermine whether authentication is required,
the configuration field m.media.unauthenticated is added.
Copy link
Contributor

Choose a reason for hiding this comment

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

Added where? To which endpoint? Down there you have that as a reply and not as sending, so something is off

Copy link
Author

Choose a reason for hiding this comment

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

Added endpoint in new revision

}
```

Clients can decide based on this
Copy link
Contributor

Choose a reason for hiding this comment

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

why not add the authentification type to m.file etc.? So like

{
  "url": "blah",
  "info": { ... },
  "authenticated": "m.local"
}

Copy link
Author

Choose a reason for hiding this comment

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

I might have miscommunicated the intent of this proposal by adding synapse#2150 considering it is only tagentally related. I've read the conversation some time ago and added it from memory. Only checking whether I cought the issues I was thinking of.

I have clarified the intent in a new revision.

Signed-off-by: Valentin Anger <syrupthinker@gryphno.de>
@helaan

This comment has been minimized.

`GET /_matrix/media/r0/config`.
It specifies what content can be accessed unauthenticated.

The following behaviours are defined:
Copy link
Author

Choose a reason for hiding this comment

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

Threaded discussions are preferred @helaan

  • m.local Correct, it also allows compliance with local regulations regarding the possession and distribution of illegal content.
  • m.cached Not quite, if the server already fetched the content (or it originated on this server), unauthenticated users can access it. Maybe m.stored is less confusing?
  • m.none and null / missing Exactly.
  • m.unspecified The server could use different criteria to allow access to content, that are not covered by this document.
    This is basically the fallback case of "you need to check to know whether you can access something".
    One might also call it arbitrary, but I didn't want the connotation of
    it never being consistent.

An unpublished version contained "Each entry in the following table is a subset of the preceding ones, with m.unspecified not fitting into this hierarchy".

Copy link

Choose a reason for hiding this comment

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

Ah, I'll switch to threaded replies then.

An unpublished version contained "Each entry in the following table is a subset of the preceding ones, with m.unspecified not fitting into this hierarchy".
That makes it a lot clearer, I did not pick up on m.cached being comparable to m.local.

About m.none: Maybe state more clearly that this is only possible on unfederated servers?

What do you think will be the mode that servers in the public federation will use when this MSC is implemented and it is worth it to have it flexible? Personally, I think federated servers will switch to m.local and unfederated servers will just use m.none. Wouldn't this be simpler and as effective to have this setting depend on whether or not you have federation enabled or am I underestimating the importance of old client support?

Copy link
Author

Choose a reason for hiding this comment

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

In my opinion m.none is not just possible on unfederated servers. Having m.none as the default for unfederated servers seems sensible, but concluding that when a server federates it will always have an accessible content repo is wrong. An admin might just not want to distribute through the media endpoints regardless.

I agree m.local would be the most common case for federated servers.

Especially m.cached gives nice properties like explained in the MSC. Although that could be cut and signaled through m.unspecified, loosing the benefit of clients knowing they can link to the content directly.

Having m.unspecified forces client and server authors to think about the possibility of rejection, something that some current clients don't do. It empowers admins to have a different rule set without clients failing when they make assumptions for the other cases.
Maybe this should be replaced or amended with "When an unknown value is encountered a client should account for the possibility of rejection".

Preserving compatibility with older clients is also a choice admins should make.
Explicitly supporting the old behavior allows this.

If I were to create the simplest form of this proposal it would just state.

All unauthenticated accesses to media endpoints may be rejected for any reason

Copy link
Member

@turt2live turt2live left a comment

Choose a reason for hiding this comment

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

Generally is a good idea, but the footgun on exploiting your own account will need solving.

Additionally older clients and servers might encounter an unexpected error code
which may lead to unknown behaviour.

## Alternatives
Copy link
Member

Choose a reason for hiding this comment

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

This will need a section comparing it to MSC701


### Configuration
To allow clients to predetermine whether authentication is required,
the field m.media.unauthenticated is added to
Copy link
Member

Choose a reason for hiding this comment

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

generally we should be naming things in the positive:

Suggested change
the field m.media.unauthenticated is added to
the field m.media.authenticated is added to

Copy link
Author

Choose a reason for hiding this comment

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

This would lead to the inverted enum values m.non-local and m.uncached
which are in my opinion worse than having the field name in the negative.

I'm open to suggestions for better enum names

Copy link
Member

Choose a reason for hiding this comment

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

tbh when I was leaving this comment I was expecting it to be a boolean, not an enum. Not sure there's a benefit for having it be an enum at all, or even really needing this flag is needed.

Copy link
Author

Choose a reason for hiding this comment

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

Well, that depends on whether servers can actually make use of that value (according to you they should not) and whether its considered useful enough for clients (as noted in the MSC).

If those are not considered useful then all that stuff can be thrown out.

### Server to server
To reduce the amount of server to server communication,
when one homeserver tries to fetch content from another homeserver,
the configuration should first be retrieved and cached.
Copy link
Member

Choose a reason for hiding this comment

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

There is no federation API for this.

Copy link
Author

Choose a reason for hiding this comment

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

I figured that because servers use the client API for media downloads they could also use it for the media config endpoint

Copy link
Member

Choose a reason for hiding this comment

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

They cannot. Also they aren't supposed to be using the client endpoints, they just haven't been defined correctly in the server-side endpoints.

Copy link
Author

Choose a reason for hiding this comment

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

Then this proposal is the time to specify that I'd say. Sharing media will be hard.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe the "federation api" could be an extra query parameter on existing download/thumbnail endpoints, which can be as simple as authed=yes/no? Of course, servers would need to also authenticate that it is another server that is requesting such media, and not someone else.


## Potential issues
Once homeservers enable this behaviour with a m.media.unauthenticated
value other than null, older clients will not be able to access some content.
Copy link
Member

Choose a reason for hiding this comment

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

Not only older clients, but many desktop clients will have a hard time accessing images now. Some of the toolkits people use don't allow them to add headers before the request, so they'd need to add special code for this to buffer the media ahead of time.

This isn't a problem we need to fix in the MSC though, just something to be aware of.

`GET /_matrix/media/r0/config`.
It specifies what content can be accessed unauthenticated.

The following behaviours are defined:
Copy link
Member

Choose a reason for hiding this comment

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

I'd generally just recommend we have it turned on for the client-server API regardless. There's nothing stopping a server from accepting lack of auth, and realistically the spec should fix the general case of media being locked down.

Copy link
Author

Choose a reason for hiding this comment

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

Such a change should only happen after some server-server API is in place though, right?
Otherwise media couldn't be fetched from a strictly conforming server.

}
```

## Potential issues
Copy link
Member

Choose a reason for hiding this comment

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

Also mentioned in MSC701 (I think, I'm going off memory) is a way to solve the authentication issue without potentially leaking your access token. Clients which have 'download this file' or 'open in new tab' buttons will need to pass along the access token via the query string. In doing so, when someone copies the link and pastes it to someone else they've exposed their account.

Copy link
Author

Choose a reason for hiding this comment

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

I really try to stay away from crypto, so this is just a naive simplification of MSC701:

The authentication token is created through HMAC(access_token, media_id).
This way only the media download can be replayed.
I'm not sure how the HMAC would be verified, but that'd need to be solved for MSC701 as well.

- Specify behaviour on unknown enum values
- Include points brought up by turt2live
- Draw a comparison to MSC701
- Formatting

Signed-off-by: Valentin Anger <syrupthinker@gryphno.de>
@turt2live turt2live added kind:feature MSC for not-core and not-maintenance stuff kind:maintenance MSC which clarifies/updates existing spec and removed kind:feature MSC for not-core and not-maintenance stuff labels Apr 20, 2020
Copy link
Contributor

@ShadowJonathan ShadowJonathan left a comment

Choose a reason for hiding this comment

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

I like this idea, but I think it has a fatal flaw and confusion with m.none that i'd like to see resolved first.


| Enum value | Description |
| ---------- | ----------- |
| null / missing | All content can be accessed unauthenticated |
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm seeing m.none mentioned below, should that one be added here? Or what's the status on that?

Copy link
Author

Choose a reason for hiding this comment

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

null should actually be m.none here, thanks for pointing that out.

To reduce the amount of server to server communication,
when one homeserver tries to fetch content from another homeserver,
the configuration should first be retrieved and cached.
When the value is m.none the server should not attempt to fetch the
Copy link
Contributor

Choose a reason for hiding this comment

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

Does m.none effectively mean "All content uploaded on here is non-accessible to other servers"? that breaks quite a lot of (core) assumptions in matrix, where f.e. someone setting a room avatar in a federated room can suddenly "not display" that avatar simply because the server does not allow federated propagation of that file, per server-wide rules.

Copy link
Author

Choose a reason for hiding this comment

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

I assume my other comment clears the first part up, but m.none actually means no restrictions, as in the current behaviour. m.all would actually be the behaviour you describe, as in everything is restricted.

For the latter, yes, that is an expected consequence of this proposal.
I'd expect a user to be made aware by server owners if such media restrictions are in place.

Copy link
Contributor

Choose a reason for hiding this comment

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

"restricted" as in "can only be accessed once authenticated"? And that any server over federation can request such media in an authenticated user's stead?

@turt2live turt2live removed their request for review April 19, 2021 15:46
@turt2live turt2live added the needs-implementation This MSC does not have a qualifying implementation for the SCT to review. The MSC cannot enter FCP. label Jun 8, 2021
@turt2live
Copy link
Member

@SyrupThinker Thanks for opening this MSC! We've been considering authentication for quite a while, and really appreciate efforts to fix this particular area of the protocol. Lately we've been working on #3916 as a way forward to authentication, and are currently gearing up for acceptance on it.

If there's something we haven't yet considered in MSC3916 that you think we should, let us know. It's our current proposal to close this MSC in favour of MSC3916.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:maintenance MSC which clarifies/updates existing spec needs-implementation This MSC does not have a qualifying implementation for the SCT to review. The MSC cannot enter FCP. proposal A matrix spec change proposal
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants