SlideShare ist ein Scribd-Unternehmen logo
1 von 11
Security is a Matter of
Success
Dino Esposito
Digital Strategist, BaxEnergy
AUTHENTICATION
▰ Cookie-based authentication (without web.config)
▰ IPrincipal based on claims (not just username)
▰ Enable authentication middleware and use it
▻ Cookie name, login path, return-url, sliding expiration
▰ Multiple authentication schemes supported
▻ Cookie, bearer token, social networks
2
AUTHENTICATION: CLAIMS
▰ All claims stored in the authentication item
(cookie)
▰ Information not retrieved but possibly in the need
of updates if changed
▰ Username and role, plus everything else
▰ Different API for sign-in/sign-out
▰ LINQ-style API to read claims
3
AUTHORIZATION
▰ Role-based authorization
▻ Authorize attribute working as usual
▰ Policy-based authorization
▻ New in ASP.NET Core
4
ROLE-BASED AUTHORIZATION
▰ AllowAnonymous
▰ Authorize(Roles="...")
▰ Custom version EnsureRole(Enum1, Enum2)
▰ Additional ActiveAuthenticationScheme parameter
5
POLICY-BASED AUTHORIZATION
▰ Policy is a collection of requirements
▰ More flexible than just roles
▰ Register policies in startup
▰ Apply through Policy attribute of Authorize
6
var policy = new AuthorizationPolicyBuilder()
.AddAuthenticationScheme("Cookie", "Bearer")
.RequireAuthenticatedUser()
.RequireRole("Admin")
.RequireClaim("editor", "contents")
.RequireClaim("level", "Senior")
.Build();
POLICY-BASED AUTHORIZATION
8
// IAuthorizationService injected in controller
public async Task<IActionResult> Save(Article article)
{
var allowed = await _authorization.AuthorizeAsync(User, ...);
if (!allowed)
return new ForbiddenResult();
// Proceed
}
SECURING WEB API
▰ Authorize works as long as cookies are OK
▰ Basic authentication
▻ User credentials packed with request
▰ Token-based authentication
▻ Token associated with a given user
▰ Identity Management Server
9
MURPHY LAW OF API DESIGNERS
PROGRAMMING ASP.NET CORE
▰ ASP.NET Core 3.0 released in H2
▻ Wait for 3.1 though 
▰ Visual Studio 2019 Update X
11
http://youbiquitous.net

Weitere ähnliche Inhalte

Mehr von Fwdays

Mehr von Fwdays (20)

"Distributed graphs and microservices in Prom.ua", Maksym Kindritskyi
"Distributed graphs and microservices in Prom.ua",  Maksym Kindritskyi"Distributed graphs and microservices in Prom.ua",  Maksym Kindritskyi
"Distributed graphs and microservices in Prom.ua", Maksym Kindritskyi
 
"Rethinking the existing data loading and processing process as an ETL exampl...
"Rethinking the existing data loading and processing process as an ETL exampl..."Rethinking the existing data loading and processing process as an ETL exampl...
"Rethinking the existing data loading and processing process as an ETL exampl...
 
"How Ukrainian IT specialist can go on vacation abroad without crossing the T...
"How Ukrainian IT specialist can go on vacation abroad without crossing the T..."How Ukrainian IT specialist can go on vacation abroad without crossing the T...
"How Ukrainian IT specialist can go on vacation abroad without crossing the T...
 
"The Strength of Being Vulnerable: the experience from CIA, Tesla and Uber", ...
"The Strength of Being Vulnerable: the experience from CIA, Tesla and Uber", ..."The Strength of Being Vulnerable: the experience from CIA, Tesla and Uber", ...
"The Strength of Being Vulnerable: the experience from CIA, Tesla and Uber", ...
 
"[QUICK TALK] Radical candor: how to achieve results faster thanks to a cultu...
"[QUICK TALK] Radical candor: how to achieve results faster thanks to a cultu..."[QUICK TALK] Radical candor: how to achieve results faster thanks to a cultu...
"[QUICK TALK] Radical candor: how to achieve results faster thanks to a cultu...
 
"[QUICK TALK] PDP Plan, the only one door to raise your salary and boost care...
"[QUICK TALK] PDP Plan, the only one door to raise your salary and boost care..."[QUICK TALK] PDP Plan, the only one door to raise your salary and boost care...
"[QUICK TALK] PDP Plan, the only one door to raise your salary and boost care...
 
"4 horsemen of the apocalypse of working relationships (+ antidotes to them)"...
"4 horsemen of the apocalypse of working relationships (+ antidotes to them)"..."4 horsemen of the apocalypse of working relationships (+ antidotes to them)"...
"4 horsemen of the apocalypse of working relationships (+ antidotes to them)"...
 
"Reconnecting with Purpose: Rediscovering Job Interest after Burnout", Anast...
"Reconnecting with Purpose: Rediscovering Job Interest after Burnout",  Anast..."Reconnecting with Purpose: Rediscovering Job Interest after Burnout",  Anast...
"Reconnecting with Purpose: Rediscovering Job Interest after Burnout", Anast...
 
"Mentoring 101: How to effectively invest experience in the success of others...
"Mentoring 101: How to effectively invest experience in the success of others..."Mentoring 101: How to effectively invest experience in the success of others...
"Mentoring 101: How to effectively invest experience in the success of others...
 
"Mission (im) possible: How to get an offer in 2024?", Oleksandra Myronova
"Mission (im) possible: How to get an offer in 2024?",  Oleksandra Myronova"Mission (im) possible: How to get an offer in 2024?",  Oleksandra Myronova
"Mission (im) possible: How to get an offer in 2024?", Oleksandra Myronova
 
