SlideShare a Scribd company logo
@magickatt on Twitter, GitHub
Background by M-ART Production https:/
/www.pexels.com/photo/a-back-view-of-a-man-in-brown-coat-standing-between-ticket-barriers-7252569/
Centralise legacy auth at the
ingress gateway
Andrew Kirkpatrick
SREday 2023
@magickatt on Twitter, GitHub
Image from https:/
/www.osohq.com/post/microservices-authorization-patterns
The problem?
@magickatt on Twitter, GitHub
Image from https:/
/www.osohq.com/post/microservices-authorization-patterns
A (possible) solution…?
@magickatt on Twitter, GitHub
Overview
1. But why not just use something off-the-shelf?
2. Identifying and categorising authentication
3. What information to send downstream?
4. Where to handle authorization
5. Stand-alone auth next to your gateway
6. Summary
Background by Codioful https:/
/www.pexels.com/photo/multicolor-photo-7130469/
@magickatt on Twitter, GitHub
But why not just use something
off-the-shelf?
Background by M-ART Production https:/
/www.pexels.com/photo/a-person-inserting-a-ticket-7252259/
@magickatt on Twitter, GitHub
Choosing an off-the-shelf solution
● Greenfield (brand new) project
○ No existing users?
○ No existing authentication/authorisation?
● Existing (possibly legacy) project?
○ Add to tech stack, or refactor existing?
○ Introducing a new authentication type
○ Deprecate existing authentication types?
○ Backwards compatibility with data?
○ Able to migrate/synchronise identity data?
https:/
/twitter.com/elonmusk/status/1632810081497513993
@magickatt on Twitter, GitHub
Migrate or synchronise identity data
If using an off-the-shelf solution, either have to migrate your users, or
find a way to (accurately) synchronise them
● How easy is it to copy/synchronise?
○ Extract data from your current platform
○ Add/update data in the new solution
● If migrating identity data across, move it in 1 go or keep in active
synchronisation?
@magickatt on Twitter, GitHub
Migrate or synchronise user data
If using an off-the-shelf solution, either have to migrate your users, or
find a way to (accurately) synchronise them
● How tricky is it to keep data in-sync?
○ How real-time is the synchronisation?
○ How often does user access and/or
permissions change?
○ How dangerous is it if out-of-sync?
@magickatt on Twitter, GitHub
Identifying and categorising
Background by cottonbro studio https:/
/www.pexels.com/photo/person-sitting-on-the-chair-near-the-plastic-containers-with-lables-6591427/
@magickatt on Twitter, GitHub
What mechanisms are you using?
Many, many different authentication types
● HTTP Basic
● HTTP Bearer
● Cookies
● API key
● OAuth 1.0, 1.0a
● OAuth 2.0
https:/
/blog.risingstack.com/web-authentication-methods-explained/
https:/
/blog.restcase.com/4-most-used-rest-api-authentication-methods/
https:/
/blog.stoplight.io/api-keys-best-practices-to-authenticate-apis
https:/
/www.synopsys.com/blogs/software-security/oauth-2-0-vs-oauth-1-0/
https:/
/www.wallarm.com/what/oauth-vs-jwt-detailed-comparison
@magickatt on Twitter, GitHub
How are these authentication types being used?
● What paths, subdomains and/or headers for which authentication type?
● Does each authentication type represent the same kind of identity?
(always a user?)
● How is auth configured?
○ Router
○ Method annotations/decorators
○ Middleware
○ Framework hooks/events/signals
○ Database page/object permissions
○ Configuration file
○ …
@magickatt on Twitter, GitHub
How are these authentication types being used?
● Multiple authentication types in a monolith, or different types
per-service?
● Are different implementations using different programming
languages/technology stacks?
● How would you combine these?
@magickatt on Twitter, GitHub
Example authentication identification
Try and choose 1 (or more) authentication types based on host, path or
headers
@magickatt on Twitter, GitHub
Example authentication identification
Alternatively try all authentication types until you determine which one is
being used
@magickatt on Twitter, GitHub
What information to send downstream?
Background by Aleksandr Burzinskij https:/
/www.pexels.com/photo/young-woman-swinging-on-swing-and-splashing-water-4834565/
@magickatt on Twitter, GitHub
Enhanced context
If handling multiple authentication types, you can consolidate their
identity/authorization information into a standardised format
● What does your current identity data look like?
● Can you represent different authentication types using a similar/same
data structure? (such as JSON)
● Ingress gateway can add headers from the auth service response to the
request sent downstream
● Header can contain identity data so do not need to look it up again
username,
password
{
user_id: 1,
company_id: 2,
name: Person
}
@magickatt on Twitter, GitHub
Example transformation
Users
Gateway
(add/remove
headers)
Auth service
Gateway removes Authorization header
Adds X-Internal-Auth header
Auth service fetches user using
credentials from Authorization
header (username and password)
Returns identity information in
header as encoded JSON
@magickatt on Twitter, GitHub
Multiple authentication types
Authorization Basic
username:password
X-Api-Key: key
If sometimes the identity object will not have a user,
does that change how you represent the company?
Each authentication type might not
represent the same thing. What if an
API key represents actions of whole a
company, rather than an individual
user in that company?
?
@magickatt on Twitter, GitHub
Where to handle authorisation
Background by Erik Mclean https:/
/www.pexels.com/photo/policeman-standing-near-modern-car-on-road-5662832/
@magickatt on Twitter, GitHub
Authentication versus authorisation
Centralise authentication, not necessarily all authorisation
● Typical auth response true/false (HTTP 2XX/4XX)
● Authentication as purely identity (who are they?)
● Authorisation as role or permission-based gate
● Most basic authorization “not logged in” (deny anonymous role)
Authenticate
identity
Authorize
identity
Fetch identity
using credentials
Does this
endpoint allow
anonymous
access?
@magickatt on Twitter, GitHub
{
"path": "/v1/admin/user/add",
"user": {
"name": "Somebody else",
"role": "member"
}
}
Broad authorization
Authenticate
identity
Authorize
identity
Fetch identity
using credentials
For this path
the user must
be an admin
{
"user_id": 1,
"name": "Somebody",
"role": "admin"
}
Request information
Identity information
(fetched during
authentication)
Use combination of
request and identity
information to
perform top-level
authorization
@magickatt on Twitter, GitHub
Delegates granular authorization
Authenticate
identity
Authorize
identity
Fetch identity
using credentials
Broad
authz
{
"user_id": 1,
"name": "Somebody",
"group": 2,
"roles": [
"document/viewer",
"group/moderator",
"report/viewer"
],
"acl": {
"document/1/admin": true,
"document/4/admin": true,
"document/8/admin": true
}
}
Too complicated
to authorize here,
let downstream
service decide…
{
"path": "/v1/document/123/attachment/456/delete"
}
Check
ACLs
Check
roles
Delete
document
Document service
@magickatt on Twitter, GitHub
Stand-alone auth next to your gateway
Background by Keenan Constance https:/
/www.pexels.com/photo/woman-sitting-on-wooden-planks-2865901/
@magickatt on Twitter, GitHub
Possible options for integrating
Most ingress gateways/proxies will allow you to specify an external auth
service via HTTP or gRPC
● Emissary Ingress AuthService (Envoy)
● Gloo Custom Auth server (Envoy)
● Kong Custom Plug-in (Nginx)
● Traefik ForwardAuth middleware
● Tyk custom plugin
● Nginx Subrequest Result
● AWS API Gateway Lambda Authorizers (Proprietary, Bearer only)
https:/
/www.getambassador.io/docs/emissary/latest/topics/running/services/auth-service
https:/
/docs.solo.io/gloo-edge/master/guides/security/auth/custom_auth/
https:/
/konghq.com/blog/custom-authentication-and-authorization-framework-with-kong
https:/
/doc.traefik.io/traefik/middlewares/http/forwardauth/
https:/
/tyk.io/blog/how-to-setup-custom-authentication-middleware-using-grpc-and-java/
https:/
/docs.nginx.com/nginx/admin-guide/security-controls/configuring-subrequest-authentication/
@magickatt on Twitter, GitHub
Web
request
Example ExtAuth request flow
Gateway HTTP/gRPC
Denied
Allowed
Auth service
● Headers
● Body
● Path
● Headers
● Path
● Response code (2XX or 4XX)
● Headers (modified)
● Body
● Path
1. Allow or deny based on headers
and path?
2. If allow, optionally add identity
and/or authorization information
@magickatt on Twitter, GitHub
Envoy ext_authz (Emissary Ingress AuthService)
Gateway HTTP/gRPC Auth service
Port 3000
https:/
/www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/security/ext_authz_filter#arch-overview-ext-authz
https:/
/www.getambassador.io/docs/emissary/latest/topics/running/services/auth-service
@magickatt on Twitter, GitHub
Practical example
Background by Ekaterina Bolovtsova https:/
/www.pexels.com/photo/a-figurine-of-the-lady-justice-on-the-table-of-a-judge-6077381/
@magickatt on Twitter, GitHub
Flask route auth via decorator request flow
Denied
Allowed
Auth
service Database
Route
decorator
All within the same
running application
/orders
API route
@magickatt on Twitter, GitHub
Flask route auth via decorator
@magickatt on Twitter, GitHub
Flask route auth via decorator
@magickatt on Twitter, GitHub
Flask route with ExtAuth request flow
Gateway HTTP
Denied
Allowed
Auth service
/orders
API route
Route
decorator
@magickatt on Twitter, GitHub
Flask route with ExtAuth
@magickatt on Twitter, GitHub
Flask route with ExtAuth
@magickatt on Twitter, GitHub
Flask route auth via decorator
@magickatt on Twitter, GitHub
Background by Mitchell Luo https:/
/www.pexels.com/photo/anonymous-woman-walking-near-pay-gates-5918868/
Summary
@magickatt on Twitter, GitHub
Summary
● Can use (almost) any type of authentication
● Try and determine what authentication types are used for which
paths/domains/headers to reduce checks/lookups (if possible)
● Pass identity and/or authorisation information onto your downstream
services
● Consider how to represent authentication/authorization data sent
downstream
● Handle none, some or all authorization before it reaches your services
● Ensure the auth service is highly available to ensure availability
© 2023 StackAdapt Inc.
StackAdapt is a self-serve programmatic advertising
platform used by the most exceptional digital marketers.
This state-of-the-art platform is where some of the most
progressive work in machine learning meets cutting-edge
user experience. Ad buyers plan, execute, and manage
data-driven digital advertising campaigns across all
devices, inventory, and publisher partners.
@magickatt on Twitter, GitHub
Thank you!
Hopefully this gives you some ideas as to how you might be
able to centralise legacy auth in some of your projects?
Slides (should be) available at
https://www.slideshare.net/magickatt/centralise-legacy-aut
h-at-the-ingress-gateway
Code example available at
https://github.com/magickatt/AuthAtTheGatewayTalk
● https://www.linkedin.com/in/andrewkirkpatrick/
● https://www.andrew-kirkpatrick.com
● https://github.com/magickatt
● https://twitter.com/magickatt

