SlideShare ist ein Scribd-Unternehmen logo
1 von 23
Emad Alashi
• Senior Developer at Readify
• ASP.NET/IIS MVP
• www.DotNetArabi.com
• www.EmadAshi.com
• @emadashi

1
OAuth 2.0 & .NET
Live with others

2
Pre-OAuth era
(Yeah, History!)

3
Images

data

Resources

email

Username & password
Username & password

Etc.

Username & password

Username & password

Username & password

4
Facebook Auth

Flickr API

Yahoo BBAuth

Web Services

Google AuthSub
5
6
So how does it work?

7
Resource owner

Authorization Server

Authorization/Resources Server

Client

Resource Server

8
myPodcast.com
302 to fb.com/auth? data

auth? clientID & scope & redirectUri=myPD.com/signin

This app wants…are you sure?
Yes please, allow
myPD.com/signin? code & scope

302 to myPD.com/signin? data

Welcome 

fb.com/auth? clientId & code & redirectUri

accessToken & tokenType & expires & refreshToken
11
OAuth in MVC 4
DotNetOpenAuth
&
OAuthWebSecurity

12
OAuth in MVC 5

OWIN

13
owin.org

14
OWIN (Open Web Interface for .NET)

15
OWIN with IIS

16
Middleware 1
Invoke(IOwinContext con)
{
DoINeedToAlterRequest?
{
}

Middleware 2
Middleware 3

AllowSubsequentMiddleWares?
{
base.Next.Invoke(con);
}

NeedToAlterResponse?
{
}
}

17
Authentication middleware

18
Authentication middleware

Application

Invoke

ApplyResponseGrant

AuthenticateCoreAsync

ApplyResponseChallenge

19
Facebook example

20
Cookies middleware

Facebook
middleware

Application

Post: myPd.com/Account/Login(Facebook)
302 to Fb.com/oauth?redirectUri=signin-facebook
ApplyResponseChallenge

302 to fb.com/oauth

401 (facebook)

Get: myPd.com/signin-facebook?code=djlsjjce

AuthenticateCoreAsync
---Create Idnetity
302 to Account/External

302 to myPD.com/Account/External

Get: Account/External

ApplyResponseGrant
-----wrap claims in App ticket
Create cookie
SignInExternal
---Create Idnetity

21
Oauth Server mid.

/auth?clientId&Response_Type
/token?code=tyggyug

redirectUri?token=uhuihuhkn

aPage
AuthHead: Bearer ygugjygj

Invoke
--validations

Oauth Auth mid.

signIn

Application

signIn

ApplyResponseGrant

AuthenticateCoreAsync

22
Microsoft.Owin.Security.Infrastructure
AuthenticationMiddleware

AuthenticationHandler

• Constructor
• CreateHandler

•
•
•
•

AuthenticateCoreAsync
InvokeAsync
ApplyResponseGrantAsync
ApplyResponseChallengeAsync

23
Authentication Middleware
• Facebook
• Google
• Twitter
• OAuth
• Server
• Authentication

24
Q&A
Emad.ashi@gmail

@EmadAshi

25

Weitere ähnliche Inhalte

Was ist angesagt?

Oauth2 and OWSM OAuth2 support
Oauth2 and OWSM OAuth2 supportOauth2 and OWSM OAuth2 support
Oauth2 and OWSM OAuth2 support
Gaurav Sharma
 
Mohanraj - Securing Your Web Api With OAuth
Mohanraj - Securing Your Web Api With OAuthMohanraj - Securing Your Web Api With OAuth
Mohanraj - Securing Your Web Api With OAuth
fossmy
 

Was ist angesagt? (20)

Intro to API Security with Oauth 2.0
Intro to API Security with Oauth 2.0Intro to API Security with Oauth 2.0
Intro to API Security with Oauth 2.0
 
OAuth2 - Introduction
OAuth2 - IntroductionOAuth2 - Introduction
OAuth2 - Introduction
 
