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

User Authentication Implementation #8

Open
wants to merge 56 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
bab2bad
First commit
jonathanpmoraes Nov 12, 2024
91f6bdf
Apllying important changes
jonathanpmoraes Nov 12, 2024
0f845e3
changing local variables
jonathanpmoraes Nov 13, 2024
7d765e1
Removing unnecessary code
jonathanpmoraes Nov 13, 2024
60f9b8a
Removing unnecessary code
jonathanpmoraes Nov 13, 2024
06a0920
Including environment variable
jonathanpmoraes Nov 13, 2024
6bff3f9
Adjusting parameters
jonathanpmoraes Nov 13, 2024
95434e2
Changing Dockerfile back to how it was
jonathanpmoraes Nov 14, 2024
337931b
Adding healthcheck for cicd to proxy
jonathanpmoraes Nov 14, 2024
fc05bf6
Commenting line
jonathanpmoraes Nov 14, 2024
1a24410
Adjusting name of services in kubernetes
jonathanpmoraes Nov 14, 2024
d4d7eb1
Adjusting name of services in kubernetes
jonathanpmoraes Nov 14, 2024
16974c9
Adjusting nginx.conf file
jonathanpmoraes Nov 14, 2024
936d703
Adjusting nginx.conf file
jonathanpmoraes Nov 14, 2024
4faa48f
Adjusting nginx.conf file
jonathanpmoraes Nov 14, 2024
8bda41d
Adjusting nginx.conf file
jonathanpmoraes Nov 14, 2024
bf25cd4
Making some new adjustments
jonathanpmoraes Nov 14, 2024
b5c40fb
Removing marquez-auth-server service
jonathanpmoraes Nov 14, 2024
7ec1146
Fixing typo in marquez host endpoint
jonathanpmoraes Nov 14, 2024
c962532
Removing auth-server from config file
jonathanpmoraes Nov 15, 2024
e2a969b
Making some adjustments
jonathanpmoraes Nov 18, 2024
d80665c
Adjusting name of marquez web ui
jonathanpmoraes Nov 18, 2024
bcc69ce
Including args to oauth2 dockerfile
jonathanpmoraes Nov 18, 2024
cb0e287
Implementing a few changes
jonathanpmoraes Nov 18, 2024
ffbd223
Adjusting server name
jonathanpmoraes Nov 18, 2024
47f83eb
Changing protocol url
jonathanpmoraes Nov 18, 2024
4421103
Adding new callback endpoint
jonathanpmoraes Nov 18, 2024
62d4f16
Adjusting parameters
jonathanpmoraes Nov 18, 2024
ce3f639
Adjusting certificate parameters
jonathanpmoraes Nov 18, 2024
2c0f455
Implementing a comment to push new workload
jonathanpmoraes Nov 18, 2024
3cb65ec
Updating configs in nginx.conf
jonathanpmoraes Nov 19, 2024
77022db
Removing ssl certificates from global http routes
jonathanpmoraes Nov 19, 2024
739eddf
Implementing more options for dns name
jonathanpmoraes Nov 19, 2024
cbf2e87
changing dns for certificate
jonathanpmoraes Nov 19, 2024
67e3027
Removing 443 handling for tests
jonathanpmoraes Nov 19, 2024
5608e15
Implementing minor changes to remove 443 and ssl
jonathanpmoraes Nov 19, 2024
9f86cba
Minor change to dockerfile
jonathanpmoraes Nov 19, 2024
b52e024
Fixing proxy_pass endpoint
jonathanpmoraes Nov 19, 2024
df6e888
Implementing more changes to Oauth2
jonathanpmoraes Nov 19, 2024
126762a
Applying changes to nginx.conf file
jonathanpmoraes Nov 21, 2024
cac066a
Adding header parameters to sign_in request
jonathanpmoraes Nov 21, 2024
41e3aea
Adjusting oauth2 address within nginx
jonathanpmoraes Nov 21, 2024
39788ca
Correcting pod's addresses
jonathanpmoraes Nov 21, 2024
8b3d703
Correcting paths to services
jonathanpmoraes Nov 21, 2024
fbfe628
Adjusting endpoint for env variable
jonathanpmoraes Nov 21, 2024
378ab70
Adding ssl and enabling ports 443
jonathanpmoraes Nov 22, 2024
0676bfe
Adding some more important configs
jonathanpmoraes Nov 22, 2024
361abda
Adding some more configs
jonathanpmoraes Nov 22, 2024
7324648
Referencing secret kept in data-lineage env
jonathanpmoraes Nov 22, 2024
1c4500a
Fixing cert path
jonathanpmoraes Nov 22, 2024
635f401
Fixing cert path again
jonathanpmoraes Nov 23, 2024
4bd2a92
Fixing some route mapping
jonathanpmoraes Nov 23, 2024
ceac6ef
Changing minor configs
jonathanpmoraes Nov 24, 2024
e664a65
Adding ajustments regarding nginx.conf and dockerfile
jonathanpmoraes Nov 25, 2024
c17fdee
updating dockerfile
jonathanpmoraes Nov 25, 2024
ddfb206
updating dockerfile again
jonathanpmoraes Nov 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
31 changes: 31 additions & 0 deletions web-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Use the official Node.js 14 image as the base image
FROM node:18

