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

Proof of Concept TDP Based Kibana Auth #2775

Merged
merged 152 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from 142 commits
Commits
Show all changes
152 commits
Select commit Hold shift + click to select a range
f8a4d54
Added formating for header and autofit columns
raftmsohani Oct 19, 2023
29fd04c
Formatted the headers
raftmsohani Oct 20, 2023
699245c
added year/month to the columns
raftmsohani Oct 20, 2023
5310946
Added contants - translation column
raftmsohani Oct 23, 2023
0269728
added friendly names to T1 and T2
raftmsohani Oct 25, 2023
ac120a6
added friendly name to m1 and m2
raftmsohani Oct 26, 2023
a7c1207
added friendly name to m3
raftmsohani Oct 26, 2023
d460fe2
added friendly_name to t3
raftmsohani Oct 27, 2023
2bb6622
added friendly_name to t4 and t5
raftmsohani Oct 27, 2023
c90ce75
added friendly_name to t7
raftmsohani Oct 27, 2023
9dfd6f8
correct missing friendly_name
raftmsohani Oct 27, 2023
90aea2f
correction on failing tests
raftmsohani Oct 27, 2023
8f210cd
addedfriendly name to excel report
raftmsohani Oct 30, 2023
a093aa0
linting
raftmsohani Oct 30, 2023
8ea36c6
linting
raftmsohani Oct 30, 2023
85da10b
linting
raftmsohani Oct 30, 2023
ac95c41
delete contants.py
raftmsohani Oct 30, 2023
d75ba04
added test for json field in error model
raftmsohani Oct 30, 2023
ea5aa30
linting
raftmsohani Oct 31, 2023
b4d0549
linting
raftmsohani Oct 31, 2023
8ce83ce
linting
raftmsohani Oct 31, 2023
c75bb7e
2599-added friendly name to postparsing validators
raftmsohani Nov 1, 2023
0ec8f16
refining the validator tests
raftmsohani Nov 7, 2023
359dae0
added returning fields names to validators
raftmsohani Nov 8, 2023
8ed0b4a
added friendly_name to error field
raftmsohani Nov 13, 2023
c57a2d5
Merge branch 'develop' into 2599-error-report-corrections-impact-wpr-…
raftmsohani Nov 14, 2023
812a2dd
linting
raftmsohani Nov 14, 2023
96634b2
corrections on views/tests
raftmsohani Nov 14, 2023
0be491f
corrections for fields
raftmsohani Nov 15, 2023
02ce7d0
failing test corrected
raftmsohani Nov 15, 2023
aa8a534
failing test corrected
raftmsohani Nov 15, 2023
19926ea
correcting test failures
raftmsohani Nov 15, 2023
6b7c86e
linting
raftmsohani Nov 16, 2023
94ef180
corrected the excel fiel generator
raftmsohani Nov 16, 2023
b6eee03
removed excessive space in validator
raftmsohani Nov 20, 2023
49dc398
linting
raftmsohani Nov 20, 2023
b0fd38a
Merge branch 'develop' into 2599-error-report-corrections-impact-wpr-…
raftmsohani Nov 20, 2023
700a965
listing
raftmsohani Nov 20, 2023
8aae444
Merge branch 'develop' into 2599-error-report-corrections-impact-wpr-…
raftmsohani Nov 21, 2023
9636854
added m6
raftmsohani Nov 21, 2023
5c2e819
lint
raftmsohani Nov 21, 2023
763c09b
corrected new line break
raftmsohani Nov 22, 2023
3e73dbc
refactored validator logic
raftmsohani Nov 22, 2023
e1c9c9a
Merge branch 'develop' into 2599-error-report-corrections-impact-wpr-…
raftmsohani Nov 25, 2023
dcc1dca
linting and correction on t1
raftmsohani Nov 25, 2023
741b442
Merge branch 'develop' into 2599-error-report-corrections-impact-wpr-…
raftmsohani Nov 25, 2023
28c9636
friendly_name correction from comments
raftmsohani Nov 25, 2023
091e716
Merge branch '2599-error-report-corrections-impact-wpr-metrics' of ht…
raftmsohani Nov 25, 2023
3e19f2d
friendly_name correction
raftmsohani Nov 25, 2023
c2501f8
corrected failing test for m5
raftmsohani Nov 25, 2023
b04df52
refactor the field_json creation DRY
raftmsohani Nov 27, 2023
206696a
- Added Kibana config
elipe17 Nov 29, 2023
ad17b56
friendly_name corrections
raftmsohani Nov 30, 2023
efc15bd
Merge branch 'develop' into 2599-error-report-corrections-impact-wpr-…
raftmsohani Nov 30, 2023
86e3024
Merge branch '2599-error-report-corrections-impact-wpr-metrics' of ht…
elipe17 Dec 4, 2023
25eb85e
Merge branch 'develop' of https://github.com/raft-tech/TANF-app into …
elipe17 Dec 4, 2023
d2d443d
linting and cleaning errors
raftmsohani Dec 4, 2023
573a056
linting
raftmsohani Dec 4, 2023
b1be7bb
correction on friendly_names
raftmsohani Dec 4, 2023
cad9173
corrected friendly_name for test_util
raftmsohani Dec 4, 2023
aa6a5ad
Merge branch 'develop' into 2599-error-report-corrections-impact-wpr-…
raftmsohani Dec 4, 2023
4bce93d
correction child care - number of months
raftmsohani Dec 4, 2023
d29ed8e
Merge branch '2599-error-report-corrections-impact-wpr-metrics' of ht…
raftmsohani Dec 4, 2023
bd29c09
fixed a few more typos and some spacing. (#2767)
George-Hudson Dec 5, 2023
657379d
- Added basic security to Kibana/Elastic
elipe17 Dec 5, 2023
eb59146
- Remove debug code
elipe17 Dec 5, 2023
ae41efd
- change provider name
elipe17 Dec 5, 2023
100d647
- Updating settings to reference environment variables
elipe17 Dec 5, 2023
beda306
Merge branch 'develop' into 2599-error-report-corrections-impact-wpr-…
raftmsohani Dec 6, 2023
13cd218
Merge branch 'develop' of https://github.com/raft-tech/TANF-app into …
elipe17 Dec 6, 2023
1536749
- Add elastic dependency
elipe17 Dec 6, 2023
bde9160
- Fix network issue
elipe17 Dec 6, 2023
0316025
- Added bulk creation of elastic indices
elipe17 Dec 6, 2023
acfb697
- Updated schemas to reference model based off of elastic document
elipe17 Dec 7, 2023
522ca38
- Remove password auth from elastic/kibana
elipe17 Dec 7, 2023
a62a345
- Remove password auth
elipe17 Dec 7, 2023
6dd34a0
- Fix tests
elipe17 Dec 7, 2023
1809129
- Fix lint
elipe17 Dec 7, 2023
640db6e
- remove debug print
elipe17 Dec 7, 2023
96e48d0
Merge branch '2599-error-report-corrections-impact-wpr-metrics' of ht…
elipe17 Dec 7, 2023
5f0fddf
Merge branch '1858-kibana-ofa-access' of https://github.com/raft-tech…
elipe17 Dec 7, 2023
556221b
Changes for fully local development
Nov 29, 2023
32a4671
Reorganized front end logic on REACT_APP_DEVAUTH env var
Dec 5, 2023
7fd7b4d
Reorganized backend logic on REACT_APP_DEVAUTH env var
Dec 5, 2023
15d4019
- Added proof on concept for tdp based kibana auth
elipe17 Dec 8, 2023
c806553
- Fixing type issue
elipe17 Dec 8, 2023
6ffbee8
added is_superuser and is_staff attrs to dev user
Dec 8, 2023
1e11ac8
- Add group check
elipe17 Dec 9, 2023
4057007
- Add frontend group check for kibana
elipe17 Dec 9, 2023
37f6975
- fix lint
elipe17 Dec 9, 2023
ccee755
- Fix lint errors
elipe17 Dec 9, 2023
00007c6
Merge branch 'elastic-bulk-doc-creation' of https://github.com/raft-t…
elipe17 Dec 9, 2023
2efe22c
- Fix doc strings
elipe17 Dec 9, 2023
34e6be6
- Adding authenticated permission
elipe17 Dec 12, 2023
86aae24
- Renaming variables to clarify things
elipe17 Dec 13, 2023
01bfd0b
- fix lint
elipe17 Dec 13, 2023
edde9d4
Revert "- Remove password auth from elastic/kibana"
elipe17 Dec 13, 2023
e066b50
- Setting up anonymous users with kibana_admin privileges
elipe17 Dec 13, 2023
3acf5e7
- Adding password to settings in cloud.gov
elipe17 Dec 13, 2023
478ea50
- remove incorrect auth
elipe17 Dec 13, 2023
5638153
- Add elastic profile
elipe17 Dec 13, 2023
1497d4a
DevAuth feature redesign inspired by Cypress
Dec 14, 2023
2febdcd
Merge branch 'elastic-bulk-doc-creation' of https://github.com/raft-t…
Dec 14, 2023
97a0cf6
Fixed CustomAuthentication.authenticate return val for login.py use case
Dec 14, 2023
2b9b46f
Fixed CustomAuthentication.authenticate logging for login.py use case
Dec 14, 2023
c18383f
Removed unneeded permissions import
Dec 14, 2023
7fc2a09
Updates to REACT_APP_DEVAUTH env var settings
Dec 14, 2023
900efa8
- debugging env vars
elipe17 Dec 14, 2023
784530e
- Testing what settings are used
elipe17 Dec 14, 2023
d9dbcfe
Revert "- debugging env vars"
elipe17 Dec 14, 2023
b3ec595
Revert "- Testing what settings are used"
elipe17 Dec 14, 2023
8cea014
- debugging env vars again
elipe17 Dec 14, 2023
61ac063
- Switching to container networking
elipe17 Dec 15, 2023
4bf8957
Restored support for CustomAuthentication.authenticate username keyword
Dec 15, 2023
761e4eb
Modified CustomAuthentication.authenticate comment to satisfy flake8
Dec 15, 2023
4693d17
Merge branch 'elastic-bulk-doc-creation' of https://github.com/raft-t…
elipe17 Dec 16, 2023
1aeb315
Merge branch 'develop' of https://github.com/raft-tech/TANF-app into …
elipe17 Dec 18, 2023
a284856
commit
elipe17 Dec 18, 2023
b8d7577
Merge branch 'elastic-bulk-doc-creation' of https://github.com/raft-t…
elipe17 Dec 18, 2023
30ee5ed
asdfgvasd
elipe17 Dec 18, 2023
1f9f32d
Revert "Modified CustomAuthentication.authenticate comment to satisfy…
elipe17 Dec 19, 2023
eacffe9
Revert "Restored support for CustomAuthentication.authenticate userna…
elipe17 Dec 19, 2023
71615d2
Revert "Updates to REACT_APP_DEVAUTH env var settings"
elipe17 Dec 19, 2023
bd6edd1
Revert "Removed unneeded permissions import"
elipe17 Dec 19, 2023
65b32ce
Revert "Fixed CustomAuthentication.authenticate logging for login.py …
elipe17 Dec 19, 2023
c49365f
Revert "Fixed CustomAuthentication.authenticate return val for login.…
elipe17 Dec 19, 2023
7bb7522
Revert "DevAuth feature redesign inspired by Cypress"
elipe17 Dec 19, 2023
af2d342
Revert "commit"
elipe17 Dec 19, 2023
d88a329
Revert "added is_superuser and is_staff attrs to dev user"
elipe17 Dec 19, 2023
247347c
Revert "Reorganized backend logic on REACT_APP_DEVAUTH env var"
elipe17 Dec 19, 2023
8205b43
Revert "Reorganized front end logic on REACT_APP_DEVAUTH env var"
elipe17 Dec 19, 2023
e32cb0d
Revert "Changes for fully local development"
elipe17 Dec 19, 2023
26455b4
asdf
elipe17 Dec 19, 2023
e9e0d78
Merge branch 'elastic-bulk-doc-creation' of https://github.com/raft-t…
elipe17 Dec 19, 2023
702c547
- Adding integration tests for elastic bulk doc creation
elipe17 Dec 20, 2023
6c97446
Revert "asdf"
elipe17 Dec 20, 2023
ffb1993
- fix lint
elipe17 Dec 20, 2023
8026eae
fasdf
elipe17 Dec 20, 2023
6ae551f
Merge branch 'develop' of https://github.com/raft-tech/TANF-app into …
elipe17 Jan 9, 2024
2ed9d25
Merge branch 'develop' of https://github.com/raft-tech/TANF-app into …
elipe17 Jan 9, 2024
f1b8a8b
- Added usage of document to tribal
elipe17 Jan 10, 2024
a658806
Merge branch 'elastic-bulk-doc-creation' of https://github.com/raft-t…
elipe17 Jan 10, 2024
8d24f72
Merge branch 'develop' into elastic-bulk-doc-creation
andrew-jameson Jan 12, 2024
f206b24
- Updated based on feedback
elipe17 Jan 17, 2024
715ced8
- Fixing error
elipe17 Jan 17, 2024
3fdb9db
Merge branch 'develop' of https://github.com/raft-tech/TANF-app into …
elipe17 Jan 17, 2024
a10383d
Merge branch 'elastic-bulk-doc-creation' of https://github.com/raft-t…
elipe17 Jan 17, 2024
3b02261
- Updating frontend to only allow access to kibana sitemap if the use…
elipe17 Jan 18, 2024
9a43a53
Merge branch 'develop' of https://github.com/raft-tech/TANF-app into …
elipe17 Jan 18, 2024
4c4f4e2
- fix lint
elipe17 Jan 18, 2024
a18db6e
Merge branch 'develop' into 1858-kibana-ofa-access
andrew-jameson Jan 22, 2024
6577cd2
Merge branch 'develop' into 1858-kibana-ofa-access
andrew-jameson Feb 12, 2024
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
6 changes: 3 additions & 3 deletions .circleci/build-and-test/jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
steps:
- checkout
- docker-compose-check
- docker-compose-up-backend
- docker-compose-up-with-elastic-backend
- run:
name: Run Unit Tests And Create Code Coverage Report
command: |
Expand Down Expand Up @@ -47,7 +47,7 @@
steps:
- checkout
- docker-compose-check
- docker-compose-up-backend
- docker-compose-up-with-elastic-backend
- docker-compose-up-frontend
- install-nodejs-machine
- disable-npm-audit
Expand All @@ -61,7 +61,7 @@
wait-for-it --service http://web:8080 --timeout 180 -- echo \"Django is ready\""
- run:
name: apply the migrations
command: cd tdrs-backend; docker-compose exec web bash -c "python manage.py makemigrations; python manage.py migrate"
command: cd tdrs-backend; docker-compose exec web bash -c "python manage.py makemigrations; python manage.py migrate"
- run:
name: Remove existing cypress test users
command: cd tdrs-backend; docker-compose exec web python manage.py delete_cypress_users -usernames [email protected] [email protected]
Expand Down
6 changes: 6 additions & 0 deletions .circleci/util/commands.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
name: Build and spin-up Django API service
command: cd tdrs-backend; docker network create external-net; docker-compose up -d --build

docker-compose-up-with-elastic-backend:
steps:
- run:
name: Build and spin-up Django API service
command: cd tdrs-backend; docker network create external-net; docker-compose --profile elastic_setup up -d --build

cf-check:
steps:
- run:
Expand Down
46 changes: 45 additions & 1 deletion tdrs-backend/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,55 @@ services:
# Copy in the Localstack setup script to configure any buckets needed
- ../scripts/localstack-setup.sh:/docker-entrypoint-initaws.d/localstack-setup.sh

kibana:
image: elastic/kibana:7.17.10
ports:
- 5601:5601
environment:
- xpack.security.encryptionKey=${KIBANA_ENCRYPTION_KEY:-something_at_least_32_characters}
- xpack.security.session.idleTimeout="1h"
- xpack.security.session.lifespan="30d"
volumes:
- ./kibana.yml:/usr/share/kibana/config/kibana.yml
depends_on:
- elastic

# This task only needs to be performed once, during the *initial* startup of
# the stack. Any subsequent run will reset the passwords of existing users to
# the values defined inside the '.env' file, and the built-in roles to their
# default permissions.
#
# By default, it is excluded from the services started by 'docker compose up'
# due to the non-default profile it belongs to. To run it, either provide the
# '--profile=elastic_setup' CLI flag to Compose commands, or "up" the service by name
# such as 'docker compose up elastic_setup'.
elastic_setup:
profiles:
- elastic_setup
build:
context: elastic_setup/
args:
ELASTIC_VERSION: "7.17.6"
init: true
environment:
ELASTIC_PASSWORD: ${ELASTIC_PASSWORD:-changeme}
KIBANA_SYSTEM_PASSWORD: ${KIBANA_SYSTEM_PASSWORD:-changeme}
OFA_ADMIN_PASSWORD: ${OFA_ADMIN_PASSWORD:-changeme}
ELASTICSEARCH_HOST: ${ELASTICSEARCH_HOST:-elastic}
depends_on:
- elastic

elastic:
image: elasticsearch:7.17.6
environment:
- discovery.type=single-node
- xpack.security.enabled=false
- logger.discovery.level=debug
- xpack.security.enabled=true
- xpack.security.authc.anonymous.username="ofa_admin"
- xpack.security.authc.anonymous.roles="ofa_admin"
- xpack.security.authc.anonymous.authz_exception=true
- ELASTIC_PASSWORD=${ELASTIC_PASSWORD:-changeme}
- KIBANA_SYSTEM_PASSWORD=${KIBANA_SYSTEM_PASSWORD:-changeme}
ports:
- 9200:9200
- 9300:9300
Expand Down Expand Up @@ -88,6 +131,7 @@ services:
- CYPRESS_TOKEN
- DJANGO_DEBUG
- SENDGRID_API_KEY
- BYPASS_KIBANA_AUTH
volumes:
- .:/tdpapp
image: tdp
Expand Down
10 changes: 10 additions & 0 deletions tdrs-backend/elastic_setup/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
ARG ELASTIC_VERSION

FROM docker.elastic.co/elasticsearch/elasticsearch:${ELASTIC_VERSION}

COPY . /

RUN ["chmod", "+x", "/entrypoint.sh"]
RUN ["chmod", "+x", "/util.sh"]

ENTRYPOINT ["/entrypoint.sh"]
110 changes: 110 additions & 0 deletions tdrs-backend/elastic_setup/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#!/usr/bin/env bash

set -eu
set -o pipefail

source "${BASH_SOURCE[0]%/*}"/util.sh


# --------------------------------------------------------
# Users declarations

declare -A users_passwords
users_passwords=(
[kibana_system]="${KIBANA_SYSTEM_PASSWORD:-}"
[ofa_admin]="${OFA_ADMIN_PASSWORD:-}"
)

declare -A users_roles
users_roles=(
[kibana_system]='kibana_system'
[ofa_admin]='kibana_admin'
)

# --------------------------------------------------------
# Roles declarations for custom roles

declare -A roles_files
roles_files=(

)

# --------------------------------------------------------


log 'Waiting for availability of Elasticsearch. This can take several minutes.'

declare -i exit_code=0
wait_for_elasticsearch || exit_code=$?

if ((exit_code)); then
case $exit_code in
6)
suberr 'Could not resolve host. Is Elasticsearch running?'
;;
7)
suberr 'Failed to connect to host. Is Elasticsearch healthy?'
;;
28)
suberr 'Timeout connecting to host. Is Elasticsearch healthy?'
;;
*)
suberr "Connection to Elasticsearch failed. Exit code: ${exit_code}"
;;
esac