More Related Content

Similar to Centralise legacy auth at the ingress gateway

Spring Boot 1.3 News #渋谷Java
Spring Boot 1.3 News #渋谷JavaSpring Boot 1.3 News #渋谷Java
Spring Boot 1.3 News #渋谷Java
Toshiaki Maki
 
Altitude San Francisco 2018: Authentication at the Edge
Altitude San Francisco 2018: Authentication at the EdgeAltitude San Francisco 2018: Authentication at the Edge
Altitude San Francisco 2018: Authentication at the Edge
Fastly
 
MQTT security
MQTT securityMQTT security
MQTT security
Anthony Chow
 
UC2013 Speed Geeking: Intro to OAuth2
UC2013 Speed Geeking: Intro to OAuth2UC2013 Speed Geeking: Intro to OAuth2
UC2013 Speed Geeking: Intro to OAuth2
Aaron Parecki
 
Building @Anywhere (for TXJS)
Building @Anywhere (for TXJS)Building @Anywhere (for TXJS)
Building @Anywhere (for TXJS)
danwrong
 
Eliminating Secret Sprawl in the Cloud with HashiCorp Vault - 07.11.2018
Eliminating Secret Sprawl in the Cloud with HashiCorp Vault - 07.11.2018Eliminating Secret Sprawl in the Cloud with HashiCorp Vault - 07.11.2018
Eliminating Secret Sprawl in the Cloud with HashiCorp Vault - 07.11.2018
HashiCorp
 