OAuth 2
OAuth 2OAuth 2
OAuth 2
 
The State of OAuth2
The State of OAuth2The State of OAuth2
The State of OAuth2
 
OAuth 2.0 and Mobile Devices: Is that a token in your phone in your pocket or...
OAuth 2.0 and Mobile Devices: Is that a token in your phone in your pocket or...OAuth 2.0 and Mobile Devices: Is that a token in your phone in your pocket or...
OAuth 2.0 and Mobile Devices: Is that a token in your phone in your pocket or...
 
Oauth2 and OWSM OAuth2 support
Oauth2 and OWSM OAuth2 supportOauth2 and OWSM OAuth2 support
Oauth2 and OWSM OAuth2 support
 
Oauth 2.0
Oauth 2.0Oauth 2.0
Oauth 2.0
 
(1) OAuth 2.0 Overview
(1) OAuth 2.0 Overview(1) OAuth 2.0 Overview
(1) OAuth 2.0 Overview
 
Mohanraj - Securing Your Web Api With OAuth
Mohanraj - Securing Your Web Api With OAuthMohanraj - Securing Your Web Api With OAuth
Mohanraj - Securing Your Web Api With OAuth
 
Presentation
PresentationPresentation
Presentation
 
Securing RESTful Payment APIs Using OAuth 2
Securing RESTful Payment APIs Using OAuth 2Securing RESTful Payment APIs Using OAuth 2
Securing RESTful Payment APIs Using OAuth 2
 
Securing your APIs with OAuth, OpenID, and OpenID Connect
Securing your APIs with OAuth, OpenID, and OpenID ConnectSecuring your APIs with OAuth, OpenID, and OpenID Connect
Securing your APIs with OAuth, OpenID, and OpenID Connect
 
The Ultimate Guide to Mobile API Security
The Ultimate Guide to Mobile API SecurityThe Ultimate Guide to Mobile API Security
The Ultimate Guide to Mobile API Security
 
OAuth 2.0 - The fundamentals, the good , the bad, technical primer and commo...
OAuth 2.0  - The fundamentals, the good , the bad, technical primer and commo...OAuth 2.0  - The fundamentals, the good , the bad, technical primer and commo...
OAuth 2.0 - The fundamentals, the good , the bad, technical primer and commo...
 
Spring4 security oauth2
Spring4 security oauth2Spring4 security oauth2
Spring4 security oauth2
 
Best Practices in Building an API Security Ecosystem
Best Practices in Building an API Security EcosystemBest Practices in Building an API Security Ecosystem
Best Practices in Building an API Security Ecosystem
 
Rest API Security
Rest API SecurityRest API Security
Rest API Security
 
Identity Management in SharePoint 2013
Identity Management in SharePoint 2013Identity Management in SharePoint 2013
Identity Management in SharePoint 2013
 
Spring4 security oauth2
Spring4 security oauth2Spring4 security oauth2
Spring4 security oauth2
 
Microservice with OAuth2
Microservice with OAuth2Microservice with OAuth2
Microservice with OAuth2
 

Andere mochten auch

Hospital information system[1]
Hospital information system[1]Hospital information system[1]
Hospital information system[1]
Prasit Chanarat
 
Health information systems (his)
Health information systems (his)Health information systems (his)
Health information systems (his)
Nkosinathi Lungu
 
Health Information Systems
Health Information SystemsHealth Information Systems
Health Information Systems
Nikhil Agarwal
 
Communication Protocols And Web Services
Communication Protocols And Web ServicesCommunication Protocols And Web Services
Communication Protocols And Web Services
Omer Katz
 

Andere mochten auch (14)

Stateless token-based authentication for pure front-end applications
Stateless token-based authentication for pure front-end applicationsStateless token-based authentication for pure front-end applications
Stateless token-based authentication for pure front-end applications
 
UMA for ACE
UMA for ACEUMA for ACE
UMA for ACE
 
Hospital information system[1]
Hospital information system[1]Hospital information system[1]
Hospital information system[1]
 
