-
Notifications
You must be signed in to change notification settings - Fork 13
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
Inbound and outbound anchors #157
Comments
Example of how the URL inbound anchor could be used: @app.route('/mydocuments/<doc>/edit/<secret_key>', methods=['GET', 'POST'])
@load_model(MyDocument, {'name': 'doc'}, 'rawdoc', kwargs=True)
@url_anchor(document='rawdoc', anchor='kwargs.secret_key')
def document_edit(rawdoc, kwargs):
doc = rawdoc.access_for(current_auth.user, current_auth.anchors)
# Further activity is with `doc`
form = MyDocumentForm(obj=doc)
if form.validate_on_submit():
form.populate_obj(doc)
return redirect(doc.url_for('view'), code=303)
return render_form(form, title="Edit document") This one is lacking an outright mechanism by which to issue a 401 Forbidden. It instead limits edit access to whatever is provided by a valid anchor, using logic determined by the model's |
The
Contrast this with the very similar flow used for merging user accounts:
|
These use cases suggest that a |
The While we need the URL anchor to map into a flow, it needs a more useful form. |
Inbound anchors are all tokens of one form or the other. A cookie token, an Authorisation header token, a URL query parameter token or some other. There's no need for a new term like "inbound anchor". Let's just call them tokens. This frees up the word "anchor" for the outbound variety. An anchor is where you can contact someone. An anchor is not a subsidiary of a user, but a first class entity that may be currently affiliated to one or more users, but could previously be affiliated to someone else. In Lastuser, that will mean a new Further, since an anchor contains PII and is subject to privacy/right to be forgotten concerns (including in the form of an unsubscribe), the anchor should not be indexed using the natural key, but using a hash of it. The hash will need an uncommon salt to defend against reversal using rainbow tables. Unfortunately, the salt here cannot be random as with passwords. It has to either derive from the natural key itself, or should be fixed for the data table, since the salt must be known before the record can be looked up. |
Lastuser was merged into Funnel in 2020. Email anchors were implemented as an |
In the process of defining abstractions around our core data models, we've arrived on the following three:
coaster.sqlalchemy
.Anchors do not indicate the existence of a user/principal, but activity that connects two or more anchors can help infer the presence of a user or other principal. Anchors also are not necessarily database objects. By their nature they are also not guaranteed to exist long term.
Inbound anchors (↓)
These are anchors that allow the user to connect to the app. Examples include:
Browser sessions. May or may not be authenticated with a user login (and thereby associated with a principal), but browser sessions can independently create an activity trail. We use this in Hasjob for tracking A/B testing impressions, and previously allowed creation of job posts as well.
Private URLs. A URL that is not published to the public can be used to grant an access role. Hasjob used to use it to allow edits to a job post from anyone with the edit URL. Boxoffice currently uses it to manage ticket assignments. Lastuser uses them to send password reset links. (Access control currently happens in the view layer, but RoleMixin needs to accept principals and anchors #156 describes a mechanism for pushing it into RoleMixin.)
Access tokens. An access token allows a principal to delegate limited access to an anonymous principal (usually a client app that presents it as a Bearer token, but the exact identity of the caller cannot be determined).
OTP. A short lived code that confirms some activity, similar to one of the use cases for private URLs.
Outbound anchors (↑)
Email address. Allows sending an email to what is presumably a principal at the receiving end.
Phone number. Allows sending an SMS or making a phone call to a presumed principal.
Push notification/Browser socket. Allows communication with a client app or browser session.
Outbound anchors like email/phone aren't necessarily verified identifiers. Verification requires a multi-step process as outlined below.
Inferring principals
Activity that creates a combination of an outbound anchor with an inbound anchor (in that order) can confirm that outbound anchor, implying the existence of a principal (if one is not already known). Examples:
Linking
From these examples, documents, principals and anchors can all be linked to each other.
While the implementation details are beyond the scope of Coaster, it should provide a basic framework as it has done for documents and principals (since #154).
The text was updated successfully, but these errors were encountered: