Skip to content

Commit

Permalink
Add authorization via HTTP header using static list of roles
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-c committed Nov 25, 2024
1 parent 665d304 commit f8ff8f0
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 42 deletions.
12 changes: 6 additions & 6 deletions dev/alive/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
}
},
"Authorization": {
"Mechanism": "UNSECURED",
"Mechanism": "SAML2",
"AllowAllAuthenticatedUsers": true,
"UnsecuredIsAdmin": false,
"SAML2": {
Expand All @@ -49,11 +49,11 @@
}
},
"RolesMapping": {
"User": "urn:mace:users",
"Super": "urn:mace:supers",
"Identified": "urn:mace:phi",
"Admin": "urn:mace:sudos",
"Federated": "urn:mace:federated"
"User": "leaf_users",
"Super": "leaf_supers",
"Identified": "leaf_phi",
"Admin": "leaf_admin",
"Federated": "leaf_federated"
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion dev/alive/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ services:
labels:
# https://leafdocs.rit.uw.edu/installation/installation_steps/9_saml2/#route-protection-setup
- traefik.http.routers.alive-coreapi-auth-${COMPOSE_PROJECT_NAME}.rule=Host(`alive.${LEAF_DOMAIN}`) && Path(`/api/user`)
- traefik.http.routers.alive-coreapi-auth-${COMPOSE_PROJECT_NAME}.middlewares=oidc-auth-${COMPOSE_PROJECT_NAME}
- traefik.http.routers.alive-coreapi-auth-${COMPOSE_PROJECT_NAME}.middlewares=oidc-auth-${COMPOSE_PROJECT_NAME},leaf-groups-${COMPOSE_PROJECT_NAME}
- traefik.http.routers.alive-coreapi-auth-${COMPOSE_PROJECT_NAME}.entrypoints=websecure
- traefik.http.routers.alive-coreapi-auth-${COMPOSE_PROJECT_NAME}.tls.certresolver=letsencrypt

Expand Down
12 changes: 6 additions & 6 deletions dev/gateway/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
}
},
"Authorization": {
"Mechanism": "UNSECURED",
"Mechanism": "SAML2",
"AllowAllAuthenticatedUsers": true,
"UnsecuredIsAdmin": false,
"SAML2": {
Expand All @@ -49,11 +49,11 @@
}
},
"RolesMapping": {
"User": "urn:mace:users",
"Super": "urn:mace:supers",
"Identified": "urn:mace:phi",
"Admin": "urn:mace:sudos",
"Federated": "urn:mace:federated"
"User": "leaf_users",
"Super": "leaf_supers",
"Identified": "leaf_phi",
"Admin": "leaf_admin",
"Federated": "leaf_federated"
}
}
},
Expand Down
6 changes: 5 additions & 1 deletion dev/gateway/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ services:
- traefik.http.middlewares.oidc-auth-${COMPOSE_PROJECT_NAME}.forwardAuth.trustForwardHeader=true
- traefik.http.middlewares.oidc-auth-${COMPOSE_PROJECT_NAME}.forwardAuth.authResponseHeaders=X-Auth-Request-User,X-Auth-Request-Email,X-Auth-Request-Access-Token,Authorization

# TODO dynamically look up from OIDC tokens
# add Leaf group to all users via HTTP request header; see appsettings.json for available roles
- traefik.http.middlewares.leaf-groups-${COMPOSE_PROJECT_NAME}.headers.customrequestheaders.gws-groups=leaf_users;leaf_phi;leaf_admin

