Skip to content

Commit

Permalink
Integration with new portalbackend authentication adapter.
Browse files Browse the repository at this point in the history
  • Loading branch information
ThanKarab committed Jul 28, 2023
1 parent 9406da4 commit 945014d
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 13 deletions.
33 changes: 24 additions & 9 deletions config/caddy/Caddyfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,38 @@
import rp-{$MIP_LINK:direct} {$KEYCLOAK_HOST}
}

handle /services/sso/* {
### Portal-Backend Keycloak Authentication ---------------> ###

# Redirect the login to the new portal-backend oauth2 login url
redir /services/sso/login /{$PORTAL_BACKEND_CONTEXT:services}/{$PORTALBACKEND_AUTH_URL:/oauth2/authorization/keycloak}

# Keycloak redirects on /services/ after login. In that case, redirect to /
redir /services/ / permanent

handle /services/oauth2/* {
uri replace /services/ /{$PORTAL_BACKEND_CONTEXT:services}/
import rp-{$MIP_LINK:direct} {$PORTAL_BACKEND_SERVER}
}

handle_path /services/* {
import rp-{$MIP_LINK:direct} {$GATEWAY_SERVER}
handle /services/login/oauth2/* {
uri replace /services/ /{$PORTAL_BACKEND_CONTEXT:services}/
import rp-{$MIP_LINK:direct} {$PORTAL_BACKEND_SERVER}
}

# keycloak redirect on /services/ after login. In that case, redirect to /
redir /services/ / permanent
handle /services/logout {
uri replace /services/ /{$PORTAL_BACKEND_CONTEXT:services}/
import rp-{$MIP_LINK:direct} {$PORTAL_BACKEND_SERVER}
}

# hotfix for whitelabel error after login
redir /services/error / temporary
### <--------------- Portal-Backend Keycloak Authentication ###


handle_path /services/* {
import rp-{$MIP_LINK:direct} {$GATEWAY_SERVER}
}

handle_errors {
@4xx expression `{http.error.status_code} == 401 || {http.error.status_code} == 404`
@4xx expression `{http.error.status_code} == 404`
redir * / temporary
}
}
}
2 changes: 1 addition & 1 deletion federation_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def cli():

LOG_FILE_CHUNK_SIZE = 1024 # Will read the logfile in chunks
TIMESTAMP_REGEX = (
r"\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.\d{3}" # 2022-04-13 18:25:22.875
r"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z" # 2022-04-13T18:25:22.875Z
)
EXPERIMENT_FINISHED_PATTERN = rf"({TIMESTAMP_REGEX}) INFO .*? User -> (.*?) ,Endpoint.*?Finished the experiment: .*?uuid=(.*?), name.*?, status=(.*?), result.*?, finished=(.*?), algorithm=(.*?), algorithmId.*? created=(.*?), updated.*?"
EXPERIMENT_TIMESTAMP_FORMAT = "%Y-%m-%d %H:%M:%S.%f"
Expand Down
5 changes: 3 additions & 2 deletions tests/backend_components/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ services:
restart: unless-stopped

portalbackend_db:
image: postgres:11.3-alpine
image: postgres:11.20-alpine
volumes:
- ./.stored_data/portalbackenddb:/var/lib/postgresql/data
hostname: portalbackend_db
Expand Down Expand Up @@ -228,7 +228,8 @@ services:
### Exareme ###
EXAREME_URL: http://exareme_master:9090
### Keycloak ###
AUTHENTICATION: 0 # Should be enabled for keycloak
AUTHENTICATION: 0
# AUTHENTICATION: 1 # Should be enabled for keycloak
KEYCLOAK_AUTH_URL: http://172.17.0.1/auth/
KEYCLOAK_REALM: MIP
KEYCLOAK_CLIENT_ID: MIP
Expand Down
4 changes: 3 additions & 1 deletion tests/frontend_components/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ services:
- ENGINE_TYPE=exareme
- ENGINE_BASE_URL=http://172.17.0.1:8080/services/
- AUTH_SKIP=true
- AUTH_ENABLE_SSO=false
# - AUTH_ENABLE_SSO=true # Should be enabled for Keycloak
- BASE_URL_CONTEXT=services
- GATEWAY_PORT=8081
- CACHE_ENABLED=false
- NODE_ENV=development
links:
- gateway-db
depends_on:
Expand Down Expand Up @@ -52,10 +54,10 @@ services:
EXTERNAL_MIP_PROTOCOL: http
KEYCLOAK_HOST: http://keycloak:8095
KEYCLOAK_AUTH_PATH: /auth
PORTALBACKEND_AUTH_URL: /oauth2/authorization/keycloak
MIP_LINK: direct
restart: unless-stopped


# keycloak_db:
# image: postgres:12.2
# volumes:
Expand Down

0 comments on commit 945014d

Please sign in to comment.