Skip to content

Latest commit

 

History

History
109 lines (81 loc) · 3.1 KB

UsersRevisited.adoc

File metadata and controls

109 lines (81 loc) · 3.1 KB

Users Revisited

In [ch-users] we put Documents directly the database to represent an initial User.

Operations can’t be invoked without a User, yet Operations, but Operations are required to create Users. We had a chicken-and-egg situation that we resolved by directly inserting the first user by hand.

However, now that we have built the capability to create Operations and Permissions, we can build the Operations to create new Users, User Identities and Subjects. That’s the subject of this chapter.

Create an operation to create a user

An Operation to create a User should take a new Document describing the User, validate that the :juxt.site.alpha/type attribute is set to https://meta.juxt.site/pass/user and other required checks. For example, a User might be required to have a name and other required attributes.

Creating an operation to put a user demonstrates the creation of an Operation that fulfils these criteria.

Example 1. Creating an operation to put a user
link:../../test/juxt/book.clj[role=include]

Here we grant the REPL user access to perform this Operation.

link:../../test/juxt/book.clj[role=include]
  1. Check the format of the id.

  2. Check the type.

  3. Default the type, if not given in the argument.

  4. Allow the user details to be retrieved via the GET method, with the https://site.test/operations/get-user Operation.

  5. Ensure only roles with a Permission are able to perform this Operation.

Important

Copy the code in Creating an operation to put a user, paste it into a REPL and evaluate.

Create an Operation to create a User Identity

In the same way, we may also need the ability to create a User Identity. For this Operation it is important that the Document given in the document refers to the User it is identifying.

See Creating an Operation to put a User Identity for a demonstration of creating and permitting an Operation that meets these requirements.

Example 2. Creating an Operation to put a User Identity
link:../../test/juxt/book.clj[role=include]

Here we grant the REPL user access to perform this Operation.

link:../../test/juxt/book.clj[role=include]
Important

Copy the code in [ex-create-operation-put-identity], paste it into a REPL and evaluate.

Create an Operation to create an Subject

Example 3. Creating an operation to put a subject
link:../../test/juxt/book.clj[role=include]

Here we grant the REPL user access to perform this Operation.

link:../../test/juxt/book.clj[role=include]
Important

Copy the code in Creating an operation to put a subject, paste it into a REPL and evaluate.