Hospital information systems - HIS
Hospital information systems - HISHospital information systems - HIS
Hospital information systems - HIS
 
Health management information system
Health management information systemHealth management information system
Health management information system
 
Health information systems (his)
Health information systems (his)Health information systems (his)
Health information systems (his)
 
Health Information Systems
Health Information SystemsHealth Information Systems
Health Information Systems
 
Health management information system
Health management information systemHealth management information system
Health management information system
 
Hospital Information Management System 24092010
Hospital Information Management System 24092010Hospital Information Management System 24092010
Hospital Information Management System 24092010
 
Hospital information system
Hospital information systemHospital information system
Hospital information system
 
Intorduction to Health information system presentation
 Intorduction to Health information system presentation Intorduction to Health information system presentation
Intorduction to Health information system presentation
 
Communication Protocols And Web Services
Communication Protocols And Web ServicesCommunication Protocols And Web Services
Communication Protocols And Web Services
 
SRS for Hospital Management System
SRS for Hospital Management SystemSRS for Hospital Management System
SRS for Hospital Management System
 
Hospital Information Systems & Electronic Health Records
Hospital Information Systems & Electronic Health RecordsHospital Information Systems & Electronic Health Records
Hospital Information Systems & Electronic Health Records
 

Ähnlich wie OAuth in the new .NET world (OWIN)

OAuth Introduction
OAuth IntroductionOAuth Introduction
OAuth Introduction
h_marvin
 

Ähnlich wie OAuth in the new .NET world (OWIN) (20)

OAuth Introduction
OAuth IntroductionOAuth Introduction
OAuth Introduction
 
Lecture 20101124
Lecture 20101124Lecture 20101124
Lecture 20101124
 
Cloud identity management meetup 150108
Cloud identity management meetup 150108Cloud identity management meetup 150108
Cloud identity management meetup 150108
 
Создание API, которое полюбят разработчики. Глубокое погружение
Создание API, которое полюбят разработчики. Глубокое погружениеСоздание API, которое полюбят разработчики. Глубокое погружение
Создание API, которое полюбят разработчики. Глубокое погружение
 
OmniAuth: From the Ground Up
OmniAuth: From the Ground UpOmniAuth: From the Ground Up
OmniAuth: From the Ground Up
 
Understanding SharePoint Apps, authentication and authorization infrastructur...
Understanding SharePoint Apps, authentication and authorization infrastructur...Understanding SharePoint Apps, authentication and authorization infrastructur...
Understanding SharePoint Apps, authentication and authorization infrastructur...
 
CIS13: Identity as a Matter of Public Safety: A Case Study in Secure API Acce...
CIS13: Identity as a Matter of Public Safety: A Case Study in Secure API Acce...CIS13: Identity as a Matter of Public Safety: A Case Study in Secure API Acce...
CIS13: Identity as a Matter of Public Safety: A Case Study in Secure API Acce...
 
Api security
Api security Api security
Api security
 
Leveraging Rails to Build Facebook Apps
Leveraging Rails to Build Facebook AppsLeveraging Rails to Build Facebook Apps
Leveraging Rails to Build Facebook Apps
 
Authorization and Authentication using IdentityServer4
Authorization and Authentication using IdentityServer4Authorization and Authentication using IdentityServer4
Authorization and Authentication using IdentityServer4
 
Facebook + Ruby
Facebook + RubyFacebook + Ruby
Facebook + Ruby
 
SharePoint Saturday Utah - Do you claim to be from the Azure Sky?
SharePoint Saturday Utah - Do you claim to be from the Azure Sky?SharePoint Saturday Utah - Do you claim to be from the Azure Sky?
SharePoint Saturday Utah - Do you claim to be from the Azure Sky?
 
Smart Distancing using Social Authentication
Smart Distancing using Social AuthenticationSmart Distancing using Social Authentication
Smart Distancing using Social Authentication
 
