All walkthroughs / Health organisation
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.
me is the client library signed in as the person named on the label, and custodian is the client library signed in as the custodian.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.
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.
Munitas.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.
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.
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.
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.
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.
me 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 backSigned in as Sam in the health organisation diagnosis_codes has 1 version, and Sam may read 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.
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.
me 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 backRefused: 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
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.
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.
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.
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.
me 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 backRefused: HTTP 401: this notebook sign-in is not in force. Sign in again from the notebook