Demystifying REST
Demystifying RESTDemystifying REST
Demystifying REST
Kirsten Hunter
 
Securing your apps with OAuth2 and OpenID Connect - Roland Guijt - Codemotion...
Securing your apps with OAuth2 and OpenID Connect - Roland Guijt - Codemotion...Securing your apps with OAuth2 and OpenID Connect - Roland Guijt - Codemotion...
Securing your apps with OAuth2 and OpenID Connect - Roland Guijt - Codemotion...
Codemotion
 
What the Heck is OAuth and OIDC - UberConf 2018
What the Heck is OAuth and OIDC - UberConf 2018What the Heck is OAuth and OIDC - UberConf 2018
What the Heck is OAuth and OIDC - UberConf 2018
Matt Raible
 
OAuth - Don’t Throw the Baby Out with the Bathwater
OAuth - Don’t Throw the Baby Out with the Bathwater OAuth - Don’t Throw the Baby Out with the Bathwater
OAuth - Don’t Throw the Baby Out with the Bathwater
Apigee | Google Cloud
 
The Current State of OAuth 2
The Current State of OAuth 2The Current State of OAuth 2
The Current State of OAuth 2
Aaron Parecki
 
Some OAuth love
Some OAuth loveSome OAuth love
Some OAuth love
Nicolas Blanco
 
Authentication and authorization in res tful infrastructures
Authentication and authorization in res tful infrastructuresAuthentication and authorization in res tful infrastructures
Authentication and authorization in res tful infrastructures
Corley S.r.l.
 
InterCon 2016 - Segurança de identidade digital levando em consideração uma a...
InterCon 2016 - Segurança de identidade digital levando em consideração uma a...InterCon 2016 - Segurança de identidade digital levando em consideração uma a...
InterCon 2016 - Segurança de identidade digital levando em consideração uma a...
iMasters
 
iMasters Intercon 2016 - Identity within Microservices
iMasters Intercon 2016 - Identity within MicroservicesiMasters Intercon 2016 - Identity within Microservices
iMasters Intercon 2016 - Identity within Microservices
Erick Belluci Tedeschi
 
How to Implement Token Authentication Using the Django REST Framework
How to Implement Token Authentication Using the Django REST FrameworkHow to Implement Token Authentication Using the Django REST Framework
How to Implement Token Authentication Using the Django REST Framework
Katy Slemon
 
I Love APIs 2015: Advanced Crash Course in Apigee Edge Workshop
I Love APIs 2015: Advanced Crash Course in Apigee Edge Workshop I Love APIs 2015: Advanced Crash Course in Apigee Edge Workshop
I Love APIs 2015: Advanced Crash Course in Apigee Edge Workshop
Apigee | Google Cloud
 
アプリ開発で知っておきたい認証技術 - OAuth 1.0 + OAuth 2.0 + OpenID Connect -
アプリ開発で知っておきたい認証技術 - OAuth 1.0 + OAuth 2.0 + OpenID Connect -アプリ開発で知っておきたい認証技術 - OAuth 1.0 + OAuth 2.0 + OpenID Connect -
アプリ開発で知っておきたい認証技術 - OAuth 1.0 + OAuth 2.0 + OpenID Connect -
Naoki Nagazumi
 
Securing RESTful APIs using OAuth 2 and OpenID Connect
Securing RESTful APIs using OAuth 2 and OpenID ConnectSecuring RESTful APIs using OAuth 2 and OpenID Connect
Securing RESTful APIs using OAuth 2 and OpenID Connect
Jonathan LeBlanc
 
Adding identity management and access control to your app
Adding identity management and access control to your appAdding identity management and access control to your app
Adding identity management and access control to your app
Álvaro Alonso González
 

Similar to Centralise legacy auth at the ingress gateway (20)

Spring Boot 1.3 News #渋谷Java
Spring Boot 1.3 News #渋谷JavaSpring Boot 1.3 News #渋谷Java
Spring Boot 1.3 News #渋谷Java
 
Altitude San Francisco 2018: Authentication at the Edge
Altitude San Francisco 2018: Authentication at the EdgeAltitude San Francisco 2018: Authentication at the Edge
Altitude San Francisco 2018: Authentication at the Edge
 
MQTT security
MQTT securityMQTT security
MQTT security
 
UC2013 Speed Geeking: Intro to OAuth2
UC2013 Speed Geeking: Intro to OAuth2UC2013 Speed Geeking: Intro to OAuth2
UC2013 Speed Geeking: Intro to OAuth2
 
Building @Anywhere (for TXJS)
Building @Anywhere (for TXJS)Building @Anywhere (for TXJS)
Building @Anywhere (for TXJS)
 
Eliminating Secret Sprawl in the Cloud with HashiCorp Vault - 07.11.2018
Eliminating Secret Sprawl in the Cloud with HashiCorp Vault - 07.11.2018Eliminating Secret Sprawl in the Cloud with HashiCorp Vault - 07.11.2018
Eliminating Secret Sprawl in the Cloud with HashiCorp Vault - 07.11.2018
 
Demystifying REST
Demystifying RESTDemystifying REST
Demystifying REST
 
Securing your apps with OAuth2 and OpenID Connect - Roland Guijt - Codemotion...
Securing your apps with OAuth2 and OpenID Connect - Roland Guijt - Codemotion...Securing your apps with OAuth2 and OpenID Connect - Roland Guijt - Codemotion...
Securing your apps with OAuth2 and OpenID Connect - Roland Guijt - Codemotion...
 
What the Heck is OAuth and OIDC - UberConf 2018
What the Heck is OAuth and OIDC - UberConf 2018What the Heck is OAuth and OIDC - UberConf 2018
What the Heck is OAuth and OIDC - UberConf 2018
 
OAuth - Don’t Throw the Baby Out with the Bathwater
OAuth - Don’t Throw the Baby Out with the Bathwater OAuth - Don’t Throw the Baby Out with the Bathwater
OAuth - Don’t Throw the Baby Out with the Bathwater
 
The Current State of OAuth 2
The Current State of OAuth 2The Current State of OAuth 2
The Current State of OAuth 2
 
Some OAuth love
Some OAuth loveSome OAuth love
Some OAuth love
 
Authentication and authorization in res tful infrastructures
Authentication and authorization in res tful infrastructuresAuthentication and authorization in res tful infrastructures
Authentication and authorization in res tful infrastructures
 
InterCon 2016 - Segurança de identidade digital levando em consideração uma a...
InterCon 2016 - Segurança de identidade digital levando em consideração uma a...InterCon 2016 - Segurança de identidade digital levando em consideração uma a...
InterCon 2016 - Segurança de identidade digital levando em consideração uma a...
 
iMasters Intercon 2016 - Identity within Microservices
iMasters Intercon 2016 - Identity within MicroservicesiMasters Intercon 2016 - Identity within Microservices
iMasters Intercon 2016 - Identity within Microservices
 
How to Implement Token Authentication Using the Django REST Framework
How to Implement Token Authentication Using the Django REST FrameworkHow to Implement Token Authentication Using the Django REST Framework
How to Implement Token Authentication Using the Django REST Framework
 
I Love APIs 2015: Advanced Crash Course in Apigee Edge Workshop
I Love APIs 2015: Advanced Crash Course in Apigee Edge Workshop I Love APIs 2015: Advanced Crash Course in Apigee Edge Workshop
I Love APIs 2015: Advanced Crash Course in Apigee Edge Workshop
 
アプリ開発で知っておきたい認証技術 - OAuth 1.0 + OAuth 2.0 + OpenID Connect -
アプリ開発で知っておきたい認証技術 - OAuth 1.0 + OAuth 2.0 + OpenID Connect -アプリ開発で知っておきたい認証技術 - OAuth 1.0 + OAuth 2.0 + OpenID Connect -
アプリ開発で知っておきたい認証技術 - OAuth 1.0 + OAuth 2.0 + OpenID Connect -
 
Securing RESTful APIs using OAuth 2 and OpenID Connect
Securing RESTful APIs using OAuth 2 and OpenID ConnectSecuring RESTful APIs using OAuth 2 and OpenID Connect
Securing RESTful APIs using OAuth 2 and OpenID Connect
 
Adding identity management and access control to your app
Adding identity management and access control to your appAdding identity management and access control to your app
Adding identity management and access control to your app
 

Recently uploaded

inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham HillinQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
LizaNolte
 
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
Fwdays
 
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving
 
"$10 thousand per minute of downtime: architecture, queues, streaming and fin...
"$10 thousand per minute of downtime: architecture, queues, streaming and fin..."$10 thousand per minute of downtime: architecture, queues, streaming and fin...
"$10 thousand per minute of downtime: architecture, queues, streaming and fin...
Fwdays
 
Call Girls Chandigarh🔥7023059433🔥Agency Profile Escorts in Chandigarh Availab...
Call Girls Chandigarh🔥7023059433🔥Agency Profile Escorts in Chandigarh Availab...Call Girls Chandigarh🔥7023059433🔥Agency Profile Escorts in Chandigarh Availab...
Call Girls Chandigarh🔥7023059433🔥Agency Profile Escorts in Chandigarh Availab...
manji sharman06
 
From NCSA to the National Research Platform
From NCSA to the National Research PlatformFrom NCSA to the National Research Platform
From NCSA to the National Research Platform
Larry Smarr
 
GlobalLogic Java Community Webinar #18 “How to Improve Web Application Perfor...
GlobalLogic Java Community Webinar #18 “How to Improve Web Application Perfor...GlobalLogic Java Community Webinar #18 “How to Improve Web Application Perfor...
GlobalLogic Java Community Webinar #18 “How to Improve Web Application Perfor...
GlobalLogic Ukraine
 
Lee Barnes - Path to Becoming an Effective Test Automation Engineer.pdf
Lee Barnes - Path to Becoming an Effective Test Automation Engineer.pdfLee Barnes - Path to Becoming an Effective Test Automation Engineer.pdf
Lee Barnes - Path to Becoming an Effective Test Automation Engineer.pdf
leebarnesutopia
 
"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota
Fwdays
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
Safe Software
 
Introduction to ThousandEyes AMER Webinar
Introduction  to ThousandEyes AMER WebinarIntroduction  to ThousandEyes AMER Webinar
Introduction to ThousandEyes AMER Webinar
ThousandEyes
 
Containers & AI - Beauty and the Beast!?!
Containers & AI - Beauty and the Beast!?!Containers & AI - Beauty and the Beast!?!
Containers & AI - Beauty and the Beast!?!
Tobias Schneck
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
Jason Yip
 
Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
Pablo Gómez Abajo
 
Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
Ivo Velitchkov
 
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
zjhamm304
 
MySQL InnoDB Storage Engine: Deep Dive - Mydbops
MySQL InnoDB Storage Engine: Deep Dive - MydbopsMySQL InnoDB Storage Engine: Deep Dive - Mydbops
MySQL InnoDB Storage Engine: Deep Dive - Mydbops
Mydbops
 
TrustArc Webinar - Your Guide for Smooth Cross-Border Data Transfers and Glob...
TrustArc Webinar - Your Guide for Smooth Cross-Border Data Transfers and Glob...TrustArc Webinar - Your Guide for Smooth Cross-Border Data Transfers and Glob...
TrustArc Webinar - Your Guide for Smooth Cross-Border Data Transfers and Glob...
TrustArc
 
Multivendor cloud production with VSF TR-11 - there and back again
Multivendor cloud production with VSF TR-11 - there and back againMultivendor cloud production with VSF TR-11 - there and back again
Multivendor cloud production with VSF TR-11 - there and back again
Kieran Kunhya
 
