Monday, March 7, 2016

Adding OAuth 2.0 Token Introspection Support to WSO2 Identity Server 5.1.0

WSO2 Identity Server 5.2.0 will have the support for OAuth 2.0 token introspection profile. If you are using Identity Server 5.1.0, this blog post explains how to build and deploy the introspection API on IS 5.1.0.

1. Checkout and build the code from https://github.com/facilelogin/aratuwa/tree/master/api-security/org.wso2.carbon.identity.oauth.introspection  and deploy it as a war file in IS 5.1.0 (IS_HOME/repository/deployment/server/webapps/).

2. Restart the Identity Server and now you should be able to use the introspection API.

3. Find below the usage of the introspection API.
 
   Empty token:

   curl -k -H 'Content-Type: application/x-www-form-urlencoded' -X POST --data 'token=' https://localhost:9443/introspect

   Response: {"active":false} 
   Invalid token: 

   curl -k -H 'Content-Type: application/x-www-form-urlencoded' -X POST --data 'token=Bjhk98792k9hkjhk' https://localhost:9443/introspect 

   Response: {"active":false,"token_type":"bearer"} 
   Get a valid token(replace the value of client_id:client_secret appropriately): 

   curl -v -X POST --basic -u client_id:client_secret -H "Content-Type: application/x-www-form-urlencoded;charset=UTF-8" -k -d "grant_type=client_credentials" https://localhost:9443/oauth2/token 

   Validate the token:

   curl -k -H 'Content-Type: application/x-www-form-urlencoded' -X POST --data 'token=99f0a7092c71a6e772cbcf77addd39ea' https://localhost:9443/introspect 

   Response: 
   { "username":"admin@carbon.super", 
     "nbf":3272, 
     "active":true, 
     "token_type":"bearer", 
     "client_id":"LUG28MI5yjL5dATxQWdYGhDLSywa" 
   } 
   Get a valid token with a scope(replace the value of client_id:client_secret appropriately): 

   curl -v -X POST --basic -u LUG28MI5yjL5dATxQWdYGhDLSywa:b855n2UIxixrl_MN_juUuG7cnTUa -H "Content-Type: application/x-www-form-urlencoded;charset=UTF-8" -k -d "grant_type=client_credentials&scope=test1 test2" https://localhost:9443/oauth2/token 

   Validate the token:

   curl -k -H 'Content-Type: application/x-www-form-urlencoded' -X POST --data 'token=c78ac96fe9b59061b53d0223d46ecc24' https://idp1.federationhub.org:9443/introspec  

   Response: 
    { "username":"admin@carbon.super", 
      "scope":"test1 test2 ", 
      "nbf":3240, 
      "active":true, 
      "token_type":"bearer", 
      "client_id":"LUG28MI5yjL5dATxQWdYGhDLSywa" 
    }

9 comments:

caiyan said...

nike blazer low
uggs sale
nike factory store
louis vuitton handbags
polo ralph lauren outlet online
ugg outlet
cheap oakleys
tory burch outlet store
louboutin uk
uggs canada
20611019caiyan

chenmeinv0 said...

ugg outlet online
ugg outlet stores
kate spade handbags
coach outlet online
ray ban wayfarer
louis vuitton purses
toms shoes outlet
ugg boots
michael kors handbags outlet
nike roshe run pas cher
2016.12.27xukaimin

chenmeinv0 said...

nike huarache ultra
polo ralph lauren outlet
louboutin outlet
nike air max 90
christian louboutin shoes
ed hardy clothing
nike air max 95
michael kors handbags
ray ban clubmaster
timberland boots uk
hzx20170302

Meiqing Xu said...

true religion outlet
michael kors outlet
nike store
michael kors outlet
toms shoes
michael kors
michael kors outlet
borse gucci
timberland boots
cheap ray ban sunglasses
20170324huazhen

Hua Cai said...

coach outlet
louis vuitton outlet
longchamp handbags
true religion uk
adidas wings shoes
oakley sunglasses wholesale
mulberry handbags sale
longchamp
ralph lauren outlet
gucci outlet online
20170424caihuali

dong dong23 said...

ysl bags
polo shirts
nike air max 90
vans outlet store
columbia outlet store
nike sb stefan janoski
ugg boots outlet
pandora rings clearance
mbt outlet
canada goose jackets
2017.5.6chenlixiang

Gege Dai said...

ralph lauren outlet
ray ban sunglasses wholesale
fitflops sale clearance
mbt shoes
fred perry polo
giuseppe zanotti shoes
nhl jerseys
nike air huarache
cartier watches for women
coach factory outlet
20170526ck

raybanoutlet001 said...

ray ban sunglasses
ugg outlet
chargers jerseys
fitflops sale
snapbacks wholesale
ray ban sunglasses
ugg outlet
pandora outlet
ugg outlet
cheap oakley sunglasses

1111141414 said...

lebron 13 shoes
lacoste outlet
longchamp handbags
van cleef arpels
adidas outlet online
adidas ultra boost 3.0
adidas superstar
patriots jerseys
adidas ultra boost
light up shoes