RUN apt update && apt install -y authbind \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /var/cache/apk/*
# Set the working directory
WORKDIR /usr/src/app

# Copy package.json and package-lock.json (if available)
COPY package*.json ./

# Install dependencies
RUN npm install
# Copy the rest of the application code
COPY . .

# Build the TypeScript code
RUN npm run build \
&& touch /etc/authbind/byport/443 \
&& chown root /etc/authbind/byport/443 \
&& chmod 777 /etc/authbind/byport/443 \
&& touch /etc/authbind/byport/80 \
&& chown root /etc/authbind/byport/80 \
&& chmod 777 /etc/authbind/byport/80

# Expose the port the app runs on
EXPOSE 1337

# Define the command to run the app
CMD ["authbind", "npm", "start"]
76 changes: 76 additions & 0 deletions web-server/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
services:
# marquez-web
web:
build:
context: ../web
dockerfile: Dockerfile
container_name: marquez-web
environment:
- MARQUEZ_HOST=marquez-api
- MARQUEZ_PORT=5000
- WEB_PORT=3000
expose:
- "3000"
stdin_open: true
tty: true
depends_on:
- api
networks:
- app-network

# marquez-web-server
marquez-web-server:
build:
dockerfile: ./Dockerfile
container_name: marquez-web-server
ports:
- "1337:1337"
environment:
- SESSION_SECRET=your_secret_key
depends_on:
- web
networks:
- app-network

# OAuth2 proxy
oauth2-proxy:
build:
context: ./oauth2-proxy
dockerfile: Dockerfile
container_name: oauth2-proxy
# volumes:
# - ./docker/oauth2-proxy/oauth2_proxy.cfg:/etc/oauth2_proxy.cfg
ports:
- "4180:4180"
env_file:
- .env
depends_on:
- web
- marquez-web-server
networks:
- app-network

nginx-proxy:
build:
context: ./nginx
dockerfile: Dockerfile
container_name: nginx-proxy
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- ./nginx/certs/certs:/etc/nginx/certs:ro
- ./nginx/logs:/var/log/nginx
# environment:
# - BASIC_AUTH_USER=testuser
# - BASIC_AUTH_PASSWORD=password
depends_on:
- oauth2-proxy
- web
networks:
- app-network

networks:
app-network:
driver: bridge
25 changes: 25 additions & 0 deletions web-server/nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Use the official NGINX base image
FROM nginx:1.27.2-alpine

# Remove the default NGINX configuration
RUN rm -f /etc/nginx/conf.d/default.conf

# Update and install required packages, including aws-cli and PyYAML
RUN apk update && \
apk add --no-cache python3 py3-pip py3-yaml aws-cli openssl bash

# Copy your custom NGINX configuration
COPY nginx.conf /etc/nginx/nginx.conf

# Copy and set permissions for init.sh
COPY init.sh /init.sh
RUN chmod +x /init.sh

# Expose ports (optional)
EXPOSE 80 443

# Set the entrypoint
ENTRYPOINT ["/init.sh"]

# Start NGINX
CMD ["nginx", "-g", "daemon off;"]
8 changes: 8 additions & 0 deletions web-server/nginx/domain.ext
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, keyEncipherment
extendedKeyUsage=serverAuth
subjectAltName = @alt_names

[alt_names]
DNS.1 = *.nubank.world
18 changes: 18 additions & 0 deletions web-server/nginx/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

set -eu

mkdir -p /etc/nginx/certs
aws s3 cp --region us-west-2 s3://nu-keysets-data-staging/certificates/pri/global/keystore.p12-2022-2023 /etc/nginx/certs
cd /etc/nginx/certs
openssl pkcs12 -in keystore.p12 -passin pass:nubankp12 -nocerts -nodes | sed -n '/BEGIN/,$p' > nubank_key.pem
openssl pkcs12 -in keystore.p12 -passin pass:nubankp12 -nokeys > nubank_cert.pem

rm /etc/nginx/certs/keystore.p12
chmod 400 /etc/nginx/certs/nubank_key.pem

envsubst '${DOMAIN} ${ES_INDEX} ${REDIRECTS}' < /templates/nginx.conf.template > /etc/nginx/nginx.conf

echo "Starting nginx"

exec "$@"
133 changes: 133 additions & 0 deletions web-server/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
events {
worker_connections 4096;
}

http {
server_tokens off;

# Include mime types
include mime.types;
default_type application/octet-stream;

# Logging Settings
access_log /dev/stdout;
error_log /dev/stderr;

# Keepalive Timeout
keepalive_timeout 65;

# Redirect HTTP to HTTPS
server {
listen 80;
server_name staging-marquez-web.nubank.world;
return 301 https://$host$request_uri;
}

# HTTPS Server Block
server {
listen 443 ssl;
server_name staging-marquez-web.nubank.world;

ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_ciphers ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:...
ssl_ecdh_curve secp521r1:secp384r1:prime256v1;
ssl_session_timeout 10m;
ssl_session_tickets off;
ssl_stapling on;

# SSL Certificate Settings
ssl_certificate /etc/nginx/certs/nubank_cert.pem;
ssl_certificate_key /etc/nginx/certs/nubank_key.pem;

# Security Headers
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload";
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header Cache-Control "no-cache";

# Health Check Endpoint
location /healthcheck {
access_log off;
return 200 'OK';
add_header Content-Type text/plain;
}

# OAuth2 Proxy Configuration
location /oauth2/ {
proxy_pass http://marquez-web-oauth2-proxy.data-lineage.svc.cluster.local:4180;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}

# Authentication Start Endpoint
location /oauth2/start {
proxy_pass http://marquez-web-oauth2-proxy.data-lineage.svc.cluster.local:4180/start;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Auth-Request-Redirect $request_uri;
}

# OAuth2 Authentication Request
location /oauth2/auth {
internal;
proxy_pass http://marquez-web-oauth2-proxy.data-lineage.svc.cluster.local:4180/auth;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Content-Length "";
proxy_pass_request_body off;
}

# Sign-Out Endpoint
location /logout {
proxy_pass http://marquez-web-oauth2-proxy.data-lineage.svc.cluster.local:4180/sign_out?rd=https://staging-marquez-web.nubank.world;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Auth-Request-Redirect $request_uri;
}

# Protect Frontend Routes
location / {
auth_request /oauth2/auth;
error_page 401 = /oauth2/start;
proxy_pass http://marquez-web-ui:443;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;

# Pass user information to the backend
auth_request_set $user $upstream_http_x_auth_request_user;
proxy_set_header X-User $user;
}

# Protected API Endpoint
location /proxy/ {
# Authentication
auth_request /oauth2/auth;
error_page 401 = /oauth2/start;

# Proxy to your service
proxy_pass http://marquez-web-auth-server:1337;

# Proxy settings
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

# Pass user information to the backend
auth_request_set $user $upstream_http_x_auth_request_user;
proxy_set_header X-Auth-Request-User $user;
}
}
}
1 change: 1 addition & 0 deletions web-server/node_modules/.bin/mime

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

1 change: 1 addition & 0 deletions web-server/node_modules/.bin/mkdirp

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

1 change: 1 addition & 0 deletions web-server/node_modules/.bin/resolve

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

1 change: 1 addition & 0 deletions web-server/node_modules/.bin/rimraf

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

1 change: 1 addition & 0 deletions web-server/node_modules/.bin/tree-kill

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

1 change: 1 addition & 0 deletions web-server/node_modules/.bin/ts-node

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

1 change: 1 addition & 0 deletions web-server/node_modules/.bin/ts-node-dev

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

1 change: 1 addition & 0 deletions web-server/node_modules/.bin/ts-node-script

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

1 change: 1 addition & 0 deletions web-server/node_modules/.bin/ts-node-transpile-only

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

1 change: 1 addition & 0 deletions web-server/node_modules/.bin/ts-script

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

1 change: 1 addition & 0 deletions web-server/node_modules/.bin/tsc

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

1 change: 1 addition & 0 deletions web-server/node_modules/.bin/tsnd

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

1 change: 1 addition & 0 deletions web-server/node_modules/.bin/tsserver

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

Loading