Skip to content
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

Support requiring the scan of a secret to start onboarding #749

Merged

Conversation

shankari
Copy link
Contributor

This is the most challenging part of e-mission/e-mission-docs#628
Concretely:

  • Add a new secret check module
  • have the external URL launch invoke the secret check module
  • on success, start the built-in onboarding (no downloading the UI)

Since the UI is not replaced by download, we needed to add a new state to the onboarding flow to replace it.

High level changes:

  • Add a secret check module
  • Copy over the initial screen from em-base
  • Add a new state to the onboarding process
  • once the onboarding has started, include the secret as part of the token sent to the server

This is a hack to support the specific requirements of the NREL publication
process, which is currently intended to be a closed system.
- Users need to scan a specified QR code that represents a secret
- They are allowed to proceed only if the secret matches the app secret

In the long term, we want to use channels directly instead of this "secret"
code. However, we didn't want to deal with externally hosted software for
approval at this time.

This is the commit fixes the first three tasks in
e-mission/e-mission-docs#628

in particular,
e-mission/e-mission-docs#628 (comment)
and
e-mission/e-mission-docs#628 (comment)

Changes:
- new "secretcheck" service
- on receiving a custom URL, pass the parameter to secretcheck
- secretcheck validates the secret and stores it
- change startprefs so that if we have a valid stored secret, we can move on to
  checking the other onboarding states
- copy over the templates and the javascript code for the first screen from the
  em-base repository
Fairly simple fix
We read the hardcoded secret directly from the `SecretCheck` module since we
should not have come to this screen unless the input `SecretCheck` and the
hardcoded secret match, so we might as well use the hardcoded check.

This is the final set of changes for
e-mission/e-mission-docs#628

Testing done:

Checked the userid on the server.

```
 {'_id': ObjectId('60503a011fa22fb602d332b1'),
  'user_email': 'REPLACEMEkVVdF9rT',
  'uuid': UUID('cf8ccb7b-84d7-40e4-a726-7691e614b042'),
  'update_ts': datetime.datetime(2021, 3, 15, 21, 54, 25, 463000)}]
```

Checked the userid on the phone - was the same

Checked the server logs, auth was fine

```
START 2021-03-15 21:54:25.460376 POST /profile/create
END 2021-03-15 21:54:25.467684 POST /profile/create  0.007261991500854492
START 2021-03-15 21:54:25.583845 POST /profile/get
END 2021-03-15 21:54:25.589675 POST /profile/get cf8ccb7b-84d7-40e4-a726-7691e614b042 0.005787849426269531
START 2021-03-15 21:54:26.051814 POST /profile/update
END 2021-03-15 21:54:26.057612 POST /profile/update cf8ccb7b-84d7-40e4-a726-7691e614b042 0.0057489871978759766
START 2021-03-15 21:55:32.222428 POST /result/metrics/timestamp
END 2021-03-15 21:55:32.234051 POST /result/metrics/timestamp cf8ccb7b-84d7-40e4-a726-7691e614b042 0.011476993560791016
```
@shankari shankari merged commit 9a4c148 into e-mission:nrel_location_history Mar 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant