Snowflake connector for MuleSoft using Azure Oauth Client Credentials

Baranee Manoharan
4 Jan 202318:32

Summary

TLDRThis video tutorial guides viewers on integrating MuleSoft with Snowflake using the client credential grant pattern for machine-to-machine communication. It covers creating an application in Azure, setting up application ID URI, app roles, and permissions. The video demonstrates generating a token, creating a security integration in Snowflake, and verifying the token. It concludes with a Java client program example, illustrating how to fetch data from Snowflake using MuleSoft, highlighting the process of setting up a custom connector due to limitations with existing connectors.

Takeaways

  • 🔧 The video demonstrates how to connect Mulesoft to Snowflake using the client credentials method for machine-to-machine communication.
  • 🚀 The process involves creating an application in Azure and configuring it for client credentials rather than user-based access.
  • 🛠️ The video shows the steps for registering an application in Azure, setting the application ID URI, and assigning roles.
  • 🔐 Snowflake requires security integration with Azure by using JWT tokens, which are created and verified through Azure endpoints.
  • 📝 After obtaining a valid token, the token's role is verified, and it maps to a user account in Snowflake.
  • 💡 A custom Mulesoft connector is built because the standard Mulesoft connector doesn't fully support OAuth or JDBC for Snowflake.
  • 💻 The developer uses a Java client program to generate tokens and establish the connection, which is then integrated with Mulesoft.
  • 🔄 The Snowflake connection is demonstrated by running SQL queries using a database and schema defined in the configuration.
  • 📊 The program successfully returns results from Snowflake, converting them to JSON and executing scheduled tasks.
  • 🛠️ The custom connector is available on GitHub for others who may need to integrate Mulesoft with Snowflake via Azure's external authentication.

Q & A

  • What is the main topic of the video?

    -The main topic of the video is about the options available for connecting MuleSoft to Snowflake using client credential pattern.

  • Why is the client credential pattern used in this context?

    -The client credential pattern is used for machine-to-machine communication, allowing the application to authenticate itself with Snowflake on behalf of the user.

  • What is the role of Azure in the process described in the video?

    -Azure is used to create and manage application registrations, which are necessary for provisioning applications and obtaining tokens for use with Snowflake.

  • How does the video demonstrate the creation of an application in Azure?

    -The video demonstrates the creation of an application in Azure by navigating to 'Application Registration', then 'New Registration', and adding an Application ID URI.

  • What is the significance of the application ID URI in the process?

    -The application ID URI is significant as it identifies the application to Azure and Snowflake, and is used when creating app roles and setting permissions.

  • Why is it necessary to add app roles in the Azure application?

    -App roles are added to define the permissions and roles that the application will have within Azure, which is essential for controlling access and security.

  • What is the purpose of creating a token in the video?

    -The purpose of creating a token is to authenticate the application with Snowflake, allowing it to access and interact with Snowflake resources on behalf of the user.

  • How is the security integration created with Snowflake in the video?

    -The security integration is created by providing the necessary configuration details such as the audience, issuer, and JWKS URI, which are obtained from Azure, and then creating a security integration in Snowflake.

  • What is the role of the 'system verify external browser token' command in Snowflake?

    -The 'system verify external browser token' command is used in Snowflake to verify the token obtained from Azure, ensuring it is valid and can be used for authentication.

  • How does the video address the creation of a Java client program for MuleSoft?

    -The video addresses the creation of a Java client program by showing how to convert the obtained token and credentials into a format that can be used by MuleSoft connectors, and then demonstrating how to implement this in a custom connector.

  • What is the significance of the 'username extractor' mentioned in the video?

    -The 'username extractor' is significant as it extracts the username from the token, which is then used to create a user in Snowflake that corresponds to the application for authentication purposes.

Outlines

00:00

🔗 Setting Up Azure for Snowflake Integration

This paragraph explains the process of connecting MuleSoft to Snowflake using client credential flow. It details the creation of an application in Azure, adding an application ID URI, and setting up app roles. The speaker demonstrates how to configure API permissions and scopes, and how to create a token using client ID and secret. The process involves setting up a security integration in Snowflake with the necessary configurations, including the audience and issuer URIs, and verifying the token's validity.

05:02

🛠️ Creating a Custom MuleSoft Connector

The speaker discusses creating a system security integration in Snowflake and the need to map the 'aud' claim from the token to the 'sub' claim in Snowflake. They also mention creating a username and password for Snowflake, which is derived from the token's 'sub' claim. The paragraph further explains the process of creating a Java client program to connect to Snowflake and converting it into a MuleSoft connector. The speaker highlights the need to use client ID and secret instead of username and password for authentication.

10:04

💻 Debugging and Testing the Custom Connector

In this paragraph, the speaker demonstrates how to debug and test the custom MuleSoft connector. They show the process of generating a token, extracting the 'aud' claim, and using it to establish a connection with Snowflake. The speaker also explains how to execute SQL commands using the connector and how to transform the results into a JSON format. The debugging process includes setting breakpoints and stepping through the code to ensure that the connector is functioning correctly.

15:05

📝 Finalizing the MuleSoft Connector and Code Review

The final paragraph covers the completion of the MuleSoft connector and a review of the code. The speaker discusses attaching the source code to the connector for easier debugging and maintenance. They also mention the need for additional JAR files to support JSON and login functionalities. The speaker provides a walkthrough of the code, explaining the connection configuration, the execution of SQL queries, and the conversion of results into a byte array. The paragraph concludes with the speaker's intention to check in the code to GitHub for further collaboration and improvement.

Mindmap

Keywords

💡Mulesoft

Mulesoft is a platform that provides integration software to connect applications, data, and devices. In the video, the focus is on using Mulesoft to create a custom connector for Snowflake, as the existing connectors are inadequate for certain authentication methods like OAuth.

💡Snowflake

Snowflake is a cloud-based data warehousing platform. The video demonstrates how to connect Mulesoft to Snowflake, focusing on secure machine-to-machine communication via client credentials and token-based authentication.

💡Client Credentials

The client credentials flow is an OAuth 2.0 mechanism used for machine-to-machine communication. In the video, it is highlighted as a secure method for integrating Snowflake with Mulesoft, where the machine (rather than a user) authenticates and procures tokens for communication.

💡Azure Application Registration

Azure Application Registration allows users to register and manage applications within Microsoft's Azure environment. In the video, this process is essential for setting up Snowflake integration, where an application is registered to generate client credentials and procure tokens.

💡Token

A token in OAuth-based authentication systems is a credential that represents authorization to access a particular resource. In this case, the video discusses the steps to generate and use tokens to securely communicate with Snowflake, replacing traditional username-password authentication.

💡OAuth 2.0

OAuth 2.0 is a widely adopted authorization framework that allows secure access to resources without sharing credentials. The video explains how Mulesoft integrates with Snowflake using OAuth 2.0, specifically focusing on the client credentials flow for machine-to-machine communication.

💡API Permissions

API permissions refer to the permissions granted to applications to interact with resources on behalf of a user or machine. In the video, setting proper API permissions in Azure is a critical step to ensure that the registered application can access Snowflake resources securely.

💡Custom Connector

A custom connector is a user-developed solution that facilitates communication between systems when no out-of-the-box option is available. In the video, the speaker develops a custom connector in Mulesoft for Snowflake due to the limitations of the default connectors provided by Mulesoft.

💡JWT (JSON Web Token)

JWT is a compact, URL-safe means of representing claims between two parties. The video demonstrates how JWT tokens are used to authenticate and authorize actions between Mulesoft and Snowflake, and how they are generated via Azure.

💡Security Integration

Security integration refers to the setup of secure communication between different systems. In the video, Snowflake's security integration is created using Azure, and it's key to ensuring that tokens generated in Azure can be properly verified by Snowflake, allowing access to resources.

Highlights

Introduction to connecting MuleSoft to Snowflake using machine-to-machine communication.

Explanation of using client credential pattern for connecting to Snowflake.

Guide to creating application registrations in Azure for Snowflake integration.

Adding Application ID URI to the Azure application registration.

Setting up app roles for secure access control.

Best practices for managing permissions and roles in Azure.

Creating a token using client ID and secret in Azure.

Verifying the token's role and permissions.

Creating a system security integration with Snowflake.

Mapping the audience list from Azure to Snowflake for security integration.

Using the system verify external work token command in Snowflake.

Creating a username and password for Snowflake based on token extraction.

Building a Java client program to connect MuleSoft with Snowflake.

Using custom connector in MuleSoft for Snowflake connection.

Explanation of using client ID and secret instead of username and password.

Debugging and attaching source code for the custom connector.

Executing a query and returning results as a string or byte array in MuleSoft.

Demonstration of the custom connector's functionality with a live example.

Conclusion and summary of the process for connecting MuleSoft to Snowflake.

Transcripts

play00:00

oil welcome to this mules of video in

play00:03

this video we are going to see what are

play00:05

the options available for connecting

play00:07

mulesoft into snowflake

play00:09

so since it is a machine to machine

play00:12

communication we are going to use client

play00:14

credential

play00:15

or pattern

play00:17

so snowflake has provided to a couple of

play00:19

the links one is to create

play00:23

applicator applications in azure

play00:26

which I have executed here

play00:28

so

play00:30

so you can actually

play00:33

provision applications for user on

play00:36

behalf of the user you can procure a

play00:38

token for behalf of the user or the

play00:41

client itself so we are going to use it

play00:42

for client credential meaning mission to

play00:44

Mission it is for client so

play00:48

I am going to implement this one in

play00:49

Azure for example go to application

play00:52

registration

play00:53

new registration

play00:55

once you have this one you can add

play00:59

application

play01:01

ID URI to it so this this URLs we have

play01:05

given us

play01:07

to create two applications but I have

play01:08

done it in a single application so in

play01:11

first initial thing is go to

play01:13

applicationization click on new

play01:15

registration Snowflake and created that

play01:18

one so I'll go to eBay permission

play01:21

so before that you need to go here and

play01:23

set this application ID URI this random

play01:26

it creates itself and it's a random

play01:29

create ID

play01:31

then

play01:32

you need to add app role

play01:34

this is the approach

play01:37

you can use online with generator and

play01:40

I'll prepare this one and put in yours

play01:42

this is explained here here

play01:46

so once you set the application URI

play01:50

then go to manages add this you add this

play01:53

role and create an another application

play01:56

you don't have to

play01:57

this is just best practice if you want

play01:59

to just play around with your

play02:00

application is enough and add a role to

play02:04

this new new application that you have

play02:06

created

play02:07

then

play02:09

this is just trying to client security

play02:11

creation before that once you create a

play02:14

second application you won't go to the

play02:21

API add a scope the scope is coming from

play02:25

the other previous application that you

play02:27

have created in azure

play02:29

so once you have that let me show you

play02:31

that how it looks like in here once you

play02:33

add this role go back to the AP

play02:35

permission add a permission

play02:41

since we have one application it's

play02:42

showing the same application again it's

play02:44

Snowflake and I have this system admin

play02:47

role here

play02:48

that is what we have added here so

play02:50

that's why this system admin and this

play02:53

value is coming over

play02:55

to the Token that we generate so once

play02:58

you do that go to

play03:00

heavy permissions and make sure that

play03:02

this is all banned that means it's both

play03:05

are approved by the Admin right

play03:08

then this is the time to create a token

play03:12

and see what's inside right so go to

play03:15

client ID and secret put everything it's

play03:17

decline through the chills okay

play03:21

button then you would get hit open make

play03:25

sure the token is having

play03:27

this value in it the roles that you have

play03:30

right then you can make sure that until

play03:33

now you're good

play03:35

so once you've done this

play03:39

information

play03:40

Grant the permission it's all saying the

play03:43

same thing go to end point and create

play03:46

take the token URL and like this you can

play03:49

make a call right and procure the token

play03:51

once you procreate the token

play03:53

switch over to this URL

play03:56

from here this is both this is common

play03:58

for both using plantar and children user

play04:02

username and password

play04:05

so we're coming to this page and say

play04:09

this is what I have said here

play04:16

I'm talking

play04:20

so this is this is the role that that I

play04:24

was talking about once you generate the

play04:26

token you can put an objective I want to

play04:28

see it

play04:30

after that you need to create a system a

play04:32

security integration with the snowflake

play04:34

here I have my domain demo account which

play04:38

is free I have created a

play04:41

by providing few results from you I

play04:44

officially from here

play04:46

so this is nothing but Nashua you can

play04:49

message it from here we sure

play04:51

this is

play04:53

goes there there's no click sorry it's

play04:56

just not flick and the jwtu are a token

play04:59

you should take it from azure

play05:02

endpoints

play05:06

take the alternative configuration

play05:12

that gives you the URL the jws URI

play05:17

this UI you should take it as private

play05:20

into snowflake right that is what this

play05:23

this URL is and then you need to provide

play05:26

the mapping climax sub and that's this

play05:29

audience list is nothing but this is

play05:32

coming from the APA permissions

play05:35

sorry The Xpose API and copy this

play05:38

so I think we are ready then create this

play05:41

one you will get the security

play05:43

integration created now we need to

play05:46

provide the role uh record for this one

play05:50

and then

play05:52

using the same token you can verify it

play05:54

from Snowflake using

play05:57

system verify external work token

play06:00

once you do that you will have a

play06:03

username extractor

play06:04

which you would need here so this is

play06:06

explained and uh

play06:08

in here once you create the integration

play06:12

system security integration then you

play06:15

would see it as failing because you

play06:17