Stateless Auth using OAuth2 & JWT
Stateless Auth using OAuth2 & JWTStateless Auth using OAuth2 & JWT
Stateless Auth using OAuth2 & JWT
 
Social Single Sign-On with OpenID Connect
Social Single Sign-On with OpenID ConnectSocial Single Sign-On with OpenID Connect
Social Single Sign-On with OpenID Connect
 
SharePoint Saturday Austin - Share point authentication and authorization
SharePoint Saturday Austin - Share point authentication and authorizationSharePoint Saturday Austin - Share point authentication and authorization
SharePoint Saturday Austin - Share point authentication and authorization
 
Restful design at work v2.0
Restful design at work v2.0Restful design at work v2.0
Restful design at work v2.0
 
Understanding Identity in the World of Web APIs – Ronnie Mitra, API Architec...
Understanding Identity in the World of Web APIs – Ronnie Mitra,  API Architec...Understanding Identity in the World of Web APIs – Ronnie Mitra,  API Architec...
Understanding Identity in the World of Web APIs – Ronnie Mitra, API Architec...
 
Stateless Auth using OAUTH2 & JWT
Stateless Auth using OAUTH2 & JWTStateless Auth using OAUTH2 & JWT
Stateless Auth using OAUTH2 & JWT
 
SharePoint Authentication And Authorization SPTechCon San Francisco
SharePoint Authentication And Authorization SPTechCon San FranciscoSharePoint Authentication And Authorization SPTechCon San Francisco
SharePoint Authentication And Authorization SPTechCon San Francisco
 

Mehr von Emad Alashi

Mehr von Emad Alashi (12)

RBAC in Azure Kubernetes Service AKS
RBAC in Azure Kubernetes Service AKSRBAC in Azure Kubernetes Service AKS
RBAC in Azure Kubernetes Service AKS
 
Am I a Good Developer
Am I a Good DeveloperAm I a Good Developer
Am I a Good Developer
 
Basic Intro to WinDbg
Basic Intro to WinDbgBasic Intro to WinDbg
Basic Intro to WinDbg
 
Acquiring knowledge
Acquiring knowledgeAcquiring knowledge
Acquiring knowledge
 
Owin, Katana, and Helios
Owin, Katana, and HeliosOwin, Katana, and Helios
Owin, Katana, and Helios
 
ASP.NET Routing & MVC
ASP.NET Routing & MVCASP.NET Routing & MVC
ASP.NET Routing & MVC
 
Software Life Cycle, Humans & Code
Software Life Cycle, Humans & CodeSoftware Life Cycle, Humans & Code
Software Life Cycle, Humans & Code
 
HTML5 & IE
HTML5 & IEHTML5 & IE
HTML5 & IE
 
ASP.NET MVC One Step Deeper
ASP.NET MVC One Step DeeperASP.NET MVC One Step Deeper
ASP.NET MVC One Step Deeper
 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVCIntroduction to ASP.NET MVC
Introduction to ASP.NET MVC
 
Communication Skills one To one
Communication Skills one To oneCommunication Skills one To one
Communication Skills one To one
 
Introduction To NHibernate
Introduction To NHibernateIntroduction To NHibernate
Introduction To NHibernate
 

Kürzlich hochgeladen

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Kürzlich hochgeladen (20)

DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
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...
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 

OAuth in the new .NET world (OWIN)

