SlideShare a Scribd company logo
Securing
Microservices
using Play and Akka HTTP
Rafal Gancarz
@RafalGancarz
1
About me
• Lead Consultant at
OpenCredo
• Helping companies transform
their IT platforms and the ways
their do business
• Technologist, architect,
developer
• Agile practitioner & evangelist
• Scala <- Java <- PHP
2
(Micro)services
• SOA reloaded
• Lightweight, open standards
• Loosely coupled, self-contained
• Independent and scalable
• Bounded context (part of business domain)
3
Securing the monolith
DB
authentication
Pros
• single entry point
• limited attack surface
• centralised authentication &
authorisation
Cons
• totally exposed when
compromised
4

Recommended for you

Anatomy of a Modern Node.js Application Architecture
Anatomy of a Modern Node.js Application Architecture Anatomy of a Modern Node.js Application Architecture
Anatomy of a Modern Node.js Application Architecture

This document provides an overview of the typical components and architecture of a modern Node.js application, including web and application servers, a queue, worker servers, databases, caches, and how to monitor transactions as they flow through the distributed system. It also describes how to configure AppDynamics to monitor errors, transactions, hardware resources, calls to external services and databases, and end user experience for Node.js applications.

node.jsapplication monitoringnode.js architecture
NoSQL - No Security?
NoSQL - No Security?NoSQL - No Security?
NoSQL - No Security?

This document discusses NoSQL database security issues. It begins by introducing NoSQL and big data concepts. It then covers common NoSQL databases and explains why they are popular. However, it notes that NoSQL solutions are often not designed with security in mind by default. Some key security issues with NoSQL databases include weak authentication, insecure password storage, lack of authorization controls, and vulnerabilities to injection attacks. The document provides examples of these issues and recommends ways to secure NoSQL installations, such as validating inputs, defining a trusted environment, and continuing to sanitize for traditional and NoSQL-specific attacks.

Developing distributed applications with Akka and Akka Cluster
Developing distributed applications with Akka and Akka ClusterDeveloping distributed applications with Akka and Akka Cluster
Developing distributed applications with Akka and Akka Cluster

This document outlines a presentation on developing distributed applications with Akka and Akka Cluster. It introduces Akka as a toolkit for building highly concurrent, distributed, and fault tolerant applications. It discusses concurrency paradigms like actors, dataflow, and software transactional memory. Live demos are presented showing actors, Akka remoting and clustering, and consistent replicated data types. The presentation emphasizes building distributed systems with Akka's actor model and using features like routers, deployment, and CRDTs to manage distributed state.

Securing the monolith -
considerations
• Combined presentation and business logic tier
• End user login
• Session based authentication
• Single sign-on (usually with SAML)
5
Securing microservices
(first take)
DB
Pros
• siloed data
Cons
• large attack surface
• multiple auth enforcement
points
• shared auth data storeDB DB
6
• Who is the consumer (the end user vs the third-party system)?
• Is user context relevant?
• access control granularity
• act on behalf
• What are the security related requirements?
• highly sensitive data
• integration over public internet
• social login
• single sign-on (SSO)
Securing microservices - considerations
7
• What are commercial requirements for your project?
• time to market
• availability of skills / expertise
• buy vs build
• What about the legacy?
• existing security implementation
• interoperability with the legacy platform
Securing microservices - considerations
8

Recommended for you

Containerless in the Cloud with AWS Lambda
Containerless in the Cloud with AWS LambdaContainerless in the Cloud with AWS Lambda
Containerless in the Cloud with AWS Lambda

Slides from ConFoo (confoo.ca) 2017 presentation on Amazon Lambda. Covers AWS Lambda, AWS Cognito, and AWS API-Gateway.

javaaws api-gatewayaws
Come sta la nostra applicazione? Un viaggio alla scoperta degli Health Check ...
Come sta la nostra applicazione? Un viaggio alla scoperta degli Health Check ...Come sta la nostra applicazione? Un viaggio alla scoperta degli Health Check ...
Come sta la nostra applicazione? Un viaggio alla scoperta degli Health Check ...

In questa sessione scopriremo come utilizzare al meglio di Health Check, funzionalità che è stata introdotta in ASP.NET ancora dalla versione 2.2, ma che poche applicazioni sfruttano. Uno strumento davvero utile anche per un primo debug, o per una semplice verifica dello stato delle nostre applicazioni...e non solo per chi utilizza container e orchestratori. Cosa ci permettono di sapere gli Health Check? Come possiamo essere notificati se qualcosa non va nel verso giusto? A queste e ad altre domande daremo risposta nel corso della sessione

asp.netasp.net corehealthchecks
Microservices with SenecaJS (part 2)
Microservices with SenecaJS (part 2)Microservices with SenecaJS (part 2)
Microservices with SenecaJS (part 2)

The document discusses microservices architecture using SenecaJS, RabbitMQ, Docker, and other tools. It covers setting up RabbitMQ with Docker, using SenecaJS's pattern matching and transport capabilities including AMQP transport with RabbitMQ, running services in Docker containers or with PM2, using Consul for service discovery and configuration, and implementing authentication with JWT. The presentation includes demos and discusses testing and other topics related to building microservices.