would need you would need SUV

play06:20

once you execute that one

play06:23

verify the token you will get the

play06:26

or you once you end up okay this is what

play06:28

you have so system verify external token

play06:31

this will pass you this username after

play06:33

that you need to create a username this

play06:35

user in

play06:37

the snowflake the system is not click

play06:39

account where it goes I have is viewed

play06:42

it here

play06:44

user the ID that I have extracted from

play06:48

this should become the username

play06:51

and the password can be anything

play06:55

and the login as well the same ID

play06:59

and once you create that the

play07:02

so you this should be successful as well

play07:04

right then

play07:07

go to go back to the link

play07:12

then you're done you will be able to

play07:15

procure this token and use it and in

play07:18

this topic right so for that I'm going

play07:21

to create a Java client program then I

play07:25

will convert them into a

play07:27

new soft connector right so mulesoft

play07:30

does have a connector list of huge

play07:34

connectors or connecting with snowflake

play07:36

but it is useless because

play07:38

it's not supporting jdbc is not oauth

play07:41

right so we are Keen to use that one so

play07:44

username and password we are not going

play07:46

to provide it instead we want to provide

play07:50

this is my minimum viable product so of

play07:53

this connector we are going to provide

play07:55

planetarium secret instead of username

play07:57

and password right so the username which

play08:00

this one you have seen it that that we

play08:02

have cleared here

play08:04

right this is coming from the token this

play08:06

never changes even if you create n

play08:08

number of tokens

play08:09

that

play08:12

climb is going to be the same all the

play08:14

time so once you've created

play08:17

you can create a number of

play08:20

yeah so say this would be same cc87 that

play08:24

the once you create the username you can

play08:25

use it for the number of application

play08:29

and that is goes here the client ID

play08:31

which I have used it in

play08:33

yeah three seven

play08:35

so and on the client Secret

play08:38

scope

play08:39

scope is the same I'm going to give it

play08:42

in the browser then it's a client finish

play08:44

then

play08:47

this is my account name and from this

play08:50

coming from straight snowflake you can

play08:52

go to

play08:54

it's an application

play08:57

account you can copy it here

play09:02

over here

play09:04

and then the default Warehouse name

play09:06

compute w h

play09:11

and this is this one and my database is

play09:14

API

play09:15

km1

play09:22

demo one

play09:23

API testing tables and I have a table

play09:25

for demo

play09:28

so

play09:30

we will run this one go to worksheet and

play09:32

open it and

play09:34

run

play09:36

demo right good sky

play09:41

it has 15 rows

play09:43

and

play09:45

again this is

play09:47

this is not needed

play09:51

so we are going to create one let me

play09:53

show this demo

play09:55

and then I'll go to the code as well

play09:58

so mules are provided one this country

play10:01

is useless Finance because we are using

play10:03

jdbc one supporter so that's why I have

play10:07

created this Custom Custom connector and

play10:10

mule 4 right let me run this program and

play10:13

see what it what it gets to us I mean

play10:16

otherwise let me debug the time

play10:20

I didn't care

play10:23

I want to save this one

play10:26

okay so

play10:28

save this guy

play10:32

so the trick to when you create a custom

play10:35

committer you

play10:38

generate the sources as well attach the

play10:41

sources and better debug it so that

play10:43

would be easiest thing I have attached

play10:45

my by clicking the class I have attached

play10:48

the source code as well

play10:51

then

play10:52

of course I have a good breakpoint

play10:55

that goes straight to that

play10:59

okay I'm not reloading

play11:05

let's see what I heard

play11:10

and so

play11:13

so I have breakpoint here

play11:15

between so first what I'm doing is in

play11:18

this connector I'm going to get the

play11:21

token which is this this part right so

play11:24

let me go to that one

play11:27

step four step forward so I'm adding

play11:30

length to control ID that you provided

play11:33

in the connector then

play11:35

I'm taking a parameter again generating

play11:38

the token so token is this one then then

play11:40

from the token I'm extracting

play11:42

the odds token

play11:45

which is this one

play11:47

this works

play11:55

exactly the same

play11:57

this will also have this right now a

play12:00

role that we have added then I'm

play12:02

procuring a connection using the

play12:04

clientele

play12:08

once I have it I'm going to create the

play12:11

statement first I'll use the I'll

play12:13

execute use database command and that's

play12:16

schema

play12:17

after that I'm going to execute this

play12:20

query which is coming straight from

play12:25

sorry

play12:27

straight from the goal let me show you

play12:29

that

play12:31

particularly

play12:32

so here I have the selection from demo

play12:37

that is coming to here