exit $exit_code
fi

sublog 'Elasticsearch is running'

log 'Waiting for initialization of built-in users'

wait_for_builtin_users || exit_code=$?

if ((exit_code)); then
suberr 'Timed out waiting for condition'
exit $exit_code
fi

sublog 'Built-in users were initialized'

for role in "${!roles_files[@]}"; do
log "Role '$role'"

declare body_file
body_file="${BASH_SOURCE[0]%/*}/roles/${roles_files[$role]:-}"
if [[ ! -f "${body_file:-}" ]]; then
sublog "No role body found at '${body_file}', skipping"
continue
fi

sublog 'Creating/updating'
ensure_role "$role" "$(<"${body_file}")"
done

for user in "${!users_passwords[@]}"; do
log "User '$user'"
if [[ -z "${users_passwords[$user]:-}" ]]; then
sublog 'No password defined, skipping'
continue
fi

declare -i user_exists=0
user_exists="$(check_user_exists "$user")"

if ((user_exists)); then
sublog 'User exists, setting password'
set_user_password "$user" "${users_passwords[$user]}"
else
if [[ -z "${users_roles[$user]:-}" ]]; then
suberr ' No role defined, skipping creation'
continue
fi

sublog 'User does not exist, creating'
create_user "$user" "${users_passwords[$user]}" "${users_roles[$user]}"
fi
done

log "Elastic setup completed. Exiting with code: $?"
Loading
Loading