microservicessenecajs
API gateway
DB DB DB
API gateway
Pros
• single point of entry
• limited surface attack
• configurable authentication
protocols and backends
• faster time to market
• gateway availability/scalability
Cons
• additional cost
• services unsecured internally
• HTTP level access control
• limited auth context
9
HTTP basic auth + client id&secret
DB DB DB
Pros
• easy
• good for third-party integration
• stateless
Cons
• requires TLS
• doesn’t expire
• difficult to enforce at scale
(unless used with API gateway)
client_id
client_secret
10
Play Framework
• Basic HTTP auth with HTTP filter
• Basic HTTP auth with Action builder
• Play2.x Authentication and Authorization module
(https://github.com/t2v/play2-auth)
• Pac4j module (https://github.com/leleuj/play-pac4j)
• Secure Social module (http://securesocial.ws/)
• Silhouette module (http://silhouette.mohiva.com/)
11
Akka HTTP
• authenticateBasicX directives
• http://doc.akka.io/docs/akka-stream-and-http-experimental/2.0-M2/scala/http/routing-dsl/directives/
security-directives/authenticateBasic.html#authenticatebasic
def myUserPassAuthenticator(credentials: Credentials): Future[Option[String]] =
credentials match {
case p @ Credentials.Provided(id) =>
Future {
// potentially
if (p.verify("s3cr3t")) Some(id)
else None
}
case _ => Future.successful(None)
}
val route =
Route.seal {
path("secured") {
authenticateBasicAsync(realm = "secure site", myUserPassAuthenticator)
{ userName =>
complete(s"The user is '$userName'")
}
}
}
12

Recommended for you

4 JVM Web Frameworks
4 JVM Web Frameworks4 JVM Web Frameworks
4 JVM Web Frameworks

The document discusses various JVM web frameworks including Play, Ratpack, Spring Boot, and Rails. It provides code examples for templating, databases, servers, and other aspects of each framework. It compares the strengths and weaknesses of frameworks like Play, Ratpack, and Spring Boot. It emphasizes that modern JVM web development uses languages like Scala, Groovy, JRuby and Clojure rather than traditional Java web apps with WAR files. The document encourages the audience to pick a framework like Play, Ratpack or Rails and provides the basic commands to create a new project in each.

TDD a REST API With Node.js and MongoDB
TDD a REST API With Node.js and MongoDBTDD a REST API With Node.js and MongoDB
TDD a REST API With Node.js and MongoDB

This document discusses developing and testing a MongoDB and Node.js REST API. It introduces MongoDB and Node.js, and then covers building an API with the following parts: using Mongoose to define schemas for products, categories, and users; building routes with Express; and testing with Mocha and Superagent. Key topics include schema design principles, building RESTful routes, and testing the API end-to-end. The goal is to learn how to structure APIs on MongoDB with Node.js and ensure quality with testing.

mongodbnodejs
Blazor, lo sapevi che...
Blazor, lo sapevi che...Blazor, lo sapevi che...
Blazor, lo sapevi che...

Stanco delle solite sessioni introduttive o generiche su blazor? Bene, questa è la serata che fa per te. In questa sessione ho raccolto una serie di argomenti, problematiche e tips derivanti da due anni di utilizzo di Blazor (praticamente dal suo lancio). Casi reali affrontanti e risolti. E come nel (ormai) classico format online di XE, ci sarà ampio spazio per le domande ed il confronto.

blazorwasmasp.net
OAuth2+OpenID Connect
DB DB DB
Auth Server
Pros
• standard based
• popular for social login & delegated
authorisation
• caters for browser, mobile and
server-to-server use cases
• token expiry
Cons
• requires TLS
• requires Authorisation Server
• developed initially as authorisation
framework
• numerous flavours used
• non-trivial to get right
• authentication impl out of scope
13
Play Framework
• Pac4j module (https://github.com/leleuj/play-pac4j)
- supports OAuth2, OAuth2 and OpenID
• Secure Social module (http://securesocial.ws/) -
supports OAuth1 and OAuth2
• Silhouette module (http://silhouette.mohiva.com/) -
supports OAuth1, OAuth2 and OpenID
14
Akka HTTP
• authenticateOAuth2X directives
• http://doc.akka.io/docs/akka-stream-and-http-experimental/2.0-M2/scala/http/
routing-dsl/directives/security-directives/
authenticateOAuth2.html#authenticateoauth2
def authenticateOAuth2[T](realm: String,
authenticator: Authenticator[T]):
AuthenticationDirective[T]
Usage the same as HTTP basic but requires validating access
token retrieved from the header (not supported natively).
15
OpenID Connect
• Nimbus (https://bitbucket.org/connect2id/
oauth-2.0-sdk-with-openid-connect-extensions)
• Apache Oltu (https://oltu.apache.org/)
https://openid.net/developers/specs/ 16

Recommended for you

Javantura v4 - (Spring)Boot your application on Red Hat middleware stack - Al...
Javantura v4 - (Spring)Boot your application on Red Hat middleware stack - Al...Javantura v4 - (Spring)Boot your application on Red Hat middleware stack - Al...
Javantura v4 - (Spring)Boot your application on Red Hat middleware stack - Al...

This document provides an overview of Red Hat's middleware stack and how Spring Boot applications can be deployed on it. It discusses Red Hat middleware products like WildFly and KeyCloak, as well as OpenShift for Kubernetes-based application deployment. It also covers tools like Fabric8 for building and deploying Docker images to OpenShift and CE & Obsidian for integrating various products and generating quickstarts. Finally, it announces some demos of KeyCloak and Artemis integration with Spring Boot applications.

springbootred hataleš justin
Web application development using Play Framework (with Java)
Web application development using Play Framework (with Java)Web application development using Play Framework (with Java)
Web application development using Play Framework (with Java)

This document provides an overview of the Play Framework for web application development using Java. It discusses the history and architecture of Play, how to set up a Play project, the MVC structure, routing, controllers, views, sessions, assets, hot code reloading, databases, testing, deployment, and scaling. Play uses Netty as its web server, is stateless, supports hot code reloading, and allows building asynchronous and reactive applications. It also has integrations for Akka, WebSockets, caching, internationalization, and more.

java play framework
ASP.NET: Present and future
ASP.NET: Present and futureASP.NET: Present and future
ASP.NET: Present and future

what's happening in ASP.NET, and where things are going. Or course, at time of writing (September 2013)

asp.net.net framework
JSON Web Token
DB DB DB
Auth Server
Pros
• auth claims can be signed
(HMAC or RSA)
• compact (suitable for URLs,
headers, query params)
• self-contained, stateless
• excellent SAML alternative for
SSO
Cons
• requires TLS or encryption
• authentication impl out of scope
http://jwt.io/
17
JSON Web Token
• No built-in support in Play or Akka HTTP
• authentikat-jwt (https://github.com/jasongoodwin/
authentikat-jwt) - Scala
• iain-logan/jwt (https://github.com/iain-logan/jwt) - Scala
• jose4j (https://bitbucket.org/b_c/jose4j/wiki/Home) -
Java
• jjwt (https://github.com/jwtk/jjwt) - Java
18
Mutually authenticated TLS
DB DB DB
Pros
• strong point to point security
Cons
• requires PKI
• key management and
distribution challenging
• difficult to implement and
troubleshoot
• no user context
mTLS
19
Play Framework - server-side
• https://www.playframework.com/documentation/2.4.x/ConfiguringHttps
class CustomSSLEngineProvider(appProvider: ApplicationProvider) extends SSLEngineProvider {
def createSSLContext(applicationProvider: ApplicationProvider): SSLContext = {

val keyManagers = readKeyManagers()

val trustManagers = readTrustManagers()



val sslContext = SSLContext.getInstance("TLS")

sslContext.init(keyManagers, trustManagers, null)

sslContext

}
override def createSSLEngine(): SSLEngine = {
val sslContext = createSSLContext(appProvider)
val sslParameters = sslContext.getDefaultSSLParameters
sslParameters.setUseCipherSuitesOrder(true)
sslParameters.setNeedClientAuth(true)
val engine = sslContext.createSSLEngine

engine.setSSLParameters(sslParameters)
engine
}
}
20

Recommended for you

Introduction to Shield and kibana
Introduction to Shield and kibanaIntroduction to Shield and kibana
Introduction to Shield and kibana

The shield is a plugin for Elasticsearch that enables you to easily secure an elasticsearch cluster. Kibana is an open source analytics and visualization platform designed to work with Elasticsearch

knoldusknolxkibana
AWS Primer and Quickstart
AWS Primer and QuickstartAWS Primer and Quickstart
AWS Primer and Quickstart

This document provides an introduction and overview of key AWS services, including: - Infrastructure as a Service (IaaS) offerings like EC2, EBS, S3, and regions/availability zones. - Platform as a Service (PaaS) like RDS, DynamoDB, Lambda, and analytics services. - Software as a Service (SaaS) examples. It discusses architecture principles of availability, fault tolerance, and scalability that AWS supports. Brief histories of AWS and its evolution are also presented.

cloudpublic cloudvirtualization
Flask jwt authentication tutorial
Flask jwt authentication tutorialFlask jwt authentication tutorial
Flask jwt authentication tutorial

Here’s a step-by-step guide to implement Flask JWT Authentication with an example. Clone the flask-jwt authentication github repo and play around with the code

flask jwt authenticationtechnologyremote working
Akka HTTP - server-side
• http://doc.akka.io/docs/akka-stream-and-http-experimental/2.0-
M2/scala/http/low-level-server-side-api.html#serversidehttps
def createSSLContext(): SSLContext = {

val keyManagers = readKeyManagers()

val trustManagers = readTrustManagers()



val sslContext = SSLContext.getInstance("TLS")

sslContext.init(keyManagers, trustManagers, null)

sslContext

}



def run() = {



implicit val system = ActorSystem("server")

implicit val materializer = ActorMaterializer()



val sslContext = createSSLContext()



val serverSource = Http().bind(interface = "localhost", port = 8200, ServerSettings(system),
Some(HttpsContext(sslContext, Some(immutable.Seq("TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384")),
Some(immutable.Seq("TLSv1.2")), Some(Need), Some(sslContext.getDefaultSSLParameters))))



…



}
21
Authorisation
• At the perimeter or within the business logic?
• Where user roles/permissions are coming from
(each bounded context might have different
access control considerations)?
• How is the user context passed into the service?
22
Play Framework
• Authorisation with HTTP filter
• Authorisation with Action builder
• Deadbolt (http://deadbolt.ws/#/home) - works with
Silhouette and SecureSocial for authentication
23
Akka HTTP
• authorize directive
• http://doc.akka.io/docs/akka-stream-and-http-experimental/2.0-M2/scala/http/routing-dsl/
directives/security-directives/authorize.html#authorize
case class User(name: String)
val admins = Set("Peter")
def hasAdminPermissions(user: User): Boolean =
admins.contains(user.name)
val route =
Route.seal {
authenticateBasic(realm = "secure site", myUserPassAuthenticator) { user
=>
path("peters-lair") {
authorize(hasAdminPermissions(user)) {
complete(s"'${user.name}' visited Peter's lair")
}
}
}
}
24

Recommended for you

Node js for enterprise
Node js for enterpriseNode js for enterprise
Node js for enterprise

The document discusses Node.js, including what it is, its benefits, use cases, and readiness for enterprise use. Node.js is an event-driven, non-blocking I/O model that is well-suited for building scalable web applications with real-time features but not CPU-intensive batch processes. It promotes fast development with smaller codebases and is widely adopted by enterprises. The document also covers Node.js application architecture, database support, development tools, deployment practices, and strategies for adoption.

node jsnode for enterprisenode js architecture
Server Sent Events, Async Servlet, Web Sockets and JSON; born to work together!
Server Sent Events, Async Servlet, Web Sockets and JSON; born to work together!Server Sent Events, Async Servlet, Web Sockets and JSON; born to work together!
Server Sent Events, Async Servlet, Web Sockets and JSON; born to work together!

This session focuses on how Java EE 7 provides extensive set of new and enhanced features to support standards like HTML5, WebSockets, and Server Sent Events among others.In this session we will show how these new features are designed and matched to work together for developing lightweight solutions matching end users high expectation from a web application’s responsiveness. The session will cover best practices and design patterns governing application development using JAX-RS 2.0, Async Servlet, and JSON-P (among others) as well as iterating over the pitfalls that should be avoided. During the session we will show code snippets and block diagrams that clarify use of APIs coming from the demo application we will show at the end.

server sent eventsasync servletwebsockets
Security Architecture Consulting - Hiren Shah
Security Architecture Consulting - Hiren ShahSecurity Architecture Consulting - Hiren Shah
Security Architecture Consulting - Hiren Shah

In modern age it has become crucial to perform secure architecture review along with regular pentest practice. Application architecture review can be defined as reviewing the current security controls in the application architecture. This helps a user to identify potential security flaws at an early stage and mitigate them before starting the development stage.

#infosec#nsconclave#nsconclave2020
Key takeaways
• Securing microservice based architectures is
challenging
• The technology landscape changes all the time
• One size (solution) doesn’t fit all
• Consider your requirements before committing to a
technical solution
25
Questions?
• Email: rafal.gancarz@opencredo.com
• Twitter: @RafalGancarz
• See me tomorrow at lunchtime for a Q&A session on
Securing Microservices using Play and Akka HTTP
• Visit OpenCredo’s booth tomorrow and enter a draw to
win Apple Watch!
• See you at the Scala Exchange party later :)
• Thank you!
26

More Related Content

What's hot

Building a serverless company on AWS lambda and Serverless framework
Building a serverless company on AWS lambda and Serverless frameworkBuilding a serverless company on AWS lambda and Serverless framework
Building a serverless company on AWS lambda and Serverless framework
Luciano Mammino
 
Scala play-framework
Scala play-frameworkScala play-framework
Scala play-framework
Abdhesh Kumar
 
Spicing up JMX with Jolokia (Devoxx 2014)
Spicing up JMX with Jolokia (Devoxx 2014)Spicing up JMX with Jolokia (Devoxx 2014)
Spicing up JMX with Jolokia (Devoxx 2014)
roland.huss
 
Anatomy of a Modern Node.js Application Architecture
Anatomy of a Modern Node.js Application Architecture Anatomy of a Modern Node.js Application Architecture
Anatomy of a Modern Node.js Application Architecture
AppDynamics
 
NoSQL - No Security?
NoSQL - No Security?NoSQL - No Security?
NoSQL - No Security?
Gavin Holt
 
Developing distributed applications with Akka and Akka Cluster
Developing distributed applications with Akka and Akka ClusterDeveloping distributed applications with Akka and Akka Cluster
Developing distributed applications with Akka and Akka Cluster
Konstantin Tsykulenko
 
Containerless in the Cloud with AWS Lambda
Containerless in the Cloud with AWS LambdaContainerless in the Cloud with AWS Lambda
Containerless in the Cloud with AWS Lambda
Ryan Cuprak
 
Come sta la nostra applicazione? Un viaggio alla scoperta degli Health Check ...
Come sta la nostra applicazione? Un viaggio alla scoperta degli Health Check ...Come sta la nostra applicazione? Un viaggio alla scoperta degli Health Check ...
Come sta la nostra applicazione? Un viaggio alla scoperta degli Health Check ...
Andrea Dottor
 
Microservices with SenecaJS (part 2)
Microservices with SenecaJS (part 2)Microservices with SenecaJS (part 2)
Microservices with SenecaJS (part 2)
Designveloper
 
4 JVM Web Frameworks
4 JVM Web Frameworks4 JVM Web Frameworks
4 JVM Web Frameworks
Joe Kutner
 
TDD a REST API With Node.js and MongoDB
TDD a REST API With Node.js and MongoDBTDD a REST API With Node.js and MongoDB
TDD a REST API With Node.js and MongoDB
Valeri Karpov
 
Blazor, lo sapevi che...
Blazor, lo sapevi che...Blazor, lo sapevi che...
Blazor, lo sapevi che...
Andrea Dottor
 
Javantura v4 - (Spring)Boot your application on Red Hat middleware stack - Al...
Javantura v4 - (Spring)Boot your application on Red Hat middleware stack - Al...Javantura v4 - (Spring)Boot your application on Red Hat middleware stack - Al...
Javantura v4 - (Spring)Boot your application on Red Hat middleware stack - Al...
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
Web application development using Play Framework (with Java)
Web application development using Play Framework (with Java)Web application development using Play Framework (with Java)
Web application development using Play Framework (with Java)
Saeed Zarinfam
 
ASP.NET: Present and future
ASP.NET: Present and futureASP.NET: Present and future
ASP.NET: Present and future
Hrvoje Hudoletnjak
 
Introduction to Shield and kibana
Introduction to Shield and kibanaIntroduction to Shield and kibana
Introduction to Shield and kibana
Knoldus Inc.
 
AWS Primer and Quickstart
AWS Primer and QuickstartAWS Primer and Quickstart
AWS Primer and Quickstart
Manish Pandit
 
Flask jwt authentication tutorial
Flask jwt authentication tutorialFlask jwt authentication tutorial
Flask jwt authentication tutorial
Katy Slemon
 
Node js for enterprise
Node js for enterpriseNode js for enterprise
Node js for enterprise
ravisankar munusamy
 
Server Sent Events, Async Servlet, Web Sockets and JSON; born to work together!
Server Sent Events, Async Servlet, Web Sockets and JSON; born to work together!Server Sent Events, Async Servlet, Web Sockets and JSON; born to work together!
Server Sent Events, Async Servlet, Web Sockets and JSON; born to work together!
Masoud Kalali
 

What's hot (20)

Building a serverless company on AWS lambda and Serverless framework
Building a serverless company on AWS lambda and Serverless frameworkBuilding a serverless company on AWS lambda and Serverless framework
Building a serverless company on AWS lambda and Serverless framework
 
Scala play-framework
Scala play-frameworkScala play-framework
Scala play-framework
 
Spicing up JMX with Jolokia (Devoxx 2014)
Spicing up JMX with Jolokia (Devoxx 2014)Spicing up JMX with Jolokia (Devoxx 2014)
Spicing up JMX with Jolokia (Devoxx 2014)
 
Anatomy of a Modern Node.js Application Architecture
Anatomy of a Modern Node.js Application Architecture Anatomy of a Modern Node.js Application Architecture
Anatomy of a Modern Node.js Application Architecture
 
NoSQL - No Security?
NoSQL - No Security?NoSQL - No Security?
NoSQL - No Security?
 
Developing distributed applications with Akka and Akka Cluster
Developing distributed applications with Akka and Akka ClusterDeveloping distributed applications with Akka and Akka Cluster
Developing distributed applications with Akka and Akka Cluster
 
Containerless in the Cloud with AWS Lambda
Containerless in the Cloud with AWS LambdaContainerless in the Cloud with AWS Lambda
Containerless in the Cloud with AWS Lambda
 
Come sta la nostra applicazione? Un viaggio alla scoperta degli Health Check ...
Come sta la nostra applicazione? Un viaggio alla scoperta degli Health Check ...Come sta la nostra applicazione? Un viaggio alla scoperta degli Health Check ...
Come sta la nostra applicazione? Un viaggio alla scoperta degli Health Check ...
 
Microservices with SenecaJS (part 2)
Microservices with SenecaJS (part 2)Microservices with SenecaJS (part 2)
Microservices with SenecaJS (part 2)
 
4 JVM Web Frameworks
4 JVM Web Frameworks4 JVM Web Frameworks
4 JVM Web Frameworks
 
TDD a REST API With Node.js and MongoDB
TDD a REST API With Node.js and MongoDBTDD a REST API With Node.js and MongoDB
TDD a REST API With Node.js and MongoDB
 
Blazor, lo sapevi che...
Blazor, lo sapevi che...Blazor, lo sapevi che...
Blazor, lo sapevi che...
 
Javantura v4 - (Spring)Boot your application on Red Hat middleware stack - Al...
Javantura v4 - (Spring)Boot your application on Red Hat middleware stack - Al...Javantura v4 - (Spring)Boot your application on Red Hat middleware stack - Al...
Javantura v4 - (Spring)Boot your application on Red Hat middleware stack - Al...
 
Web application development using Play Framework (with Java)
Web application development using Play Framework (with Java)Web application development using Play Framework (with Java)
Web application development using Play Framework (with Java)
 
ASP.NET: Present and future
ASP.NET: Present and futureASP.NET: Present and future
ASP.NET: Present and future
 
Introduction to Shield and kibana
Introduction to Shield and kibanaIntroduction to Shield and kibana
Introduction to Shield and kibana
 
AWS Primer and Quickstart
AWS Primer and QuickstartAWS Primer and Quickstart
AWS Primer and Quickstart
 
Flask jwt authentication tutorial
Flask jwt authentication tutorialFlask jwt authentication tutorial
Flask jwt authentication tutorial
 
Node js for enterprise
Node js for enterpriseNode js for enterprise
Node js for enterprise
 
Server Sent Events, Async Servlet, Web Sockets and JSON; born to work together!
Server Sent Events, Async Servlet, Web Sockets and JSON; born to work together!Server Sent Events, Async Servlet, Web Sockets and JSON; born to work together!
Server Sent Events, Async Servlet, Web Sockets and JSON; born to work together!
 

Similar to Securing Microservices using Play and Akka HTTP

Security Architecture Consulting - Hiren Shah
Security Architecture Consulting - Hiren ShahSecurity Architecture Consulting - Hiren Shah
Security Architecture Consulting - Hiren Shah
NSConclave
 
[2019.1] 하이퍼레저 패브릭 v1.3, v1.4 새로운 기능
[2019.1] 하이퍼레저 패브릭 v1.3, v1.4 새로운 기능[2019.1] 하이퍼레저 패브릭 v1.3, v1.4 새로운 기능
[2019.1] 하이퍼레저 패브릭 v1.3, v1.4 새로운 기능
Hyperledger Korea User Group
 
Securing your Pulsar Cluster with Vault_Chris Kellogg
Securing your Pulsar Cluster with Vault_Chris KelloggSecuring your Pulsar Cluster with Vault_Chris Kellogg
Securing your Pulsar Cluster with Vault_Chris Kellogg
StreamNative
 
Spring4 security
Spring4 securitySpring4 security
Spring4 security
Sang Shin
 
Intro to Apache Shiro
Intro to Apache ShiroIntro to Apache Shiro
Intro to Apache Shiro
Claire Hunsaker
 
Super simple application security with Apache Shiro
Super simple application security with Apache ShiroSuper simple application security with Apache Shiro
Super simple application security with Apache Shiro
Marakana Inc.
 
Windows 8 Apps and the Outside World
Windows 8 Apps and the Outside WorldWindows 8 Apps and the Outside World
Top Ten Java Defense for Web Applications v2
Top Ten Java Defense for Web Applications v2Top Ten Java Defense for Web Applications v2
Top Ten Java Defense for Web Applications v2
Jim Manico
 
Managing your secrets in a cloud environment
Managing your secrets in a cloud environmentManaging your secrets in a cloud environment
Managing your secrets in a cloud environment
Taswar Bhatti
 
Security DevOps - Free pentesters' time to focus on high-hanging fruits // Ha...
Security DevOps - Free pentesters' time to focus on high-hanging fruits // Ha...Security DevOps - Free pentesters' time to focus on high-hanging fruits // Ha...
Security DevOps - Free pentesters' time to focus on high-hanging fruits // Ha...
Christian Schneider
 
Rails Security
Rails SecurityRails Security
Rails Security
Wen-Tien Chang
 
Aplicaciones distribuidas con Dapr
Aplicaciones distribuidas con DaprAplicaciones distribuidas con Dapr
Aplicaciones distribuidas con Dapr
César Jesús Angulo Gasco
 
Using Apache as an Application Server
Using Apache as an Application ServerUsing Apache as an Application Server
Using Apache as an Application Server
Phil Windley
 
Dynamic Database Credentials: Security Contingency Planning
Dynamic Database Credentials: Security Contingency PlanningDynamic Database Credentials: Security Contingency Planning
Dynamic Database Credentials: Security Contingency Planning
Sean Chittenden
 
Developing your first application using FIWARE
Developing your first application using FIWAREDeveloping your first application using FIWARE
Developing your first application using FIWARE
FIWARE
 
4aa5 3404
4aa5 34044aa5 3404
4aa5 3404
Bloombase
 
Groovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentationGroovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentation
Stuart (Pid) Williams
 
Hyperleger Composer Architecure Deep Dive
Hyperleger Composer Architecure Deep DiveHyperleger Composer Architecure Deep Dive
Hyperleger Composer Architecure Deep Dive
Dan Selman
 
Spa Secure Coding Guide
Spa Secure Coding GuideSpa Secure Coding Guide
Spa Secure Coding Guide
Geoffrey Vandiest
 
Struts 2 - Introduction
Struts 2 - Introduction Struts 2 - Introduction
Struts 2 - Introduction
Hitesh-Java
 

Similar to Securing Microservices using Play and Akka HTTP (20)

Security Architecture Consulting - Hiren Shah
Security Architecture Consulting - Hiren ShahSecurity Architecture Consulting - Hiren Shah
Security Architecture Consulting - Hiren Shah
 
[2019.1] 하이퍼레저 패브릭 v1.3, v1.4 새로운 기능
[2019.1] 하이퍼레저 패브릭 v1.3, v1.4 새로운 기능[2019.1] 하이퍼레저 패브릭 v1.3, v1.4 새로운 기능
[2019.1] 하이퍼레저 패브릭 v1.3, v1.4 새로운 기능
 
Securing your Pulsar Cluster with Vault_Chris Kellogg
Securing your Pulsar Cluster with Vault_Chris KelloggSecuring your Pulsar Cluster with Vault_Chris Kellogg
Securing your Pulsar Cluster with Vault_Chris Kellogg
 
Spring4 security
Spring4 securitySpring4 security
Spring4 security
 
Intro to Apache Shiro
Intro to Apache ShiroIntro to Apache Shiro
Intro to Apache Shiro
 
Super simple application security with Apache Shiro
Super simple application security with Apache ShiroSuper simple application security with Apache Shiro
Super simple application security with Apache Shiro
 
Windows 8 Apps and the Outside World
Windows 8 Apps and the Outside WorldWindows 8 Apps and the Outside World
Windows 8 Apps and the Outside World
 
Top Ten Java Defense for Web Applications v2
Top Ten Java Defense for Web Applications v2Top Ten Java Defense for Web Applications v2
Top Ten Java Defense for Web Applications v2
 
Managing your secrets in a cloud environment
Managing your secrets in a cloud environmentManaging your secrets in a cloud environment
Managing your secrets in a cloud environment
 
Security DevOps - Free pentesters' time to focus on high-hanging fruits // Ha...
Security DevOps - Free pentesters' time to focus on high-hanging fruits // Ha...Security DevOps - Free pentesters' time to focus on high-hanging fruits // Ha...
Security DevOps - Free pentesters' time to focus on high-hanging fruits // Ha...
 
Rails Security
Rails SecurityRails Security
Rails Security
 
Aplicaciones distribuidas con Dapr
Aplicaciones distribuidas con DaprAplicaciones distribuidas con Dapr
Aplicaciones distribuidas con Dapr
 
Using Apache as an Application Server
Using Apache as an Application ServerUsing Apache as an Application Server
Using Apache as an Application Server
 
Dynamic Database Credentials: Security Contingency Planning
Dynamic Database Credentials: Security Contingency PlanningDynamic Database Credentials: Security Contingency Planning
Dynamic Database Credentials: Security Contingency Planning
 
Developing your first application using FIWARE
Developing your first application using FIWAREDeveloping your first application using FIWARE
Developing your first application using FIWARE
 
4aa5 3404
4aa5 34044aa5 3404
4aa5 3404
 
Groovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentationGroovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentation
 
Hyperleger Composer Architecure Deep Dive
Hyperleger Composer Architecure Deep DiveHyperleger Composer Architecure Deep Dive
Hyperleger Composer Architecure Deep Dive
 
Spa Secure Coding Guide
Spa Secure Coding GuideSpa Secure Coding Guide
Spa Secure Coding Guide
 
Struts 2 - Introduction
Struts 2 - Introduction Struts 2 - Introduction
Struts 2 - Introduction
 

Recently uploaded

How to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptxHow to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptx
Adam Dunkels
 
How RPA Help in the Transportation and Logistics Industry.pptx
How RPA Help in the Transportation and Logistics Industry.pptxHow RPA Help in the Transportation and Logistics Industry.pptx
How RPA Help in the Transportation and Logistics Industry.pptx
SynapseIndia
 
Cookies program to display the information though cookie creation
Cookies program to display the information though cookie creationCookies program to display the information though cookie creation
Cookies program to display the information though cookie creation
shanthidl1
 
Manual | Product | Research Presentation
Manual | Product | Research PresentationManual | Product | Research Presentation
Manual | Product | Research Presentation
welrejdoall
 
Coordinate Systems in FME 101 - Webinar Slides
Coordinate Systems in FME 101 - Webinar SlidesCoordinate Systems in FME 101 - Webinar Slides
Coordinate Systems in FME 101 - Webinar Slides
Safe Software
 
The Increasing Use of the National Research Platform by the CSU Campuses
The Increasing Use of the National Research Platform by the CSU CampusesThe Increasing Use of the National Research Platform by the CSU Campuses
The Increasing Use of the National Research Platform by the CSU Campuses
Larry Smarr
 
Best Practices for Effectively Running dbt in Airflow.pdf
Best Practices for Effectively Running dbt in Airflow.pdfBest Practices for Effectively Running dbt in Airflow.pdf
Best Practices for Effectively Running dbt in Airflow.pdf
Tatiana Al-Chueyr
 
Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...
Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...
Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...
Chris Swan
 
Mitigating the Impact of State Management in Cloud Stream Processing Systems
Mitigating the Impact of State Management in Cloud Stream Processing SystemsMitigating the Impact of State Management in Cloud Stream Processing Systems
Mitigating the Impact of State Management in Cloud Stream Processing Systems
ScyllaDB
 
Details of description part II: Describing images in practice - Tech Forum 2024
Details of description part II: Describing images in practice - Tech Forum 2024Details of description part II: Describing images in practice - Tech Forum 2024
Details of description part II: Describing images in practice - Tech Forum 2024
BookNet Canada
 
20240702 Présentation Plateforme GenAI.pdf
20240702 Présentation Plateforme GenAI.pdf20240702 Présentation Plateforme GenAI.pdf
20240702 Présentation Plateforme GenAI.pdf
Sally Laouacheria
 
How Social Media Hackers Help You to See Your Wife's Message.pdf
How Social Media Hackers Help You to See Your Wife's Message.pdfHow Social Media Hackers Help You to See Your Wife's Message.pdf
How Social Media Hackers Help You to See Your Wife's Message.pdf
HackersList
 
WPRiders Company Presentation Slide Deck
WPRiders Company Presentation Slide DeckWPRiders Company Presentation Slide Deck
WPRiders Company Presentation Slide Deck
Lidia A.
 
DealBook of Ukraine: 2024 edition
DealBook of Ukraine: 2024 editionDealBook of Ukraine: 2024 edition
DealBook of Ukraine: 2024 edition
Yevgen Sysoyev
 
UiPath Community Day Kraków: Devs4Devs Conference
UiPath Community Day Kraków: Devs4Devs ConferenceUiPath Community Day Kraków: Devs4Devs Conference
UiPath Community Day Kraków: Devs4Devs Conference
UiPathCommunity
 
Recent Advancements in the NIST-JARVIS Infrastructure
Recent Advancements in the NIST-JARVIS InfrastructureRecent Advancements in the NIST-JARVIS Infrastructure
Recent Advancements in the NIST-JARVIS Infrastructure
KAMAL CHOUDHARY
 
The Rise of Supernetwork Data Intensive Computing
The Rise of Supernetwork Data Intensive ComputingThe Rise of Supernetwork Data Intensive Computing
The Rise of Supernetwork Data Intensive Computing
Larry Smarr
 
20240704 QFM023 Engineering Leadership Reading List June 2024
20240704 QFM023 Engineering Leadership Reading List June 202420240704 QFM023 Engineering Leadership Reading List June 2024
20240704 QFM023 Engineering Leadership Reading List June 2024
Matthew Sinclair
 
Quality Patents: Patents That Stand the Test of Time
Quality Patents: Patents That Stand the Test of TimeQuality Patents: Patents That Stand the Test of Time
Quality Patents: Patents That Stand the Test of Time
Aurora Consulting
 
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptxRPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
SynapseIndia
 

Recently uploaded (20)

How to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptxHow to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptx
 
How RPA Help in the Transportation and Logistics Industry.pptx
How RPA Help in the Transportation and Logistics Industry.pptxHow RPA Help in the Transportation and Logistics Industry.pptx
How RPA Help in the Transportation and Logistics Industry.pptx
 
Cookies program to display the information though cookie creation
Cookies program to display the information though cookie creationCookies program to display the information though cookie creation
Cookies program to display the information though cookie creation
 
Manual | Product | Research Presentation
Manual | Product | Research PresentationManual | Product | Research Presentation
Manual | Product | Research Presentation
 
Coordinate Systems in FME 101 - Webinar Slides
Coordinate Systems in FME 101 - Webinar SlidesCoordinate Systems in FME 101 - Webinar Slides
Coordinate Systems in FME 101 - Webinar Slides
 
The Increasing Use of the National Research Platform by the CSU Campuses
The Increasing Use of the National Research Platform by the CSU CampusesThe Increasing Use of the National Research Platform by the CSU Campuses
The Increasing Use of the National Research Platform by the CSU Campuses
 
Best Practices for Effectively Running dbt in Airflow.pdf
Best Practices for Effectively Running dbt in Airflow.pdfBest Practices for Effectively Running dbt in Airflow.pdf
Best Practices for Effectively Running dbt in Airflow.pdf
 
Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...
Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...
Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...
 
Mitigating the Impact of State Management in Cloud Stream Processing Systems
Mitigating the Impact of State Management in Cloud Stream Processing SystemsMitigating the Impact of State Management in Cloud Stream Processing Systems
Mitigating the Impact of State Management in Cloud Stream Processing Systems
 
Details of description part II: Describing images in practice - Tech Forum 2024
Details of description part II: Describing images in practice - Tech Forum 2024Details of description part II: Describing images in practice - Tech Forum 2024
Details of description part II: Describing images in practice - Tech Forum 2024
 
20240702 Présentation Plateforme GenAI.pdf
20240702 Présentation Plateforme GenAI.pdf20240702 Présentation Plateforme GenAI.pdf
20240702 Présentation Plateforme GenAI.pdf
 
How Social Media Hackers Help You to See Your Wife's Message.pdf
How Social Media Hackers Help You to See Your Wife's Message.pdfHow Social Media Hackers Help You to See Your Wife's Message.pdf
How Social Media Hackers Help You to See Your Wife's Message.pdf
 
WPRiders Company Presentation Slide Deck
WPRiders Company Presentation Slide DeckWPRiders Company Presentation Slide Deck
WPRiders Company Presentation Slide Deck
 
DealBook of Ukraine: 2024 edition
DealBook of Ukraine: 2024 editionDealBook of Ukraine: 2024 edition
DealBook of Ukraine: 2024 edition
 
UiPath Community Day Kraków: Devs4Devs Conference
UiPath Community Day Kraków: Devs4Devs ConferenceUiPath Community Day Kraków: Devs4Devs Conference
UiPath Community Day Kraków: Devs4Devs Conference
 
Recent Advancements in the NIST-JARVIS Infrastructure
Recent Advancements in the NIST-JARVIS InfrastructureRecent Advancements in the NIST-JARVIS Infrastructure
Recent Advancements in the NIST-JARVIS Infrastructure
 
The Rise of Supernetwork Data Intensive Computing
The Rise of Supernetwork Data Intensive ComputingThe Rise of Supernetwork Data Intensive Computing
The Rise of Supernetwork Data Intensive Computing
 
20240704 QFM023 Engineering Leadership Reading List June 2024
20240704 QFM023 Engineering Leadership Reading List June 202420240704 QFM023 Engineering Leadership Reading List June 2024
20240704 QFM023 Engineering Leadership Reading List June 2024
 
Quality Patents: Patents That Stand the Test of Time
Quality Patents: Patents That Stand the Test of TimeQuality Patents: Patents That Stand the Test of Time
Quality Patents: Patents That Stand the Test of Time
 
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptxRPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
 

Securing Microservices using Play and Akka HTTP

  • 1. Securing Microservices using Play and Akka HTTP Rafal Gancarz @RafalGancarz 1
  • 2. About me • Lead Consultant at OpenCredo • Helping companies transform their IT platforms and the ways their do business • Technologist, architect, developer • Agile practitioner & evangelist • Scala <- Java <- PHP 2
  • 3. (Micro)services • SOA reloaded • Lightweight, open standards • Loosely coupled, self-contained • Independent and scalable • Bounded context (part of business domain) 3
  • 4. Securing the monolith DB authentication Pros • single entry point • limited attack surface • centralised authentication & authorisation Cons • totally exposed when compromised 4
  • 5. Securing the monolith - considerations • Combined presentation and business logic tier • End user login • Session based authentication • Single sign-on (usually with SAML) 5
  • 6. Securing microservices (first take) DB Pros • siloed data Cons • large attack surface • multiple auth enforcement points • shared auth data storeDB DB 6
  • 7. • Who is the consumer (the end user vs the third-party system)? • Is user context relevant? • access control granularity • act on behalf • What are the security related requirements? • highly sensitive data • integration over public internet • social login • single sign-on (SSO) Securing microservices - considerations 7
  • 8. • What are commercial requirements for your project? • time to market • availability of skills / expertise • buy vs build • What about the legacy? • existing security implementation • interoperability with the legacy platform Securing microservices - considerations 8
  • 9. API gateway DB DB DB API gateway Pros • single point of entry • limited surface attack • configurable authentication protocols and backends • faster time to market • gateway availability/scalability Cons • additional cost • services unsecured internally • HTTP level access control • limited auth context 9
  • 10. HTTP basic auth + client id&secret DB DB DB Pros • easy • good for third-party integration • stateless Cons • requires TLS • doesn’t expire • difficult to enforce at scale (unless used with API gateway) client_id client_secret 10
  • 11. Play Framework • Basic HTTP auth with HTTP filter • Basic HTTP auth with Action builder • Play2.x Authentication and Authorization module (https://github.com/t2v/play2-auth) • Pac4j module (https://github.com/leleuj/play-pac4j) • Secure Social module (http://securesocial.ws/) • Silhouette module (http://silhouette.mohiva.com/) 11
  • 12. Akka HTTP • authenticateBasicX directives • http://doc.akka.io/docs/akka-stream-and-http-experimental/2.0-M2/scala/http/routing-dsl/directives/ security-directives/authenticateBasic.html#authenticatebasic def myUserPassAuthenticator(credentials: Credentials): Future[Option[String]] = credentials match { case p @ Credentials.Provided(id) => Future { // potentially if (p.verify("s3cr3t")) Some(id) else None } case _ => Future.successful(None) } val route = Route.seal { path("secured") { authenticateBasicAsync(realm = "secure site", myUserPassAuthenticator) { userName => complete(s"The user is '$userName'") } } } 12
  • 13. OAuth2+OpenID Connect DB DB DB Auth Server Pros • standard based • popular for social login & delegated authorisation • caters for browser, mobile and server-to-server use cases • token expiry Cons • requires TLS • requires Authorisation Server • developed initially as authorisation framework • numerous flavours used • non-trivial to get right • authentication impl out of scope 13
  • 14. Play Framework • Pac4j module (https://github.com/leleuj/play-pac4j) - supports OAuth2, OAuth2 and OpenID • Secure Social module (http://securesocial.ws/) - supports OAuth1 and OAuth2 • Silhouette module (http://silhouette.mohiva.com/) - supports OAuth1, OAuth2 and OpenID 14
  • 15. Akka HTTP • authenticateOAuth2X directives • http://doc.akka.io/docs/akka-stream-and-http-experimental/2.0-M2/scala/http/ routing-dsl/directives/security-directives/ authenticateOAuth2.html#authenticateoauth2 def authenticateOAuth2[T](realm: String, authenticator: Authenticator[T]): AuthenticationDirective[T] Usage the same as HTTP basic but requires validating access token retrieved from the header (not supported natively). 15
  • 16. OpenID Connect • Nimbus (https://bitbucket.org/connect2id/ oauth-2.0-sdk-with-openid-connect-extensions) • Apache Oltu (https://oltu.apache.org/) https://openid.net/developers/specs/ 16
  • 17. JSON Web Token DB DB DB Auth Server Pros • auth claims can be signed (HMAC or RSA) • compact (suitable for URLs, headers, query params) • self-contained, stateless • excellent SAML alternative for SSO Cons • requires TLS or encryption • authentication impl out of scope http://jwt.io/ 17
  • 18. JSON Web Token • No built-in support in Play or Akka HTTP • authentikat-jwt (https://github.com/jasongoodwin/ authentikat-jwt) - Scala • iain-logan/jwt (https://github.com/iain-logan/jwt) - Scala • jose4j (https://bitbucket.org/b_c/jose4j/wiki/Home) - Java • jjwt (https://github.com/jwtk/jjwt) - Java 18
  • 19. Mutually authenticated TLS DB DB DB Pros • strong point to point security Cons • requires PKI • key management and distribution challenging • difficult to implement and troubleshoot • no user context mTLS 19
  • 20. Play Framework - server-side • https://www.playframework.com/documentation/2.4.x/ConfiguringHttps class CustomSSLEngineProvider(appProvider: ApplicationProvider) extends SSLEngineProvider { def createSSLContext(applicationProvider: ApplicationProvider): SSLContext = {
 val keyManagers = readKeyManagers()
 val trustManagers = readTrustManagers()
 
 val sslContext = SSLContext.getInstance("TLS")
 sslContext.init(keyManagers, trustManagers, null)
 sslContext
 } override def createSSLEngine(): SSLEngine = { val sslContext = createSSLContext(appProvider) val sslParameters = sslContext.getDefaultSSLParameters sslParameters.setUseCipherSuitesOrder(true) sslParameters.setNeedClientAuth(true) val engine = sslContext.createSSLEngine
 engine.setSSLParameters(sslParameters) engine } } 20
  • 21. Akka HTTP - server-side • http://doc.akka.io/docs/akka-stream-and-http-experimental/2.0- M2/scala/http/low-level-server-side-api.html#serversidehttps def createSSLContext(): SSLContext = {
 val keyManagers = readKeyManagers()
 val trustManagers = readTrustManagers()
 
 val sslContext = SSLContext.getInstance("TLS")
 sslContext.init(keyManagers, trustManagers, null)
 sslContext
 }
 
 def run() = {
 
 implicit val system = ActorSystem("server")
 implicit val materializer = ActorMaterializer()
 
 val sslContext = createSSLContext()
 
 val serverSource = Http().bind(interface = "localhost", port = 8200, ServerSettings(system), Some(HttpsContext(sslContext, Some(immutable.Seq("TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384")), Some(immutable.Seq("TLSv1.2")), Some(Need), Some(sslContext.getDefaultSSLParameters))))
 
 …
 
 } 21
  • 22. Authorisation • At the perimeter or within the business logic? • Where user roles/permissions are coming from (each bounded context might have different access control considerations)? • How is the user context passed into the service? 22
  • 23. Play Framework • Authorisation with HTTP filter • Authorisation with Action builder • Deadbolt (http://deadbolt.ws/#/home) - works with Silhouette and SecureSocial for authentication 23
  • 24. Akka HTTP • authorize directive • http://doc.akka.io/docs/akka-stream-and-http-experimental/2.0-M2/scala/http/routing-dsl/ directives/security-directives/authorize.html#authorize case class User(name: String) val admins = Set("Peter") def hasAdminPermissions(user: User): Boolean = admins.contains(user.name) val route = Route.seal { authenticateBasic(realm = "secure site", myUserPassAuthenticator) { user => path("peters-lair") { authorize(hasAdminPermissions(user)) { complete(s"'${user.name}' visited Peter's lair") } } } } 24
  • 25. Key takeaways • Securing microservice based architectures is challenging • The technology landscape changes all the time • One size (solution) doesn’t fit all • Consider your requirements before committing to a technical solution 25
  • 26. Questions? • Email: rafal.gancarz@opencredo.com • Twitter: @RafalGancarz • See me tomorrow at lunchtime for a Q&A session on Securing Microservices using Play and Akka HTTP • Visit OpenCredo’s booth tomorrow and enter a draw to win Apple Watch! • See you at the Scala Exchange party later :) • Thank you! 26