"Why have we learned how to package products, but not how to 'package ourselv...
"Why have we learned how to package products, but not how to 'package ourselv..."Why have we learned how to package products, but not how to 'package ourselv...
"Why have we learned how to package products, but not how to 'package ourselv...
 
"How to tame the dragon, or leadership with imposter syndrome", Oleksandr Zin...
"How to tame the dragon, or leadership with imposter syndrome", Oleksandr Zin..."How to tame the dragon, or leadership with imposter syndrome", Oleksandr Zin...
"How to tame the dragon, or leadership with imposter syndrome", Oleksandr Zin...
 
"Leadership, Soft Skills, and Personality Types for IT teams", Sergiy Tytenko
"Leadership, Soft Skills, and Personality Types for IT teams",  Sergiy Tytenko"Leadership, Soft Skills, and Personality Types for IT teams",  Sergiy Tytenko
"Leadership, Soft Skills, and Personality Types for IT teams", Sergiy Tytenko
 
"How Ukrainian IT specialist can go on vacation abroad without crossing the T...
"How Ukrainian IT specialist can go on vacation abroad without crossing the T..."How Ukrainian IT specialist can go on vacation abroad without crossing the T...
"How Ukrainian IT specialist can go on vacation abroad without crossing the T...
 
"Mastering cross-cultural communication", Anna Gandrabura
"Mastering cross-cultural communication", Anna Gandrabura"Mastering cross-cultural communication", Anna Gandrabura
"Mastering cross-cultural communication", Anna Gandrabura
 
"Incremental rollouts and rollbacks with business metrics control at every st...
"Incremental rollouts and rollbacks with business metrics control at every st..."Incremental rollouts and rollbacks with business metrics control at every st...
"Incremental rollouts and rollbacks with business metrics control at every st...
 
"AIRe - AI Reliability Engineering", Denys Vasyliev
"AIRe - AI Reliability Engineering", Denys Vasyliev"AIRe - AI Reliability Engineering", Denys Vasyliev
"AIRe - AI Reliability Engineering", Denys Vasyliev
 
"Testing of Helm Charts or There and Back Again", Yura Rochniak
"Testing of Helm Charts or There and Back Again", Yura Rochniak"Testing of Helm Charts or There and Back Again", Yura Rochniak
"Testing of Helm Charts or There and Back Again", Yura Rochniak
 
"How to mentor (future) devops engineers", Vsevolod Polyakov
"How to mentor (future) devops engineers",  Vsevolod Polyakov"How to mentor (future) devops engineers",  Vsevolod Polyakov
"How to mentor (future) devops engineers", Vsevolod Polyakov
 
"Running Open-Source LLM models on Kubernetes", Volodymyr Tsap
"Running Open-Source LLM models on Kubernetes",  Volodymyr Tsap"Running Open-Source LLM models on Kubernetes",  Volodymyr Tsap
"Running Open-Source LLM models on Kubernetes", Volodymyr Tsap
 

Kürzlich hochgeladen

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Kürzlich hochgeladen (20)

Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 

Dino Esposito "Security is a matter of success"

  • 1. Security is a Matter of Success Dino Esposito Digital Strategist, BaxEnergy
  • 2. AUTHENTICATION ▰ Cookie-based authentication (without web.config) ▰ IPrincipal based on claims (not just username) ▰ Enable authentication middleware and use it ▻ Cookie name, login path, return-url, sliding expiration ▰ Multiple authentication schemes supported ▻ Cookie, bearer token, social networks 2
  • 3. AUTHENTICATION: CLAIMS ▰ All claims stored in the authentication item (cookie) ▰ Information not retrieved but possibly in the need of updates if changed ▰ Username and role, plus everything else ▰ Different API for sign-in/sign-out ▰ LINQ-style API to read claims 3
  • 4. AUTHORIZATION ▰ Role-based authorization ▻ Authorize attribute working as usual ▰ Policy-based authorization ▻ New in ASP.NET Core 4
  • 5. ROLE-BASED AUTHORIZATION ▰ AllowAnonymous ▰ Authorize(Roles="...") ▰ Custom version EnsureRole(Enum1, Enum2) ▰ Additional ActiveAuthenticationScheme parameter 5
  • 6. POLICY-BASED AUTHORIZATION ▰ Policy is a collection of requirements ▰ More flexible than just roles ▰ Register policies in startup ▰ Apply through Policy attribute of Authorize 6
  • 7. var policy = new AuthorizationPolicyBuilder() .AddAuthenticationScheme("Cookie", "Bearer") .RequireAuthenticatedUser() .RequireRole("Admin") .RequireClaim("editor", "contents") .RequireClaim("level", "Senior") .Build();
  • 8. POLICY-BASED AUTHORIZATION 8 // IAuthorizationService injected in controller public async Task<IActionResult> Save(Article article) { var allowed = await _authorization.AuthorizeAsync(User, ...); if (!allowed) return new ForbiddenResult(); // Proceed }
  • 9. SECURING WEB API ▰ Authorize works as long as cookies are OK ▰ Basic authentication ▻ User credentials packed with request ▰ Token-based authentication ▻ Token associated with a given user ▰ Identity Management Server 9
  • 10. MURPHY LAW OF API DESIGNERS
  • 11. PROGRAMMING ASP.NET CORE ▰ ASP.NET Core 3.0 released in H2 ▻ Wait for 3.1 though  ▰ Visual Studio 2019 Update X 11 http://youbiquitous.net