Hinweis der Redaktion

  1. What we will learn today:What is OAuth (Intro)The new authentication model of MVC 5 & OWIN and how it relates to OAuthThe .net components Microsoft put that deals with OAuth like Facebook authenticationNote:We will be fast
  2. Everyone had access to your entire resources unconditionedIncluding the fool and the evilOnce in their hands, can never revoke their access unless you change the password
  3. OAuth started 2006Blain Cook (Twitter)Chris Messina Larry HalffDavidRecordonEran HammerLater in 2008 it moved under the umbrella of Internet Engineering Task Force (IETF)
  4. Authorization CodeThe authorization code is obtained by using an authorization serveras an intermediary between the client and resource owner. Instead ofrequesting authorization directly from the resource owner, the clientdirects the resource owner to an authorization server (via itsuser-agent as defined in [RFC2616]), which in turn directs theresource owner back to the client with the authorization code.Before directing the resource owner back to the client with theauthorization code, the authorization server authenticates theresource owner and obtains authorization. Because the resource owneronly authenticates with the authorization server, the resourceowner’s credentials are never shared with the client.The authorization code provides a few important security benefits,such as the ability to authenticate the client, as well as thetransmission of the access token directly to the client withoutpassing it through the resource owner’s user-agent and potentiallyexposing it to others, including the resource owner.1.3.2. ImplicitThe implicit grant is a simplified authorization code flow optimizedfor clients implemented in a browser using a scripting language suchas JavaScript. In the implicit flow, instead of issuing the clientan authorization code, the client is issued an access token directlyHardt Standards Track [Page 8]RFC 6749 OAuth 2.0 October 2012(as the result of the resource owner authorization). The grant typeis implicit, as no intermediate credentials (such as an authorizationcode) are issued (and later used to obtain an access token).When issuing an access token during the implicit grant flow, theauthorization server does not authenticate the client. In somecases, the client identity can be verified via the redirection URIused to deliver the access token to the client. The access token maybe exposed to the resource owner or other applications with access tothe resource owner’s user-agent.Implicit grants improve the responsiveness and efficiency of someclients (such as a client implemented as an in-browser application),since it reduces the number of round trips required to obtain anaccess token. However, this convenience should be weighed againstthe security implications of using implicit grants, such as thosedescribed in Sections 10.3 and 10.16, especially when theauthorization code grant type is available.1.3.3. Resource Owner Password CredentialsThe resource owner password credentials (i.e., username and password)can be used directly as an authorization grant to obtain an accesstoken. The credentials should only be used when there is a highdegree of trust between the resource owner and the client (e.g., theclient is part of the device operating system or a highly privilegedapplication), and when other authorization grant types are notavailable (such as an authorization code).Even though this grant type requires direct client access to theresource owner credentials, the resource owner credentials are usedfor a single request and are exchanged for an access token. Thisgrant type can eliminate the need for the client to store theresource owner credentials for future use, by exchanging thecredentials with a long-lived access token or refresh token.1.3.4. Client CredentialsThe client credentials (or other forms of client authentication) canbe used as an authorization grant when the authorization scope islimited to the protected resources under the control of the client,or to protected resources previously arranged with the authorizationserver. Client credentials are used as an authorization granttypically when the client is acting on its own behalf (the client isalso the resource owner) or is requesting access to protectedresources based on an authorization previously arranged with theauthorization server.
  5. The flow illustrated in Figure 3 includes the following steps:(A) The client initiates the flow by directing the resource owner’suser-agent to the authorization endpoint. The client includesits client identifier, requested scope, local state, and aredirection URI to which the authorization server will send theuser-agent back once access is granted (or denied).(B) The authorization server authenticates the resource owner (viathe user-agent) and establishes whether the resource ownergrants or denies the client’s access request.(C) Assuming the resource owner grants access, the authorizationserver redirects the user-agent back to the client using theredirection URI provided earlier (in the request or duringclient registration). The redirection URI includes anauthorization code and any local state provided by the clientearlier.(D) The client requests an access token from the authorizationserver’s token endpoint by including the authorization codereceived in the previous step. When making the request, theclient authenticates with the authorization server. The clientincludes the redirection URI used to obtain the authorizationcode for verification.(E) The authorization server authenticates the client, validates theauthorization code, and ensures that the redirection URIreceived matches the URI used to redirect the client instep (C). If valid, the authorization server responds back withan access token and, optionally, a refresh token.
  6. KatanaAuthentication is a Middleware
  7. Invoke: Check if should handle or notAuthenticateCore: create Authentication Ticket (Identity wrapper)ApplyResponseGrant: add token, remove tokenApplyResponseChallenge: handle 401