Erick Tedeschi fala sobre Segurança de identidade digital levando em consideração uma arquitetura de microserviço no InterCon 2016.
Saiba mais em http://intercon2016.imasters.com.br/
iMastersjornalista, web editor, web writer, tradutora (en-pt/pt-en) at iMasters
2. Who?
• PHP
Developer
since
2003
• Application
Security
since
2007
• Biker
• Maker
• Help
devs delivery
Secure
Applications
• Help
business
to
keep
clients
data
secure
3. Agenda
• Microservice architecture
Version
1
• About
Tokens
• OAuth
2.0
• OpenID
Connect
• Authorization
Code
Flow
Example
• Microservice architecture
NG!!!
4. Microservice Architecture
V1
API
GatewayOAuth
Server*
Account
GET
/my/{user_id}
Transfer
POST
/transferto/{src_account}/{dst_account}
Receipt
GET
/receipts/{user_id}
End-‐User
Bank
API
(Public)
GET
/my
POST
/transferto/{dst_account}
GET
/receipts
/token
/authorize
Basic
auth
Basic
auth
No
auth
5. Microservice Architecture
V1
API
GatewayOAuth
Server*
Account
GET
/my/{user_id}
Transfer
POST
/transferto/{src_account}/{dst_account}
Receipt
GET
/receipts/{user_id}
End-‐User
Bank
API
(Public)
GET
/my
POST
/transferto/{dst_account}
GET
/receipts
/token
/authorize
Basic
auth
Basic
auth
No
auth
• Poor
logging
(audit
trail)
• Poor
identification
on
microservices (X-‐User-‐Logged
L)
• Authorization
centralized
on
API
Gateway
• Microservices are
more
like
CRUDs
APIs
• Microservices have
”micro
user
repositories”
or
don’t
have
authentication/authorization
• API
Gateway
have
more
responsibility
than
necessary
6. Now,
let’s
take
a
look
at
the:
Token
• A
piece
of stamped metal used
as
a substitute for money;
a voucher that
can
be
exchanged
for
goods
or
services
(https://en.wiktionary.org/wiki/token)
• Token
By
Reference
• An
opaque
string
generated
randomly
• Ex.:
2YotnFZFEjr1zCsicMWpAA
• Token
By
Value
• A
JWT
that
contains
claims
about
the
context
of
the
token
• Ex.:
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczovL215LnNlcnZpY2UuY29tIiwiaWF0IjoxNDM1MTc5NjAzLCJleHA
iOjE0MzUxODE0MjEsImF1ZCI6Ind3dy5zZXJ2aWNlLmNvbSIsInN1YiI6ImpvaG5kb2VAZ21haWwuY29tIiwiUm9sZSI6WyJhcHByb
3ZlciIsInZpZXdlciJdfQ.91GLvtMhhnICmqlf_RVONGw5IM9i8eeAPx2s_WpMObU
8. The
OAuth
2.0
Authorization
Framework
The
OAuth
2.0
enables
a
third-‐party
application
to
obtain
limited
access
to
an
HTTP
service
on
behalf
of
a
resource
owner...
16. A
complete
Authorization
Server
• /authorize
• /token
• /introspection
(check
access_token)
• /token_info (get
more
information
about
identity)
• /revocation
17. Let’s
see
how
to
get
both
access_token and
id_token using
Authorization
Code
Flow
30. Microservice Architecture
NG!!!
API
Gateway
Authorization
Server
Account
GET
/my
GET
/pvt/{account}
Transfer
POST
/transferto/{dst_account}
Receipt
GET
/receipts
OAuth
Filter
OAuth
Filter
OAuth
Filter
OAuth
Filter
Resource
Owner
Introspection/validation
Bank
API
(Public)
GET
/my
POST
/transferto/{dst_account}
GET
/receipts
/token
/authorize
/introspect
/revoke
/token_info
”offline
introspection/validation”
”offline
introspection/validation”
31. Microservice Architecture
NG!!!
API
Gateway
Authorization
Server
Account
GET
/my
GET
/pvt/{account}
Transfer
POST
/transferto/{dst_account}
Receipt
GET
/receipts
OAuth
Filter
OAuth
Filter
OAuth
Filter
OAuth
Filter
Resource
Owner
Introspection/validation
Bank
API
(Public)
GET
/my
POST
/transferto/{dst_account}
GET
/receipts
/token
/authorize
/introspect
/revoke
/token_info
”offline
introspection/validation”
”offline
introspection/validation”
• Audit
Trail
Improved
• Microservices can
make
decision
based
on
the
end-‐user
identity
• Fine
grained
authorization
across
the
services
• The
whole
environment
have
a
central
user
identity
repository
(OAuth+OpenID Connect
Server)
• API
Gateway
is
clean/slim