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

feat(1136): Accept AMS OpenID #1369

Merged
merged 87 commits into from
Jan 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
5109614
init
jorgegonzalez Oct 1, 2021
4b8e8f7
Merge branch 'raft-tdp-main' into feat/1136-ams
jorgegonzalez Oct 1, 2021
6840d47
tweak initial ams auth request
jorgegonzalez Oct 4, 2021
e1c21cb
refactor and generalize views
jorgegonzalez Oct 6, 2021
1b62fa2
Merge branch 'raft-tdp-main' into feat/1136-ams
jorgegonzalez Oct 7, 2021
fd249c3
update token params request
jorgegonzalez Oct 7, 2021
05fcf33
Minor refactor
jorgegonzalez Oct 7, 2021
e07b4bd
Merge branch 'raft-tdp-main' into feat/1136-ams
jorgegonzalez Oct 7, 2021
3dae31d
Minor fixes
jorgegonzalez Oct 7, 2021
612e706
Merge branch 'raft-tdp-main' into feat/1136-ams
jorgegonzalez Oct 19, 2021
ba2128c
Merge branch 'raft-tdp-main' of https://github.com/raft-tech/TANF-app…
jorgegonzalez Oct 21, 2021
d90ebdd
feat: nits and initial hhsid support
jorgegonzalez Oct 26, 2021
223d382
Merge branch 'raft-tdp-main' into feat/1136-ams
jorgegonzalez Oct 26, 2021
a061431
Fetch hhsid for authentication
jorgegonzalez Oct 28, 2021
3ac7288
Lint fixes
jorgegonzalez Oct 28, 2021
5a9c1d3
Increase max line length for everyone's sanity
jorgegonzalez Oct 28, 2021
49a428e
Merge branch 'raft-tdp-main' of https://github.com/raft-tech/TANF-app…
jorgegonzalez Nov 3, 2021
aa87411
Various tweaks
jorgegonzalez Nov 4, 2021
6d36344
Merge branch 'raft-tdp-main' into feat/1136-ams
jorgegonzalez Nov 9, 2021
9cec3e3
split up oidc auth handlers for easier testing
jorgegonzalez Nov 10, 2021
0f24cde
Merge branch 'raft-tdp-main' of https://github.com/raft-tech/TANF-app…
jorgegonzalez Nov 15, 2021
019990a
split up token oidc handlers for each auth provider
jorgegonzalez Nov 15, 2021
31e5c8a
Merge branch 'raft-tdp-main' into feat/1136-ams
jorgegonzalez Nov 15, 2021
66bd8ce
nit
jorgegonzalez Nov 15, 2021
abc456d
Merge branch 'raft-tdp-main' of https://github.com/raft-tech/TANF-app…
jorgegonzalez Nov 16, 2021
528c603
Merge branch 'raft-tdp-main' into feat/1136-ams
jorgegonzalez Nov 17, 2021
2a0a1a5
refactor: add ams client assertion
jorgegonzalez Nov 18, 2021
f5e4bde
fix: add hhs_id to admin.py
jorgegonzalez Nov 19, 2021
2fd8c2d
build: tweak for test deployments
jorgegonzalez Nov 19, 2021
dff0627
build: add ams vars to docker-compose
jorgegonzalez Nov 22, 2021
73302ee
Merge branch 'raft-tdp-main' into feat/1136-ams
jorgegonzalez Nov 22, 2021
57bb813
fix: ams request auth scope
jorgegonzalez Nov 23, 2021
4dc5ff3
Merge branch 'raft-tdp-main' of https://github.com/raft-tech/TANF-app…
jorgegonzalez Nov 30, 2021
13d5ced
refactor: update ams redirect uris
jorgegonzalez Dec 1, 2021
4f663c2
refactor: add temp loggers
jorgegonzalez Dec 2, 2021
97a4fac
Merge branch 'raft-tdp-main' into feat/1136-ams
jorgegonzalez Dec 2, 2021
ad09091
refactor: test new token endpoint payload
jorgegonzalez Dec 6, 2021
b7fb6b3
Merge branch 'raft-tdp-main' into feat/1136-ams
jorgegonzalez Dec 6, 2021
aed8323
refactor: fix token request shape
jorgegonzalez Dec 8, 2021
5edd14d
Merge branch 'raft-tdp-main' into feat/1136-ams
jorgegonzalez Dec 8, 2021
bd7d9ea
refactor: remove ams client assertion func
jorgegonzalez Dec 8, 2021
455864b
feat: log in users via hhs
jorgegonzalez Dec 8, 2021
8711fed
Merge branch 'raft-tdp-main' into feat/1136-ams
jorgegonzalez Dec 9, 2021
6265e0f
update import names and small url updates
riatzukiza Dec 10, 2021
2419cbe
update several tests
riatzukiza Dec 10, 2021
4df6545
update frontend tests
riatzukiza Dec 13, 2021
e0c80cc
Got all existing tests to pass again
riatzukiza Dec 13, 2021
712d1c0
styles: fix lint issues, remove additional logs, remove unused vars, …
jorgegonzalez Dec 14, 2021
48ff513
fix: django admin login url
jorgegonzalez Dec 14, 2021
93796f8
fix: auth test
jorgegonzalez Dec 14, 2021
bca61fb
docs: add remote development guide
jorgegonzalez Dec 15, 2021
f1aa418
Merge branch 'raft-tdp-main' into feat/1136-ams
jorgegonzalez Dec 15, 2021
711bb1e
test: add requests_mock and initial ams test
jorgegonzalez Dec 16, 2021
c5b0ce9
feat: add ams logout handler
jorgegonzalez Dec 17, 2021
e9ebd98
test: add TestLofinAMS class with local mock
jorgegonzalez Dec 17, 2021
1bbd391
test: abstract more of TestLoginAMS
jorgegonzalez Dec 17, 2021
39086dc
Merge branch 'raft-tdp-main' into feat/1136-ams
jorgegonzalez Jan 3, 2022
ca01dac
fix: lockfile
jorgegonzalez Jan 3, 2022
1d0c5e7
test: fix latest AMS tests and refactor fixtures
jorgegonzalez Jan 3, 2022
ad04b82
Merge branch 'raft-tdp-main' of https://github.com/raft-tech/TANF-app…
jorgegonzalez Jan 3, 2022
ddf2ac0
test: add additional ams test
jorgegonzalez Jan 3, 2022
87a0afb
test: fix and refactor login tests
jorgegonzalez Jan 3, 2022
b3e8833
Merge branch 'raft-tdp-main' of https://github.com/raft-tech/TANF-app…
jorgegonzalez Jan 5, 2022
4beb63a
Merge branch 'raft-tdp-main' into feat/1136-ams
jorgegonzalez Jan 6, 2022
3021019
Merge branch 'raft-tdp-main' into feat/1136-ams
jorgegonzalez Jan 6, 2022
9e7e68a
Update tdrs-backend/tdpservice/users/api/utils.py
jorgegonzalez Jan 6, 2022
7bb9234
Update tdrs-backend/tdpservice/users/api/login_redirect_oidc.py
jorgegonzalez Jan 6, 2022
113a019
Update tdrs-backend/tdpservice/users/api/login.py
jorgegonzalez Jan 6, 2022
d1a7ac7
Update tdrs-backend/docs/remote-development.md
jorgegonzalez Jan 6, 2022
b70076c
style: lint
jorgegonzalez Jan 7, 2022
1ce9ae9
test
jorgegonzalez Jan 7, 2022
fbf915f
test 2
jorgegonzalez Jan 7, 2022
143794c
test 2
jorgegonzalez Jan 7, 2022
e51a518
test with ams state factory
jorgegonzalez Jan 7, 2022
0ea550e
Merge branch 'raft-tdp-main' into feat/1136-ams
jorgegonzalez Jan 7, 2022
c38f229
refactor: re-introduce ci success requirement
jorgegonzalez Jan 7, 2022
3fc5298
fix: logout uri params
jorgegonzalez Jan 10, 2022
64c5240
refactor: various nits and fixes
jorgegonzalez Jan 10, 2022
2e0476a
fix: change backend login_url redirect to frontend url
jorgegonzalez Jan 11, 2022
813b054
Merge branch 'raft-tdp-main' into feat/1136-ams
jorgegonzalez Jan 12, 2022
901d628
test: tweak customauthentication test
jorgegonzalez Jan 12, 2022
922a95e
test: missing state nonce tracker case
jorgegonzalez Jan 12, 2022
e985590
build: fix codecov patch config
jorgegonzalez Jan 12, 2022
24cf7c1
Merge branch 'raft-tdp-main' into feat/1136-ams
jorgegonzalez Jan 13, 2022
855ccea
Merge branch 'raft-tdp-main' into feat/1136-ams
ADPennington Jan 18, 2022
95e4db9
Update tdrs-backend/tdpservice/settings/common.py
jorgegonzalez Jan 18, 2022
52081d6
build: prevent faulty deploys from missing settings
jorgegonzalez Jan 18, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ coverage:
target: 90%
flags:
- backend
patch: off
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Patch diff status runs turned off as they are not useful compared to the main project build.