networks:
ingress:
aliases:
Expand Down Expand Up @@ -74,7 +78,7 @@ services:
labels:
# https://leafdocs.rit.uw.edu/installation/installation_steps/9_saml2/#route-protection-setup
- traefik.http.routers.gateway-coreapi-auth-${COMPOSE_PROJECT_NAME}.rule=Host(`${LEAF_DOMAIN}`) && Path(`/api/user`)
- traefik.http.routers.gateway-coreapi-auth-${COMPOSE_PROJECT_NAME}.middlewares=oidc-auth-${COMPOSE_PROJECT_NAME}
- traefik.http.routers.gateway-coreapi-auth-${COMPOSE_PROJECT_NAME}.middlewares=oidc-auth-${COMPOSE_PROJECT_NAME},leaf-groups-${COMPOSE_PROJECT_NAME}
- traefik.http.routers.gateway-coreapi-auth-${COMPOSE_PROJECT_NAME}.entrypoints=websecure
- traefik.http.routers.gateway-coreapi-auth-${COMPOSE_PROJECT_NAME}.tls.certresolver=letsencrypt

Expand Down
12 changes: 6 additions & 6 deletions dev/hymtruth/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
}
},
"Authorization": {
"Mechanism": "UNSECURED",
"Mechanism": "SAML2",
"AllowAllAuthenticatedUsers": true,
"UnsecuredIsAdmin": false,
"SAML2": {
Expand All @@ -49,11 +49,11 @@
}
},
"RolesMapping": {
"User": "urn:mace:users",
"Super": "urn:mace:supers",
"Identified": "urn:mace:phi",
"Admin": "urn:mace:sudos",
"Federated": "urn:mace:federated"
"User": "leaf_users",
"Super": "leaf_supers",
"Identified": "leaf_phi",
"Admin": "leaf_admin",
"Federated": "leaf_federated"
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion dev/hymtruth/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ services:
labels:
# https://leafdocs.rit.uw.edu/installation/installation_steps/9_saml2/#route-protection-setup
- traefik.http.routers.hymtruth-coreapi-auth-${COMPOSE_PROJECT_NAME}.rule=Host(`hymtruth.${LEAF_DOMAIN}`) && Path(`/api/user`)
- traefik.http.routers.hymtruth-coreapi-auth-${COMPOSE_PROJECT_NAME}.middlewares=oidc-auth-${COMPOSE_PROJECT_NAME}
- traefik.http.routers.hymtruth-coreapi-auth-${COMPOSE_PROJECT_NAME}.middlewares=oidc-auth-${COMPOSE_PROJECT_NAME},leaf-groups-${COMPOSE_PROJECT_NAME}
- traefik.http.routers.hymtruth-coreapi-auth-${COMPOSE_PROJECT_NAME}.entrypoints=websecure
- traefik.http.routers.hymtruth-coreapi-auth-${COMPOSE_PROJECT_NAME}.tls.certresolver=letsencrypt

Expand Down
12 changes: 6 additions & 6 deletions dev/mash/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
}
},
"Authorization": {
"Mechanism": "UNSECURED",
"Mechanism": "SAML2",
"AllowAllAuthenticatedUsers": true,
"UnsecuredIsAdmin": false,
"SAML2": {
Expand All @@ -49,11 +49,11 @@
}
},
"RolesMapping": {
"User": "urn:mace:users",
"Super": "urn:mace:supers",
"Identified": "urn:mace:phi",
"Admin": "urn:mace:sudos",
"Federated": "urn:mace:federated"
"User": "leaf_users",
"Super": "leaf_supers",
"Identified": "leaf_phi",
"Admin": "leaf_admin",
"Federated": "leaf_federated"
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion dev/mash/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ services:
labels:
# https://leafdocs.rit.uw.edu/installation/installation_steps/9_saml2/#route-protection-setup
- traefik.http.routers.mash-coreapi-auth-${COMPOSE_PROJECT_NAME}.rule=Host(`mash.${LEAF_DOMAIN}`) && Path(`/api/user`)
- traefik.http.routers.mash-coreapi-auth-${COMPOSE_PROJECT_NAME}.middlewares=oidc-auth-${COMPOSE_PROJECT_NAME}
- traefik.http.routers.mash-coreapi-auth-${COMPOSE_PROJECT_NAME}.middlewares=oidc-auth-${COMPOSE_PROJECT_NAME},leaf-groups-${COMPOSE_PROJECT_NAME}
- traefik.http.routers.mash-coreapi-auth-${COMPOSE_PROJECT_NAME}.entrypoints=websecure
- traefik.http.routers.mash-coreapi-auth-${COMPOSE_PROJECT_NAME}.tls.certresolver=letsencrypt

Expand Down
12 changes: 6 additions & 6 deletions dev/mstudy/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
}
},
"Authorization": {
"Mechanism": "UNSECURED",
"Mechanism": "SAML2",
"AllowAllAuthenticatedUsers": true,
"UnsecuredIsAdmin": false,
"SAML2": {
Expand All @@ -49,11 +49,11 @@
}
},
"RolesMapping": {
"User": "urn:mace:users",
"Super": "urn:mace:supers",
"Identified": "urn:mace:phi",
"Admin": "urn:mace:sudos",
"Federated": "urn:mace:federated"
"User": "leaf_users",
"Super": "leaf_supers",
"Identified": "leaf_phi",
"Admin": "leaf_admin",
"Federated": "leaf_federated"
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion dev/mstudy/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ services:
labels:
# https://leafdocs.rit.uw.edu/installation/installation_steps/9_saml2/#route-protection-setup
- traefik.http.routers.mstudy-coreapi-auth-${COMPOSE_PROJECT_NAME}.rule=Host(`mstudy.${LEAF_DOMAIN}`) && Path(`/api/user`)
- traefik.http.routers.mstudy-coreapi-auth-${COMPOSE_PROJECT_NAME}.middlewares=oidc-auth-${COMPOSE_PROJECT_NAME}
- traefik.http.routers.mstudy-coreapi-auth-${COMPOSE_PROJECT_NAME}.middlewares=oidc-auth-${COMPOSE_PROJECT_NAME},leaf-groups-${COMPOSE_PROJECT_NAME}
- traefik.http.routers.mstudy-coreapi-auth-${COMPOSE_PROJECT_NAME}.entrypoints=websecure
- traefik.http.routers.mstudy-coreapi-auth-${COMPOSE_PROJECT_NAME}.tls.certresolver=letsencrypt

Expand Down
12 changes: 6 additions & 6 deletions dev/radar/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
}
},
"Authorization": {
"Mechanism": "UNSECURED",
"Mechanism": "SAML2",
"AllowAllAuthenticatedUsers": true,
"UnsecuredIsAdmin": false,
"SAML2": {
Expand All @@ -49,11 +49,11 @@
}
},
"RolesMapping": {
"User": "urn:mace:users",
"Super": "urn:mace:supers",
"Identified": "urn:mace:phi",
"Admin": "urn:mace:sudos",
"Federated": "urn:mace:federated"
"User": "leaf_users",
"Super": "leaf_supers",
"Identified": "leaf_phi",
"Admin": "leaf_admin",
"Federated": "leaf_federated"
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion dev/radar/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ services:
labels:
# https://leafdocs.rit.uw.edu/installation/installation_steps/9_saml2/#route-protection-setup
- traefik.http.routers.radar-coreapi-auth-${COMPOSE_PROJECT_NAME}.rule=Host(`radar.${LEAF_DOMAIN}`) && Path(`/api/user`)
- traefik.http.routers.radar-coreapi-auth-${COMPOSE_PROJECT_NAME}.middlewares=oidc-auth-${COMPOSE_PROJECT_NAME}
- traefik.http.routers.radar-coreapi-auth-${COMPOSE_PROJECT_NAME}.middlewares=oidc-auth-${COMPOSE_PROJECT_NAME},leaf-groups-${COMPOSE_PROJECT_NAME}
- traefik.http.routers.radar-coreapi-auth-${COMPOSE_PROJECT_NAME}.entrypoints=websecure
- traefik.http.routers.radar-coreapi-auth-${COMPOSE_PROJECT_NAME}.tls.certresolver=letsencrypt

Expand Down

0 comments on commit f8ff8f0

Please sign in to comment.