Warning
This is a very unfinished document where I brainstorm ideas and concepts for the new version of this project. Treat it as a very early draft.
Each scope is expressed as a Uniform Resource Name (URN). URNs are a way to uniquely identify resources and follow the format urn:<namespace>:<resource>. In our case, the format is urn:<app name>:<auth>:<resource>:<access>:
urnis the prefix for all URNs- Namespace is a combination of
<app name>and<auth><app name>is the name of the app; we usestaartin the examples below- Scopes can be for an organization or a user, so
<auth>always starts withorg_orusr_
<resource>is the resource the scope is for- Each scope must always end with the level of
<access>which can be eitherreadorwrite
For example:
urn:staart:org_1abc9c:*:read-> read access to the organization with the IDorg_1abc9curn:staart:usr_1abc9c:*:write-> write access to the user with the IDusr_1abc9c
You can also have scopes that are limited to a specific resource, for example:
urn:staart:org_1abc9c:membership_16a085:read-> read access to the membership with the IDmembership_16a085in the organization with the IDorg_1abc9curn:staart:usr_1abc9c:email:write-> write access to the email of the user with the IDusr_1abc9curn:staart:org_1abc9c:membership_16a085:user:read-> read access to the user in the membership with the IDmembership_16a085in the organization with the IDorg_1abc9c
Scope matching uses glob patterns, so you can also have wildcard scopes:
urn:staart:org_1abc9c:membership_*:read-> read access to all memberships in the organization with the IDorg_1abc9curn:staart:usr_*:write-> write access to all usersurn:staart:org_*:membership_16a085:read-> read access to the membership with the IDmembership_16a085regardless of the organization
Other implementation notes:
- Each scope must have at least 4
:characters (urn, namespace, organization or user, resource,readorwrite)urn:staart:org_1abc9c:readis not valid, instead useurn:staart:org_1abc9c:*:readurn:staart:usr_1abc9c:resource:subresource:subsubresource:readis valid and can be used to create complex scopes
readis a strict subset ofwrite, so if a user haswriteaccess to a resource, they also havereadaccess to it; therefore:- A token cannot have both
readandwriteaccess to the same resource
- A token cannot have both
- Superadmins by definition have all rights, so they have the scope
urn:staart:*:*:write
- Use
p-min-delayto delay responding to auth requests to at least 1 second to prevent timing attacks. For example, making a request to/auth/loginwill always take 1 second (even though it should usually be much shorter) so that it's impossible to know whether a user exists or not (since throwing a 404 is faster than when a user exists and password comparisons take place) and also useful for hash comparisons.