play12:39

so it's just about this guys then see

play12:42

how many rows now right now I'm

play12:44

returning them as a string uh I'm

play12:47

creating this scenario and create

play12:48

returning as a string but I'm going to

play12:50

change it into byte array so that it

play12:53

will be

play12:54

will be quite equivalent to

play12:57

mules are given one but once mail sort

play13:00

is supporting this connect this way of

play13:01

connecting snowflake I think that's a

play13:03

way going forward right because many

play13:05

people will use that then the news I've

play13:07

got the bugs closed so that is reliable

play13:10

but right now this is the only shot we

play13:12

have if we are using otherwise you can

play13:14

use wrist based authentication if you

play13:17

don't prefer the connector

play13:19

if you don't prefer the hunter right so

play13:21

let me

play13:22

inflates it it reads all it reads all

play13:25

the things and

play13:26

it drove right to the Intel

play13:32

yes okay let's keep running because

play13:46

so this transform component tool is it's

play13:50

convert them into a Json is because it's

play13:52

just it's right now this component is

play13:54

threatening string

play13:59

right so permission to machine

play14:01

communication this is the

play14:04

let me stop it

play14:09

see this transform component has got

play14:11

something just this one here 15 areas

play14:15

then

play14:16

go through this

play14:22

you can be working then fix the code

play14:24

this is going to be in a GitHub burn one

play14:27

to one and that's fine

play14:29

okay I will check in there

play14:36

I will add it here so I can get that

play14:43

and it repeats things because it's a

play14:45

scheduler so here you see it

play14:48

you have all the rows

play14:51

my fingers

play15:05

and start by every second but uh

play15:08

see so it runs perfectly so now I'm

play15:11

going to go through this

play15:12

uh the code where we came

play15:16

the code is this one so

play15:21

this is pump file where I have added

play15:24

attached sources so let's let's create

play15:26

the jar and there we can attach your

play15:28

source and debug it

play15:30

and you would need a snowflake provided

play15:33

jar file

play15:35

and this is to support Json and this is

play15:39

for login

play15:40

now I'm going to this operation straight

play15:41

away

play15:42

this is where I have

play15:45

all the operations is scheduled so the

play15:47

execute query that you see it in here

play15:49

this is very pretty simple now I have

play15:52

not

play15:53

changed icons as well so execute query

play15:56

that is coming from here so that's

play15:59

expecting a connection but connection

play16:01

contributes in this here so where is

play16:03

this connection configuration this is

play16:05

actually if you press F12

play16:10

so this connection having a

play16:13

configuration as well so this

play16:14

configuration you should go and see it

play16:16

which is this one so here I have all the

play16:19

listed username client ID Secret

play16:24

this one is 90 weeks if it's called

play16:27

account where else

play16:29

so I have but I don't see it and

play16:31

database

play16:32

everywhere right so now

play16:42

in the

play16:45

in this place that will become

play16:47

the connected level kind of creation so

play16:49

you would you would want to give

play16:51

a SQL text here I would need I would

play16:55

make it I'll do it now later so this is

play16:59

the what client this client is actually

play17:02

is this file I am making a HTTP

play17:04

connection and preparing the token that

play17:06

you have seen it while debugging right

play17:08

so we are adding this details

play17:13

running this do post is actually making

play17:16

HTTP call for this I haven't text

play17:19

analyzed it but I have text analyze it

play17:21

if I want to use it so that it will come

play17:23

in the connection

play17:24

celebration itself so

play17:26

then what I'm doing is I'm once I

play17:28

prepare the token extract the out token

play17:31

from there then I use use database and

play17:33

use schema from

play17:35

from the config I'm getting schema

play17:39

once I do that I execute okay get the

play17:42

results here and convert them into Json

play17:44

and return them as finely as a string

play17:46

bit which is which should be a wide

play17:48

array

play17:50

which I'm gonna work further this is

play17:52

just 10 MBP for me

play17:54

yeah

play17:56

okay

play17:58

so this I'm going to check in as I said

play18:00

like in GitHub you can see it

play18:04

and so if you are using Azure as your

play18:07

what provider

play18:09

external load provider and mulesoft and

play18:12

snowflake

play18:13

this is uh

play18:17

I have shown almost everything

play18:26

and that's it thank you very much for

play18:30

your time

Rate This

5.0 / 5 (0 votes)

Связанные теги
MuleSoft IntegrationSnowflake ConnectorAzure SetupClient CredentialsMachine CommunicationCustom ConnectorToken GenerationAPI PermissionsOAuth IntegrationDatabase Query
Вам нужно краткое изложение на английском?