ScyllaDB Leaps Forward with Dor Laor, CEO of ScyllaDB
ScyllaDB Leaps Forward with Dor Laor, CEO of ScyllaDBScyllaDB Leaps Forward with Dor Laor, CEO of ScyllaDB
ScyllaDB Leaps Forward with Dor Laor, CEO of ScyllaDB
ScyllaDB
 

Recently uploaded (20)

inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham HillinQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
 
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
 
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
 
"$10 thousand per minute of downtime: architecture, queues, streaming and fin...
"$10 thousand per minute of downtime: architecture, queues, streaming and fin..."$10 thousand per minute of downtime: architecture, queues, streaming and fin...
"$10 thousand per minute of downtime: architecture, queues, streaming and fin...
 
Call Girls Chandigarh🔥7023059433🔥Agency Profile Escorts in Chandigarh Availab...
Call Girls Chandigarh🔥7023059433🔥Agency Profile Escorts in Chandigarh Availab...Call Girls Chandigarh🔥7023059433🔥Agency Profile Escorts in Chandigarh Availab...
Call Girls Chandigarh🔥7023059433🔥Agency Profile Escorts in Chandigarh Availab...
 
From NCSA to the National Research Platform
From NCSA to the National Research PlatformFrom NCSA to the National Research Platform
From NCSA to the National Research Platform
 
GlobalLogic Java Community Webinar #18 “How to Improve Web Application Perfor...
GlobalLogic Java Community Webinar #18 “How to Improve Web Application Perfor...GlobalLogic Java Community Webinar #18 “How to Improve Web Application Perfor...
GlobalLogic Java Community Webinar #18 “How to Improve Web Application Perfor...
 
Lee Barnes - Path to Becoming an Effective Test Automation Engineer.pdf
Lee Barnes - Path to Becoming an Effective Test Automation Engineer.pdfLee Barnes - Path to Becoming an Effective Test Automation Engineer.pdf
Lee Barnes - Path to Becoming an Effective Test Automation Engineer.pdf
 
"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
 
Introduction to ThousandEyes AMER Webinar
Introduction  to ThousandEyes AMER WebinarIntroduction  to ThousandEyes AMER Webinar
Introduction to ThousandEyes AMER Webinar
 
Containers & AI - Beauty and the Beast!?!
Containers & AI - Beauty and the Beast!?!Containers & AI - Beauty and the Beast!?!
Containers & AI - Beauty and the Beast!?!
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
 
Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
 
Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
 
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
 
MySQL InnoDB Storage Engine: Deep Dive - Mydbops
MySQL InnoDB Storage Engine: Deep Dive - MydbopsMySQL InnoDB Storage Engine: Deep Dive - Mydbops
MySQL InnoDB Storage Engine: Deep Dive - Mydbops
 
TrustArc Webinar - Your Guide for Smooth Cross-Border Data Transfers and Glob...
TrustArc Webinar - Your Guide for Smooth Cross-Border Data Transfers and Glob...TrustArc Webinar - Your Guide for Smooth Cross-Border Data Transfers and Glob...
TrustArc Webinar - Your Guide for Smooth Cross-Border Data Transfers and Glob...
 
Multivendor cloud production with VSF TR-11 - there and back again
Multivendor cloud production with VSF TR-11 - there and back againMultivendor cloud production with VSF TR-11 - there and back again
Multivendor cloud production with VSF TR-11 - there and back again
 
ScyllaDB Leaps Forward with Dor Laor, CEO of ScyllaDB
ScyllaDB Leaps Forward with Dor Laor, CEO of ScyllaDBScyllaDB Leaps Forward with Dor Laor, CEO of ScyllaDB
ScyllaDB Leaps Forward with Dor Laor, CEO of ScyllaDB
 

