Top Banner
Last Updated: Aug. 2015 Amila De Silva Decoupling Key Management from WSO2 API Manager WSO2 API Manager Team
27
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Decoupling Key Management from WSO2 API Manager

Last Updated: Aug. 2015

Amila De Silva

Decoupling Key Management fromWSO2 API Manager

WSO2 API Manager Team

Page 2: Decoupling Key Management from WSO2 API Manager

**

About the Presenter

๏ Amila joined WSO2 in September 2012. He is a Associate Technical Lead in the WSO2 API Manager team. In addition to his product development efforts he has provided development support and technology consulting on customer engagements, including customer QuickStart programs.

Page 3: Decoupling Key Management from WSO2 API Manager

*

Introduction

Page 4: Decoupling Key Management from WSO2 API Manager

*

Introduction

๏ OAuth2 is used for many flows in API Manager- API Store calls KeyManager to Generate CK/CS- Gateway calls KeyManager to validate token

๏ KeyManager delivers OAuth2 functions needed for API Manager

๏ Before 1.9.0, components were tightly coupled with KeyManager

- When creating OAuth Clients weren’t done through standard APIs

- Token issuing/Validation were done by directly accessing DBs.

๏ 1.9.0, allows you plugging in different OAuth2 Providers

Page 5: Decoupling Key Management from WSO2 API Manager

*

Why a Third Party OAuth Provider?

● In most of the Deployments, embedded KM will be used● Organisations might be interested in using the existing

one○ Existing one already have OAuth2 support.○ Utilize advanced features.

● Managing two Authorization Servers can cause hassles

○ Organisations have stringent policies when deploying Authorization Servers

○ Bringing in a new server into MZ can be cumbersome● Risk of losing clients, when moving to a new

Authorization Server.

Page 6: Decoupling Key Management from WSO2 API Manager

*

Architecture & Implementation

Page 7: Decoupling Key Management from WSO2 API Manager

*

What has changed?

Page 8: Decoupling Key Management from WSO2 API Manager

*

What has changed...

๏ Keymanager interface to represent an OAuth Provider.- Mapping between Application and OAuth client

maintained by consumer key.๏ Method to fetch Token Details from OAuth Provider

- getTokenMetaData๏ Four methods to register/manage OAuth Clients

- createApplication(OAuthAppRequest oauthAppRequest)- updateApplication(OAuthAppRequest oauthAppRequest)- deleteApplication(String consumerKey) - retrieveApplication(String consumerKey)

Page 9: Decoupling Key Management from WSO2 API Manager

*

Registering OAuth Clients

Before Decoupling

Page 10: Decoupling Key Management from WSO2 API Manager

*

Registering OAuth Clients...

After Decoupling

Page 11: Decoupling Key Management from WSO2 API Manager

*

Retrieving OAuth Clients...

Before Decoupling

Page 12: Decoupling Key Management from WSO2 API Manager

*

Retrieving OAuth Clients...

After Decoupling

Page 13: Decoupling Key Management from WSO2 API Manager

*

Validating Tokens

Before Decoupling

Page 14: Decoupling Key Management from WSO2 API Manager

*

Validating Tokens...

After Decoupling

Page 15: Decoupling Key Management from WSO2 API Manager

*

๏ OAuth Provider should support following APIs- An API to create clients which returns Consumer Key with the response.

(createApplication method).

- An API to get client details by passing consumer Key. (

retrieveApplication method).

- An API which can be used to delete clients by Consumer Key.

(deleteApplication method).

- An API to update OAuth Clients - Optional (updateApplication).

- An API which can return details of a token. Response should give validity

of the token, consumer Key and lifetime. (getTokenMetadata method).

Does API Manager Support Any OAuth Provider?

Page 16: Decoupling Key Management from WSO2 API Manager

*

What else has changed

๏ Map an existing OAuth client with AM Application.

Page 17: Decoupling Key Management from WSO2 API Manager

*

Extending Key Validation

Page 18: Decoupling Key Management from WSO2 API Manager

*

Extending Key Validation flow

๏ Gateway Calls APIKeyValidationService to get token validated

- Lot of operations happening inside single method๏ KeyValidationHandler breaks the big method into

smaller parts- validateToken- validateSubscription- validateScopes- generateConsumerToken

Page 19: Decoupling Key Management from WSO2 API Manager

*

Extending Key Validation flow...

๏ validateToken- For most cases, existing implementation would work

๏ validateSubscription- Skipping/Changing Domain Validation

๏ validateScopes- Relaxing/Reducing scope restrictions

๏ generateConsumerToken- Create different Types of tokens

Page 20: Decoupling Key Management from WSO2 API Manager

*

Usecase : Supporting Basic Auth

๏ Write an Axis2Handler that runs on the Gateway- Call APIKeyValidationService

๏ Extend KeyValidationHandler and override validateToken method

- Validate Credentials๏ Skip validateSubscription - Simply return true๏ Remember to set Token Type and the Tier.

Page 21: Decoupling Key Management from WSO2 API Manager

*

Deployment

Page 22: Decoupling Key Management from WSO2 API Manager

*

How does the Deployment change?

Before decoupling

Page 23: Decoupling Key Management from WSO2 API Manager

*

How does the Deployment change...

After decoupling

Page 24: Decoupling Key Management from WSO2 API Manager

*

How does the Deployment change...

Before decoupling

Page 25: Decoupling Key Management from WSO2 API Manager

*

How does the Deployment change...

After Decoupling

Page 27: Decoupling Key Management from WSO2 API Manager

Contact us !