parsers:
gcov:
Expand Down
76 changes: 76 additions & 0 deletions docs/Technical-Documentation/remote-development.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Remote Development
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added remote-development documentation covering development on remotely hosted machines and containers.


There will be times when a developer needs access to a container or a remote machine to debug a running application, or to change source code without needing to trigger a formal deployment. This document specifically describes how to use the Cloud.gov environments where TDRS is deployed as development environments.

## Tools

### Visual Studio Code
This guide presumes the use of [VS Code](https://code.visualstudio.com/) with the [Remote Development](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack) extension pack. You can achieve a similar setup on other IDEs or in the terminal (as this all uses OpenSSH underneath); please save yourself the time and just go download VS Code.

### **`cf-cli`**
Additionally, install the latest version of the [Cloudfoundry CLI](https://docs.cloudfoundry.org/cf-cli/install-go-cli.html) if you haven't.

- **Important**: There are issues with `cf-cli` versions below `7.0` so I suggest grabbing the latest version.

To get the latest version as of this writing (on macOS):

```shell
brew install cloudfoundry/tap/cf-cli@7
```

## Access Cloudfoundry

Login to CloudFoundry with the CLI:

```shell
cf login -a api.fr.cloud.gov --sso
```

### Get App GUID

Use `curl` to get the process GUID of the application on deployed application you want to connect to; replace `<app-name>` with a string like `tdp-backend-raft`. You can see a list of currently running app names with `cf apps`.

```shell
cf curl /v3/apps/$(cf app <app-name> --guid)/processes | jq --raw-output '.resources | .[] | select(.type == "web").guid'
```

**This GUID will be used to construct the `User` name of the SSH connection.**

## Create an SSH Config

Create a file `~/username/.ssh/config` if one doesn't exist, and append the Host setting below:

```
# Read more about SSH config files: https://linux.die.net/man/5/ssh_config
Host <app-name>
HostName ssh.fr.cloud.gov
User cf:<guid>/0
Port 2222
```

Where `<guid>` is the string received in the last step. The User setting should look like this: `User cf:38f6a064-4ba7-4693-8732-960dea9f32f8/0`. Note the `/0` at the end of the string is the ID of the *instance*.

To connect with `ssh` from the terminal:

```shell
ssh -p 2222 cf:<guid>/0@ssh.fr.cloud.gov
```

## Get a One Time Password

In VS Code, open the command menu (ctrl/cmd+shift+p), type "Remote-SSH", and select "Connect Current Window to Host". This should automatically look at the previously created config, and now prompt you for a one time password.

```shell
cf ssh-code
```

## Navigate to Application Code

You should now be connected to the remote host, and need only navigate to the directory containing the application code you want to change (likely `/home/vcap/app/`).

Note that redeploying or restaging will wipe all changes made remotely.

## Useful Links

[VS Code Remote Overview](https://code.visualstudio.com/docs/remote/remote-overview)
[Jetbrains Remote development](https://www.jetbrains.com/help/idea/remote-development-starting-page.html)
7 changes: 7 additions & 0 deletions tdrs-backend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ JWT_CERT_TEST=a_public_cert
# Initial superuser username should be the developer's login.gov email address
DJANGO_SU_NAME=dev.email@example.com


### AMS OpenID vars ###

AMS_CONFIGURATION_ENDPOINT=
AMS_CLIENT_ID=
AMS_CLIENT_SECRET=
Comment on lines +23 to +25
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are required to be set with at least dummy values when running locally.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

per discussion with Jorge--clarified that these need to be set to the correct values locally.


###
# Optional environment variables
# These need not be defined, but can be overwritten as needed
Expand Down
1 change: 1 addition & 0 deletions tdrs-backend/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ psycopg2-binary = "==2.9.1"
pyjwt = "==2.1.0"
requests = "==2.26.0"
wait-for-it = "==2.2.0"
requests-mock = "==1.9.3"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added for simpler request mocking in tests.


[requires]
python_version = "3.8"
115 changes: 80 additions & 35 deletions tdrs-backend/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions tdrs-backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,8 @@ $ cf bind-service tdp-backend tdp-db
```bash
$ cf restage tdp-backend
```


### Useful Links

[Remote Development Guide](../docs/Technical-Documentation/remote-development.md)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Link to the document above

3 changes: 3 additions & 0 deletions tdrs-backend/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ services:
- JWT_KEY
- USE_LOCALSTACK
- LOGGING_LEVEL
- AMS_CLIENT_ID
- AMS_CLIENT_SECRET
- AMS_CONFIGURATION_ENDPOINT
Comment on lines +66 to +68
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pass on new env vars into Docker context

volumes:
- .:/tdpapp
image: tdp
Expand Down
6 changes: 4 additions & 2 deletions tdrs-backend/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@ docstring-convention=numpy
exclude =
.git,
__pycache__,
# We ideally want migrations to be readbale, but they often get quite nested
# We ideally want migrations to be readable, but they often get quite nested
# and often have long strings.
*/migrations/*,
# No need to check blank files
__init__.py,
# These settings files often have very long strings
*/settings/common.py/,
# D203 conflicts with D211, which is the more conventional of the two
extend-ignore = E226,E302,E41,D203
# Reducing line length so flake8 linter forces easier to read code
max-line-length = 88
max-line-length = 120
Comment on lines +34 to +39
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tweaked flake line-length per @abottoms-coder for convenience. and ignoring common.py to reduce noise

max-complexity = 10


Expand Down
Loading