MunitasFeature tourAll walkthroughs

All walkthroughs / Health organisation

Health organisation · Regular data

Sign a notebook in, with a pass that cannot decide anything

A researcher signs a Python notebook in as themself. The notebook shows a code, the researcher types it in the console and approves, and the notebook receives a short-lived pass that reaches only what a notebook needs. The pass cannot decide a request, and the researcher can end it at any time.

10Steps
1Person
about 8Minutes to read
Who is involved
Sam
Researcher in the Health organisation

How to read this page

Words used on this page

Organisation
A company or hospital group that uses Munitas. Each organisation sees only its own data.
Department
A team inside an organisation that owns some of its data, such as Cardiology.
Dataset
A named collection of records, such as a table of patient admissions.
Custodian
A person who holds the data custodian role, which allows deciding who may read data. A custodian decides for the departments they are an approver for.
Access level
How restricted a dataset is. Raw is the most restricted, and nobody may read it without permission. Published is the most open.
Lease
Permission, given by the custodian, to read one dataset for one stated purpose and for a limited time.
Query
A question about a dataset, written in a language called SQL.
Sensitivity label
How identifying a column is. none does not identify anybody, quasi is a detail that could help identify a person when combined with others, and phi is protected health information.
Token
A short-lived password that also states why the person wants to read.
Sealed
Finished and closed for good, so that it can never be edited.
Iceberg table
An open way of storing a table that tools such as DuckDB can read directly.
PART ONE

Signing a notebook in

Sam, a researcher, does the readmission work in a Python notebook, which is a document that mixes code with the results of running it. A notebook is never given Sam's password or Sam's console sign-in, because either would let it do everything Sam can, including the things Sam should only ever do on screen, such as deciding a request. A notebook gets a pass of its own instead, which is a short-lived key that stands for one signed-in notebook and reaches much less.

1
Sam
Sam starts a sign-in in the notebook
Python on Sam’s own computer, using the Munitas client library

The notebook asks Munitas for a code, shows it with an address, and waits. Nothing is signed in yet, and nothing has been given to the notebook. The notebook gives itself a name, so that Sam can tell it apart from another one later.

Typed by Sam, in Python on Sam’s own computerMunitas.sign_in is the Munitas client library asking Munitas for a code, and then waiting for the person to approve it in the console.
me = Munitas.sign_in(API, label="Sam's readmission notebook", wait=180)
What came back
To sign this notebook in as you, open http://localhost:4444/oauth2/device/verify?user_code=FGMFNQGC and type the code FGMFNQGC. Check that the notebook it names is "Sam's readmission notebook". It waits for you up to 10 minutes.
The notebook printed an address to open and a code to type. It also printed Check that the notebook it names is "Sam's readmission notebook", so that Sam can compare the name, and it says how long it waits: It waits for you up to 10 minutes.
2
Sam
Sam types the code in the console
Munitas console · Sign a notebook in · /notebook-sign-in/code

Sam opens the address the notebook showed, in the console where Sam is already signed in, and types the code. Typing it proves that the person at the console is also the person at the notebook. Somebody who did not just start a sign-in has nothing to do on this page.

Screenshot: Sam types the code in the console
The page is headed Sign a notebook in, and the box The code in the notebook holds the code. Under the button it says If you did not start a sign-in in a notebook just now, close this page: nothing has been given to anybody.
3
Sam
Sam checks which notebook it is, and what it will be able to do
Munitas console · Approve this notebook · /notebook-sign-in/consent

Before approving, Sam is told which notebook is asking, from which address, with which program, and for how long the sign-in can last. The page lists what the notebook will be able to do as Sam and, just as plainly, what it will not.

Screenshot: Sam checks which notebook it is, and what it will be able to do
Next to The notebook calls itself the page says Sam's readmission notebook, and next to Lasts at most it says 8 hours. Under It cannot: the first line is decide anybody's request, including your own.
4
Sam
Sam approves, and the console says the notebook is signed in
Munitas console · The notebook is signed in · /notebook-sign-in/done

Sam presses Approve. The notebook, which has been asking every few seconds whether Sam has answered, now receives its pass. The pass lasts 15 minutes and renews itself, up to the 8 hours Sam saw, for as long as nobody ends the sign-in.

Screenshot: Sam approves, and the console says the notebook is signed in
The heading says The notebook is signed in, and the line under it says The notebook is signed in as you and will carry on by itself.
5
Sam
The notebook now acts as Sam
Python on Sam’s own computer, using the Munitas client library

The same line of code that was waiting has finished, and the notebook holds its pass. It asks who it is signed in as, and finds a dataset by name, which Sam may do.

Typed by Sam, in Python on Sam’s own computerme is the Munitas client library, a small Python package that asks Munitas for things on the person’s behalf, signed in as Sam.
who = me.me
print(f"Signed in as {who['label']} in the {who['tenant_id']} organisation")
found = me.dataset("diagnosis_codes")
print(found["name"], "has", found["version_count"], "version, and Sam may read it")
What came back
Signed in as Sam in the health organisation
diagnosis_codes has 1 version, and Sam may read it
The first line says Signed in as Sam, and the second finds diagnosis_codes, the public lookup. The notebook sees what Sam sees, and nothing more.
PART TWO

What the pass cannot do, and ending it

A notebook that could do everything its person can would be a risk if it were copied or left behind. So the pass is limited, and the person can end it at any time.

6
Sam
The pass cannot decide anything
Python on Sam’s own computer, using the Munitas client library

A notebook may find datasets, ask for access, open the few files its person was allowed to open, and make a dataset from a query. Deciding a request, or changing a role, is done in the console. Sam tries to approve a request from the notebook.

Typed by Sam, in Python on Sam’s own computerme is the Munitas client library, a small Python package that asks Munitas for things on the person’s behalf, signed in as Sam.Names used here that are not defined in this box: MunitasError is the error the client library raises when Munitas refuses a request.
try:
    me.approve("any-request-at-all")
except MunitasError as exc:
    print("Refused:", exc)
What came back
Refused: HTTP 403: a notebook sign-in reaches only what the client library does: finding datasets, asking for access, opening the few files you were allowed, and making a dataset from a query. Anything else, such as deciding a request, is done in the console
Munitas answers with the code 403, which means refused, and says a notebook sign-in reaches only what the client library does. The refusal comes before Munitas looks at which request it was or who Sam is, so a copied pass could not do it either.
7
Sam
Your notebooks lists every notebook signed in as Sam
Munitas console · Your notebooks · /notebook-sign-ins

In the console, the page called Your notebooks lists each notebook that signed in as Sam: its name, when it started, until when it can last at most, when it was last used and from which address.

Screenshot: Your notebooks lists every notebook signed in as Sam
The row for Sam's readmission notebook shows the state In force and a yellow label in use now, because the notebook made a request a moment ago. The button End now is at the end of the row.
8
Sam
Ending a notebook that is in use asks first
Munitas console · Your notebooks · /notebook-sign-ins

Sam presses End now. Because the notebook was used a moment ago, the page asks before it ends something that may be in the middle of work.

Screenshot: Ending a notebook that is in use asks first
A question appears in the row: End this notebook's sign-in? It says the notebook may be in the middle of work and stops at its next request. The answers are Yes, end it and Keep it.
9
Sam
The sign-in has ended
Munitas console · Your notebooks · /notebook-sign-ins

Sam answers yes. The pass stops working at the notebook's very next request, and the renewal that would have kept it going stops too.

Screenshot: The sign-in has ended
The state of the row now reads Ended by the person.
10
Sam
The notebook is refused from then on
Python on Sam’s own computer, using the Munitas client library

Back in the notebook, the same kind of request that worked a minute ago is refused. To go on, Sam would sign the notebook in again, with a new code.

Typed by Sam, in Python on Sam’s own computerme is the Munitas client library, a small Python package that asks Munitas for things on the person’s behalf, signed in as Sam.Names used here that are not defined in this box: MunitasError is the error the client library raises when Munitas refuses a request.
try:
    me.dataset("diagnosis_codes")
except MunitasError as exc:
    print("Refused:", exc)
What came back
Refused: HTTP 401: this notebook sign-in is not in force. Sign in again from the notebook
Munitas answers with the code 401, which means not signed in: this notebook sign-in is not in force.