Centralise legacy auth at the ingress gateway

  • 1. @magickatt on Twitter, GitHub Background by M-ART Production https:/ /www.pexels.com/photo/a-back-view-of-a-man-in-brown-coat-standing-between-ticket-barriers-7252569/ Centralise legacy auth at the ingress gateway Andrew Kirkpatrick SREday 2023
  • 2. @magickatt on Twitter, GitHub Image from https:/ /www.osohq.com/post/microservices-authorization-patterns The problem?
  • 3. @magickatt on Twitter, GitHub Image from https:/ /www.osohq.com/post/microservices-authorization-patterns A (possible) solution…?
  • 4. @magickatt on Twitter, GitHub Overview 1. But why not just use something off-the-shelf? 2. Identifying and categorising authentication 3. What information to send downstream? 4. Where to handle authorization 5. Stand-alone auth next to your gateway 6. Summary Background by Codioful https:/ /www.pexels.com/photo/multicolor-photo-7130469/
  • 5. @magickatt on Twitter, GitHub But why not just use something off-the-shelf? Background by M-ART Production https:/ /www.pexels.com/photo/a-person-inserting-a-ticket-7252259/
  • 6. @magickatt on Twitter, GitHub Choosing an off-the-shelf solution ● Greenfield (brand new) project ○ No existing users? ○ No existing authentication/authorisation? ● Existing (possibly legacy) project? ○ Add to tech stack, or refactor existing? ○ Introducing a new authentication type ○ Deprecate existing authentication types? ○ Backwards compatibility with data? ○ Able to migrate/synchronise identity data? https:/ /twitter.com/elonmusk/status/1632810081497513993
  • 7. @magickatt on Twitter, GitHub Migrate or synchronise identity data If using an off-the-shelf solution, either have to migrate your users, or find a way to (accurately) synchronise them ● How easy is it to copy/synchronise? ○ Extract data from your current platform ○ Add/update data in the new solution ● If migrating identity data across, move it in 1 go or keep in active synchronisation?
  • 8. @magickatt on Twitter, GitHub Migrate or synchronise user data If using an off-the-shelf solution, either have to migrate your users, or find a way to (accurately) synchronise them ● How tricky is it to keep data in-sync? ○ How real-time is the synchronisation? ○ How often does user access and/or permissions change? ○ How dangerous is it if out-of-sync?
  • 9. @magickatt on Twitter, GitHub Identifying and categorising Background by cottonbro studio https:/ /www.pexels.com/photo/person-sitting-on-the-chair-near-the-plastic-containers-with-lables-6591427/
  • 10. @magickatt on Twitter, GitHub What mechanisms are you using? Many, many different authentication types ● HTTP Basic ● HTTP Bearer ● Cookies ● API key ● OAuth 1.0, 1.0a ● OAuth 2.0 https:/ /blog.risingstack.com/web-authentication-methods-explained/ https:/ /blog.restcase.com/4-most-used-rest-api-authentication-methods/ https:/ /blog.stoplight.io/api-keys-best-practices-to-authenticate-apis https:/ /www.synopsys.com/blogs/software-security/oauth-2-0-vs-oauth-1-0/ https:/ /www.wallarm.com/what/oauth-vs-jwt-detailed-comparison
  • 11. @magickatt on Twitter, GitHub How are these authentication types being used? ● What paths, subdomains and/or headers for which authentication type? ● Does each authentication type represent the same kind of identity? (always a user?) ● How is auth configured? ○ Router ○ Method annotations/decorators ○ Middleware ○ Framework hooks/events/signals ○ Database page/object permissions ○ Configuration file ○ …
  • 12. @magickatt on Twitter, GitHub How are these authentication types being used? ● Multiple authentication types in a monolith, or different types per-service? ● Are different implementations using different programming languages/technology stacks? ● How would you combine these?
  • 13. @magickatt on Twitter, GitHub Example authentication identification Try and choose 1 (or more) authentication types based on host, path or headers
  • 14. @magickatt on Twitter, GitHub Example authentication identification Alternatively try all authentication types until you determine which one is being used
  • 15. @magickatt on Twitter, GitHub What information to send downstream? Background by Aleksandr Burzinskij https:/ /www.pexels.com/photo/young-woman-swinging-on-swing-and-splashing-water-4834565/
  • 16. @magickatt on Twitter, GitHub Enhanced context If handling multiple authentication types, you can consolidate their identity/authorization information into a standardised format ● What does your current identity data look like? ● Can you represent different authentication types using a similar/same data structure? (such as JSON) ● Ingress gateway can add headers from the auth service response to the request sent downstream ● Header can contain identity data so do not need to look it up again username, password { user_id: 1, company_id: 2, name: Person }
  • 17. @magickatt on Twitter, GitHub Example transformation Users Gateway (add/remove headers) Auth service Gateway removes Authorization header Adds X-Internal-Auth header Auth service fetches user using credentials from Authorization header (username and password) Returns identity information in header as encoded JSON
  • 18. @magickatt on Twitter, GitHub Multiple authentication types Authorization Basic username:password X-Api-Key: key If sometimes the identity object will not have a user, does that change how you represent the company? Each authentication type might not represent the same thing. What if an API key represents actions of whole a company, rather than an individual user in that company? ?
  • 19. @magickatt on Twitter, GitHub Where to handle authorisation Background by Erik Mclean https:/ /www.pexels.com/photo/policeman-standing-near-modern-car-on-road-5662832/
  • 20. @magickatt on Twitter, GitHub Authentication versus authorisation Centralise authentication, not necessarily all authorisation ● Typical auth response true/false (HTTP 2XX/4XX) ● Authentication as purely identity (who are they?) ● Authorisation as role or permission-based gate ● Most basic authorization “not logged in” (deny anonymous role) Authenticate identity Authorize identity Fetch identity using credentials Does this endpoint allow anonymous access?
  • 21. @magickatt on Twitter, GitHub { "path": "/v1/admin/user/add", "user": { "name": "Somebody else", "role": "member" } } Broad authorization Authenticate identity Authorize identity Fetch identity using credentials For this path the user must be an admin { "user_id": 1, "name": "Somebody", "role": "admin" } Request information Identity information (fetched during authentication) Use combination of request and identity information to perform top-level authorization
  • 22. @magickatt on Twitter, GitHub Delegates granular authorization Authenticate identity Authorize identity Fetch identity using credentials Broad authz { "user_id": 1, "name": "Somebody", "group": 2, "roles": [ "document/viewer", "group/moderator", "report/viewer" ], "acl": { "document/1/admin": true, "document/4/admin": true, "document/8/admin": true } } Too complicated to authorize here, let downstream service decide… { "path": "/v1/document/123/attachment/456/delete" } Check ACLs Check roles Delete document Document service
  • 23. @magickatt on Twitter, GitHub Stand-alone auth next to your gateway Background by Keenan Constance https:/ /www.pexels.com/photo/woman-sitting-on-wooden-planks-2865901/
  • 24. @magickatt on Twitter, GitHub Possible options for integrating Most ingress gateways/proxies will allow you to specify an external auth service via HTTP or gRPC ● Emissary Ingress AuthService (Envoy) ● Gloo Custom Auth server (Envoy) ● Kong Custom Plug-in (Nginx) ● Traefik ForwardAuth middleware ● Tyk custom plugin ● Nginx Subrequest Result ● AWS API Gateway Lambda Authorizers (Proprietary, Bearer only) https:/ /www.getambassador.io/docs/emissary/latest/topics/running/services/auth-service https:/ /docs.solo.io/gloo-edge/master/guides/security/auth/custom_auth/ https:/ /konghq.com/blog/custom-authentication-and-authorization-framework-with-kong https:/ /doc.traefik.io/traefik/middlewares/http/forwardauth/ https:/ /tyk.io/blog/how-to-setup-custom-authentication-middleware-using-grpc-and-java/ https:/ /docs.nginx.com/nginx/admin-guide/security-controls/configuring-subrequest-authentication/
  • 25. @magickatt on Twitter, GitHub Web request Example ExtAuth request flow Gateway HTTP/gRPC Denied Allowed Auth service ● Headers ● Body ● Path ● Headers ● Path ● Response code (2XX or 4XX) ● Headers (modified) ● Body ● Path 1. Allow or deny based on headers and path? 2. If allow, optionally add identity and/or authorization information
  • 26. @magickatt on Twitter, GitHub Envoy ext_authz (Emissary Ingress AuthService) Gateway HTTP/gRPC Auth service Port 3000 https:/ /www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/security/ext_authz_filter#arch-overview-ext-authz https:/ /www.getambassador.io/docs/emissary/latest/topics/running/services/auth-service
  • 27. @magickatt on Twitter, GitHub Practical example Background by Ekaterina Bolovtsova https:/ /www.pexels.com/photo/a-figurine-of-the-lady-justice-on-the-table-of-a-judge-6077381/
  • 28. @magickatt on Twitter, GitHub Flask route auth via decorator request flow Denied Allowed Auth service Database Route decorator All within the same running application /orders API route
  • 29. @magickatt on Twitter, GitHub Flask route auth via decorator
  • 30. @magickatt on Twitter, GitHub Flask route auth via decorator
  • 31. @magickatt on Twitter, GitHub Flask route with ExtAuth request flow Gateway HTTP Denied Allowed Auth service /orders API route Route decorator
  • 32. @magickatt on Twitter, GitHub Flask route with ExtAuth
  • 33. @magickatt on Twitter, GitHub Flask route with ExtAuth
  • 34. @magickatt on Twitter, GitHub Flask route auth via decorator
  • 35. @magickatt on Twitter, GitHub Background by Mitchell Luo https:/ /www.pexels.com/photo/anonymous-woman-walking-near-pay-gates-5918868/ Summary
  • 36. @magickatt on Twitter, GitHub Summary ● Can use (almost) any type of authentication ● Try and determine what authentication types are used for which paths/domains/headers to reduce checks/lookups (if possible) ● Pass identity and/or authorisation information onto your downstream services ● Consider how to represent authentication/authorization data sent downstream ● Handle none, some or all authorization before it reaches your services ● Ensure the auth service is highly available to ensure availability
  • 37. © 2023 StackAdapt Inc. StackAdapt is a self-serve programmatic advertising platform used by the most exceptional digital marketers. This state-of-the-art platform is where some of the most progressive work in machine learning meets cutting-edge user experience. Ad buyers plan, execute, and manage data-driven digital advertising campaigns across all devices, inventory, and publisher partners.
  • 38. @magickatt on Twitter, GitHub Thank you! Hopefully this gives you some ideas as to how you might be able to centralise legacy auth in some of your projects? Slides (should be) available at https://www.slideshare.net/magickatt/centralise-legacy-aut h-at-the-ingress-gateway Code example available at https://github.com/magickatt/AuthAtTheGatewayTalk ● https://www.linkedin.com/in/andrewkirkpatrick/ ● https://www.andrew-kirkpatrick.com ● https://github.com/magickatt ● https://twitter.com/magickatt