Identity Provider Package

< All Topics

IUsersSecretsApplication Interface

IUserInfo Interface

Models

Third Party Classes

Auth 2.0 and OpenID

Examples SSO

Enviroment Variables (local.settings.json)

     DataBase

     Tokens

     Admins

     Social

     Memory Cache

Examples Barracuda Admin

Examples Users Admin

     Users Functions

     IUserApplication Interface

     Models

     Third Party Classes

     Scopes Description

     Tenants Description

Video Tutorials

Create Certificate

IUsersSecretsApplication Interfaces

Register

This method will let you create a new user authentication data.

Task<Result<string>> Register(string userid, string email, string password, bool validEmail = false);

DeleteUser

This method will let you delete the user secret from Cosmos DB.

Task<Result<string>> DeleteUser(string id);

UpdateScopes

This method will let you provide the authorization level of the secret users created in order to create, read,  update and delete content in your code.

The parameter scopes is a list where the data has to be insert as a vertor, like this example

 

[“user.read”, “user.write”, “user.update”, “user.delete”].

 

Task<Result<string>> UpdateScopes(string id, List<string> scopes);

UpdateTenants

This method will let you update the tenant for the user.

Task<Result<string>> UpdateTenants(string id, List<string> tenants);

Login

This method will let you login into your single page app as long as it has been registered before.

Task<Result<LoginDto>> Login(string email, string password, HttpRequest request);

Logout

This method will let you logout.

LoginDto Logout(HttpRequest request);

RemoveRefreshToken

This method will let you remove the refresh token.

void RemoveRefreshToken(HttpRequest request);

Refresh

This method will let you refresh the token provided by login method as long as it has expired.

This method only require two parameters to works and it returns an object that contains the id, email, token and refresh token.

Task<Result<LoginDto>> Refresh(string token, string refreshToken, HttpRequest request);

RefreshToken

This method will let you refresh the token with the data info from the user has already logged in.

This method only require two parameters to works and it returns an object that contains the id, email, token and refresh token.

Task<Result<LoginDto>> RefreshToken(string id, string email, HttpRequest request);

GoogleValidateToken

This method will let you login with the google credentials.

This method will require a response data from the google SDK client.

Check the Social Grant Flowdiagram to know how it works.

Task<Result<LoginDto>> GoogleValidateToken(dynamic data, HttpRequest request);

FacebookValidateToken

This method will let you login with the facebook credentials.

This method will require a response data from the facebook SDK client.

Check the Social Grant Flowdiagram to know how it works.

Task<Result<LoginDto>> FacebookValidateToken(dynamic data, HttpRequest request);

MicrosoftValidateToken

This method will let you login with the microsoft credentials.

This method will require a response data from the microsoft SDK client.

Check the Social Grant Flow diagram to know how it works.

Task<Result<LoginDto>> MicrosoftValidateToken(dynamic data, HttpRequest request);

ValidateToken

This method only validate that token and refresh token from the user secrect.

This method require two parameters to works, it takes the cookie from the explorer and it returns an object with the token, refresh token and a flag.

TokensDto ValidateToken(HttpRequestMessage req);

ChangePassword

This method will let you change the password of the user secret already logged in.

The red arrows mean the errors that are returned at each step in the sequence.

Task<Result<string>> ChangePassword(string email, string password);

ForgotPasswordOrRegister

This method will let you ask for a new password to login as long as the user already has been registered.

The method send a notification to the email to confirm then it sends back a token to the app in order to change the password.

The red arrows mean the errors that are returned at each step in the sequence.

 string ForgotPasswordOrRegister(string email);

ValidateRegisterEmail

This method set a flag to true in the Cosmos DB when the email is confirmed

Task<Result<string>> ValidateRegisterEmail(string email);

BlockUser

This method set a flag to true in the Cosmos DB when the user has been blocked.

Task<Result<string>> BlockUser(string id, bool Block)

CheckEmail

This method validate if email already exist in the Cosmos DB.

Task<Result<string>> CheckEmail(string email);

GetAdditional

This method get extra information from one user like scopes, tenants and block status from Cosmos DB.

Task<Result<AdditionalModel>> GetAdditional(string id);

GetBatchAdditional

This method get extra information from users like scopes, tenants and block status from Cosmos DB.

Task<Result<List<AdditionalModel>>> GetBatchAdditional(List<string> ids);

IUserInfo

UserId

This parameter get the UserId.
string UserId { get; }

Email

This parameter get the Email.
string Email { get; }

GetTokenAsync

This method get the token.

Task<string> GetTokenAsync();

Scopes

This parameter get the scopes.

List<string> Scopes { get; }

ValidateTokenAsync

This method will let you validate the token form the user already logged in.

Result<ClaimsPrincipal> ValidateTokenAsync(HttpRequestHeaders value, IPAddress ipAddress);

validScopes

This method valid the scopes from users.

Result<bool> validScopes(List<string> scopes);

Models

Result

Return the result of one method
{
  Sucess: return true or false,
  Message: return message error,
  Value: return any object
}

LoginDto

This class contains the Auth user data model

{
  public string Id { get; set; }
  public string Email { get; set; }
  public dynamic Scopes { get; set; }
}

UsersSecretsDto

This class contains the Auth users secrects data model

{
  public string Id { get; set; }
  public string Email { get; set; }
  public string Password { get; set; }   
}

userAuth

This object contains the Auth users secrects data model
{
  id: null,
  email: null,
  validEmail: null
}

AdditionalModel

This model contains extra information about users in order to be manarment by a Barracuda super admin.
public List Scopes { get; set; }
public List Tenants { get; set; }
public bool Block { get; set; }

public AdditionalModel()
{
  Scopes = Scopes != null ? Scopes : null;
  Tenants = Tenants != null ? Tenants : null;
}

Third Party Classes

Net Core Dynamic

This type lets you assign any value dynamically in run-time.

Microsoft.AspNetCore.Http.HttpRequest

Represents the incoming side of an individual HTTP request.

System.Net.Http.HttpRequestMessage

Represents a HTTP request message.

System.Net.Http.Headers.HttpRequestHeaders

Represents the collection of Request Headers as defined in RFC 2616.

System.Net.IPAddress

Provides an Internet Protocol (IP) address.

System.Security.Claims.ClaimsPrincipal

An IPrincipal implementation that supports multiple claims-based identities.

Auth 2.0 and OpenID

Social Grant Flow

The red arrows mean the errors that are returned at each step in the sequence.

The blue arrows mean the option to save the refresh token in the memory instead of the Cosmos DB.

Examples SSO

These examples were tested in an application React.js and the UsersSecrects.Functions.csproj they are in our solution Barracuda. The objective is make you know how to adapt your code with the product Barracuda Identity Provider. We will show how to interact with Azure Functions, OAuth 2.0 and openid protocols.

Click in this link to watch a video with the instructions to download the solution Barracuda.

UsersSecrects.Functions.csproj

This project will show you how to use the Azure Functions, OAuth 2.0 and openid protocols with the Package Barracuda Identity Provider.
This project is located in the next Path in the solution Barracuda: Barracuda\Examples\Auth\UsersSecrets.Functions.csproj.

All Azure Functions are located in the file: Barracuda\Examples\Auth\UsersSecretsFunctions.cs

React

This application is used to test the Azure Functions examples in the project UsersSecrects.Functions.csproj and it is located in the path: Barracuda\Examples\React\React.csproj

Components:
CustomLogin is located in the path:  Barracuda\Examples\React\Source\src\components\common\customLogin.js
userAuthActions is located in the path: Barracuda\Examples\React\Source\src\redux\actions\userAuthActions.js
usersAuthApi is located in the path: Barracuda\Examples\React\Source\src\api\usersAuthApi.js
topbar is located in the path: Barracuda\Examples\React\Source\src\components\layout\topbar.js

initialState is located in the path: Barracuda\Examples\React\Source\src\redux\reducers\initialState.js
verifyTokens is located in the path: Barracuda\Examples\React\Source\src\components\verifyTokens.js

authorizationUtils is located in the path: Examples\React\Source\src\api\authorizationUtils.js

logoutButton is located in the path: Barracuda\Examples\React\Source\src\components\auth\logoutButton.js

Register

Azure Function

This function is a HTTP Post and it is called with the route: permissions/Register

The model parameter UsersSecretsDto is required to works.

Create the users with the method Register from package Barracuda Identity Provider.

Set scopes to the users with the method UpdateScopes.

Update the tenant with the method UpdateTenants.

Get the token with the method ForgotPasswordOrRegister.

The URL with a token parameter created with the example below is to valid the user email.

Finally the URL can be send it by email.

 // you can build you custom address with the token generated

// example  https://mysite.com/onRoute/?validEmailToken=” + token
// and send an email to requester including the address in the email body

// you can call to change password api whit the token recived from email

// exmaple: https://localhost/api/permissions/ValidEmail?token=” + token

// It is important use the parameter named token

// Remember not return the token only if has been calling internally by the server

// use return new OkResult(); instead

React

The component CustomLogin.js shows the front view.

Create the model UsersSecretsDto.

The redux Register action is called with the model from UserAuthActions.js.

The API component UsersAuthApi.js is called.

Auth

Azure Function

This function is a HTTP Post and it is called  with the route: permissions/Auth

The model parameter UsersSecretsDto is required to works.

Sign in with the method Login from package Barracuda Identity Provider.

React

The component CustomLogin.js shows the front view.

Create the model UsersSecretsDto with the front data view.

The redux login action is called with the model from UserAuthActions.js.

The API Auth is called with the model from UsersAuthApi.js.

If user hasn’t valid the email yet go to ValidEmail Azure Function.

If user exists get a new Authorized token also get and set user settings finally get a new refresh token otherwise it doesn’t exist.

Logout

Azure Function

This function is a HTTP Get and it is called  with the route: permissions/Logout

The user currently logged in is validated with the function validAuthorized in order to pass the parameters to the function ValidateTokenAsync.

The method Logout is called.

React

The component topbar.js shows the front view.

The component logoutButton.js is called.

The redux logout and RemoveRefreshToken action are called from UserAuthActions.js.

The API Logout and RemoveRefreshToken are called from UsersAuthApi.js.

RemoveRefreshToken

Azure Function

This function is a HTTP Get and it is called  with the route: permissions/RemoveRefreshToken

The user currently logged in is validated with the function validAuthorized in order to pass the parameters to the function ValidateTokenAsync.

The method RemoveRefreshToken is called.

React

The component topbar.js shows the front view.

The component logoutButton.js is called.

The redux logout and RemoveRefreshToken action are called from UserAuthActions.js.

The API Logout and RemoveRefreshToken are called from UsersAuthApi.js.

RefreshToken

Azure Function

This function is a HTTP Post and it is called  with the route: permissions/RefreshToken

The user currently logged in is validated with the function validAuthorized in order to pass the parameters to the function ValidateTokenAsync.

The RefreshToken function gets the refresh token for the user who has logged in.

React

The redux tokenRefresh action is called from UserAuthActions.js component.

The API RefreshToken is called from UsersAuthApi.js.

Every time the refreshToken has expired while the user still log in, the axios getRefreshToken function is called from the authorizationUtils.js component.

The redux RefreshToken action is called with the model userAuth from the userAuthActions.js component.

The API Refresh is called from the usersAuthApi.js component.

If API Refresh returns OK, the redux setUserModel action sets the new values to the user currently logged in.

Finally the process is repeated in the step 1.

Refresh

Azure Function

This function is a HTTP Post and it is called with the route: permissions/Refresh

The ValidateToken function validates the token got from HTTP Post Refresh.

The Refresh function get a new token and refresh token.

React

The API Refresh is called from the usersAuthApi.js component.

If API Refresh returns OK, the redux setUserModel action sets the new values to the user currently logged in.

Finally the process is repeated in the Azure Function RefreshToken.

ChangePassword

Azure Function

This function is a HTTP Post and it is called  with the route: permissions/ChangePassword

A token parameter is got by a RequestUri with the name “changepasswordtoken”.

The token is validated only if it !IsNullorEmpty by the method ValidateToken.

If token IsNullorEmpty the user is validated by the function ValidateTokenAsync

The model parameter UsersSecretsDto is required to works.

Change the password with the method ChangePassword.

React

Case 1: User already logged in

The component topbar.js shows the change password view.

Create the model UsersSecretsDto with the front data view.

The redux changePassword action is called with the model from UserAuthActions.js.

The API ChangePassword is called with the model from UsersAuthApi.js.

Case 2: Using URL token created in ForgotPassword Azure Function.

The process start in the component verifyTokens.js.

Read the token contained in the URL created in ForgotPassword Azure Function.

The redux ChangePassword action is called with the model and token parameter from UserAuthActions.js.

The API ValidEmail is called with the model and token parameter from UsersAuthApi.js.

If token parameter is valid the password is updated.

Social (Google, Facebook and Microsoft)

Azure Function

This function is a HTTP Post and it is called with the route: permissions/SocialGoogle permissions/SocialFacebook and permissions/SocialMicrosoft

A dynamic data is read.

The methods GoogleValidateToken, FacebookValidateToken and MicrosoftValidateToken are used to validate the token.

React

The component CustomLogin.js shows the social login view.

Every social package create a dynamic response.

The redux SocialGoogle, SocialFacebook and SocialMicrosoft actions are called with the dynamic response from UserAuthActions.js.

The API SocialGoogle, SocialFacebook and SocialMicrosoft are called with the dynamic response from UsersAuthApi.js.

If user exist get a new Authorized token also get and set user settings finally get a new refresh token

ForgotPassword

Azure Function

This function is a HTTP Get and it is called with the route: permissions/ForgotPassword.

A email parameter is got by a RequestUri with the name “email“.

Get the token with the method ForgotPasswordOrRegister in order to be send it to the email.

// you can buid you custom address with the token generated

// example “https://mysite.com/onRoute/?changepasswordtoken=” + token

// and send an email to requester including the address in the email body

// you can call to change password api whit the token recived from email

// exmaple: “https://localhost/api/permissions/ChangePassword?token=” + token

// It is important use the parameter named token

// Remember not return the token only if has been calling internally by the server

// use return new OkResult(); instead

React

The component CustomLogin.js shows the front view.

The redux ForgotPassword action is called with email parameter from UserAuthActions.js.

The API ForgotPassword is called with the email from UsersAuthApi.js.

Nothing is returned but in the Azure Function a token is created for netwotk distribution for instance, via email.

ValidEmail

Azure Function

This function is a HTTP Post and it is called with the route: permissions/ValidEmail.

A token parameter is got by a RequestUri with the name “validEmailToken”.

If token is !IsNullOrEmpty the method ValidateToken is called.

The method ValidateRegisterEmail is called.

React

The process start in the component verifyTokens.js.

Read the token contained in the URL created in Register Azure Function.

The redux ValidEmail action is called with the token from UserAuthActions.js.

The API ValidEmail is called with the token from UsersAuthApi.js.

If token is valid the user is authorized.

ResendValidEmail

Azure Function

This function is a HTTP Post and it is called with the route: permissions/ResendValidEmail.

A token or resendEmail parameter are got by a RequestUri with the name “validEmailToken” or “email”.

If token is !IsNullOrEmpty the method ValidateTokenConfirmEmail is called.

Get a new token with the method ForgotPasswordOrRegister in order to be send it to the email.

// you can build you custom address with the token generated.
// example “https://mysite.com/onRoute/?validEmailToken=” + token
// and send an email to requester including the address in the email body
// you can call to change password api whit the token recived from email
// exmaple: “https://localhost/api/permissions/ValidEmail?token=” + token
// It is important use the parameter named token
// Remember not return the token only if has been calling internally by the server
// use return new OkResult(); instead

React

The component CustomLogin.js shows the front view.

Create the model UsersSecretsDto with the front data view.

The redux login action is called with the model from UserAuthActions.js.

The API Auth is called with the model from UsersAuthApi.js.

If user hasn’t valid the email yet.

Then the system asks about your valid email URL created in Register Azure Function or create a new one.

If the URL option was chosen the redux ResendValidEmail action with the email parameter from UserAuthActions.js.

The API ResendValidEmail is called with the email from UsersAuthApi.js.

Enviroment Variables

All of theses variables are in local.setting.json file and it is located in the path: C:\Trabajo\Barracuda\Examples\Auth\local.settings.json

DataBase

All the variables in this section are set to control the Cosmos DB.

DatabaseEndpoint

This variable is to set the direction to connect to the Cosmos DB.
"DatabaseEndpoint": "https://localhost:8081"

DatabaseSecretKey

This variable is to set the key to connect with the Cosmos DB.
"DatabaseSecretKey": "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw=="

DatabaseId

This variable is to set the id of the Cosmos DB.
"DatabaseId": "Delivers"

CollectionId

This Variable is to set the id of the Cosmos DB Collection.
"CollectionId": "Delivers"

PartitionKeyPath

This variable is to set the key path of the Cosmos DB partition.

"PartitionKeyPath": "/PartitionId"

Tokens

All of these variables in this section are set to control the tokens.

SecretKey

This variable  is to set the secret key.

"SecretKey": "letssecret"

JWTKey

This variable is to set the JSON Web Token key.
"JWTKey": "401b09eab3c013d4ca54922bb802bec8fd5318192b0a75f201d8b3727429090fb337591abd3e44453b954555b7a0812e1081c39b740293f765eae731f5a65ed1"

SessionsNumber

This variable is to set the number of sesions.
"SessionsNumber": 5

ExpiredTimeInSeconds

This variable is  to set the expiration time of the Auth token.

"ExpiredTimeInSeconds": "60"

ExpiredTimeInSecondsToForgetPasword

This variable is to set the expiration time of the forget password and email validation token.

"ExpiredTimeInSecondsToForgetPasword": "3600"

ExpiredTimeInSecondsToUserLocked

This variable is to set the expiration time for a user blocked.

"ExpiredTimeInSecondsToUserLocked": "20"

IUsser

This variable is to set the name of the issuing.

"IUsser": "Delivers"

Audencie

This variable is to set the public that is able to  receive data.

"Audencie": "AllUsers"

CookieToken

This variable is to set the name of the token used for client grant flow.

"CookieToken": "X-Access-Token"

CookieRefreshToken

This variable is to set the name of the refresh token used for the client grant flow.

"CookieRefreshToken": "X-Refresh-Token"

CookieTokenPath

This variable is to set the path of the token for client grant flow.

"CookieTokenPath": "/api"

CookieRefreshTokenPath

This variable is to set path of the refresh token for client grant flow.

"CookieRefreshTokenPath": "/api/permissions/Refresh"

Admins

The next variable is set to control de users admins.

BarracudaSuperAdmins

This variable is to set the users are going to be admins.
"BarracudaSuperAdmins": "demo2@demo.com,qwer"

Social

All of these variables in this section are set to control the login from social websites.

GoogleClientId

This variable is to set the client id from google in order to get the user data info for login.

"GoogleClientId": "860374859932-268aj3d6ir5nt7s2frmjig1kjuga6e89.apps.googleusercontent.com"

GoogleISSUER

This variable is to set the path to get the user data info from google in order to login.

"GoogleISSUER": "accounts.google.com"

GraphFacebook

This variable is to set the path to get the user data info from facebook in order to login.

"GraphFacebook": "https://graph.facebook.com/"

GraphMicrosoft

This variable is to set the path to get the user data info from microsoft in order to login.

"GraphMicrosoft": "https://graph.microsoft.com/v1.0/users"

Memory Cache

All of these variables in this section are set to control where the users data are going to be saved.

RedisCacheSecurity

This variable is to set redis cache to on.

"RedisCacheSecurity": true

RedisCacheConnection

This variable is to set the IP address and port for Redis Cache.
"RedisCacheConnection": "127.0.0.1:6379"

Example Barracuda Admin

These examples were tested in an React.js application and the UsersSecrects.Functions.csproj they are in our solution Barracuda. The objective is make you know how to adapt your code with the product Barracuda Identity Provider. We will show how to interact with Azure Functions, OAuth 2.0 and openid protocols.

Click in this link to watch a video with the instructions to download the solution Barracuda.

UsersSecrects.Functions.csproj

This project will show you how to use the Azure Functions, OAuth 2.0 and openid protocols with the Package Barracuda Identity Provider.
This project is located in the next Path in the solution Barracuda: Barracuda\Examples\Auth\UsersSecrets.Functions.csproj.

All Azure Functions are located in the file: Barracuda\Examples\Auth\UsersSecretsFunctions.cs

React

This application is used to test the Azure Functions examples in the project UsersSecrects.Functions.csproj and it is located in the path: Barracuda\Examples\React\React.csproj Components: users is located in the path: Barracuda\Examples\React\Source\src\components\users\users.js customChangePassword is located in the path: Barracuda\Examples\React\Source\src\components\common\customChangePassword.js

ValidAdmin

This method check if the user has scopes.

private Result<bool> validAdmin(HttpRequestMessage req, HttpRequest request, List<string> scopes)

AddUser

Azure Function

This function is a HTTP Post and it is called with the route: permissions/AddUser.

The method validAdmin is called.

The model UsersSecretsDTO is created.

The method Register is called.

React

The component users.js shows the front view.

The component addedituser.js is called.

Create the model UsersSecretsDto with the front data view.

The API AddUser is called with the model from UsersAuthApi.js.

DeleteUser

Azure Function

This function is a HTTP Delete and it is called with the route: permissions/DeleteUser/{id}.

The method validAdmin is called.

The model UsersSecretsDTO is created.

The method DeleteUser is called.

React

The component users.js shows the front view.

The API DeleteUser is called with the user id from UsersAuthApi.js.

UpdateScopes

Azure Function

This function is a HTTP Post and it is called with the route: permissions/UpdateScopes.

The method validAdmin is called.

The model LoginDto is created.

The method UpdateScopes is called.

React

The component addedituser.js shows the front view.

Create the model LoginDto.

The API Scopes is called with the model from UsersAuthApi.js.

UpdateTenants

Azure Function

This function is a HTTP Post and it is called with the route: permissions/UpdateTenants.

The method validAdmin is called.

The model LoginDto is created.

The method UpdateTenants is called.

React

The component addedituser.js shows the front view.

Create the model LoginDto.

The API Tenants is called with the model from UsersAuthApi.js.

ChangePasswordToUser

Azure Function

This function is a HTTP Post and it is called with the route: permissions/ChangePasswordToUser.

The model UsersSecretsDTO is created.

The method validAdmin is called.

The method ChangePassword is called.

React

The component users.js shows the front view.

The component customChangePassword.js is called.

The model UsersSecretsDto is created.

The API ChangePasswordToUser is called with the model from UsersAuthApi.js.

BlockUser

Azure Function

This function is a HTTP Post and it is called with the route: permissions/BlockUser.

The method validAdmin is called.

The model LoginDto is created.

The method BlockUser is called.

React

The component addedituser.js shows the front view.

Create the model LoginDto.

The API BlockUser is called with the model from UsersAuthApi.js.

GetAdditional

Azure Function

This function is a HTTP Get and it is called with the route: permissions/GetAdditional/{id}.

The method validAdmin is called.

The method GetAdditional is called.

React

The component addedituser.js shows the front view.

The Auth GetAdditional action is called with the user id from UsersAuthApi.js.

GetBatchAdditional

Azure Function

This function is a HTTP Post and it is called with the route: permissions/GetBatchAdditional.

The method validAdmin is called.

The method GetBatchAdditional is called.

React

The component users.js shows the front view.

The Auth GetBatchAdditional action is called with the user id from UsersAuthApi.js.

CheckEmail

Azure Function

This function is a HTTP Get and it is called with the route: permissions/CheckEmail/{email}.

The method CheckEmail is called.

React

The component addedituser.js shows the front view.

The API CheckEmail is called with the user email from UsersAuthApi.js.

Example Users Admin

These examples were tested in an application React.js and the Users.Functions.csproj they are in our solution Barracuda.

The objective is make you know how to adapt your code with the product Barracuda Identity Provider.

We will show how to interact with Azure Functions, OAuth 2.0 and openid protocols.

Click in this link to watch a video with the instructions to download the solution Barracuda.

Users.Functions.csproj

This project will show you how to use the Azure Functions, OAuth 2.0 and openid protocols with the Package Barracuda Identity Provider.

This project is located in the next Path in the solution Barracuda: Barracuda\Examples\Users\Users.Functions\Users.Functions.csproj

All Azure Functions are located in the file: Barracuda\Examples\Users\Users.Functions\UsersFunctions.cs

React

This application is used to test the Azure Functions examples in the project Users.Functions.csproj and it is located in the path: Barracuda\Examples\React\React.csproj

Components:

profile is located in the path: Barracuda\Examples\React\Source\src\components\profiles\profile.js

bottomBar is located in the path: Barracuda\Examples\React\Source\src\components\layout\bottomBar.js

usersApi is located in the path: Barracuda\Examples\React\Source\src\api\usersApi.js

addedituser is located in the path: Barracuda\Examples\React\Source\src\components\users\addedituser.js

users is located in the path: Barracuda\Examples\React\Source\src\components\users\users.js

Models

UserModel

This class contains the user personal data to be saved.

{
  public string Name { get; set; }
  public string Username { get; set; }
  public string country { get; set; }
  public string state { get; set; }
  public string city { get; set; }
  public string Licence { get; set; }
  public string insurance { get; set; }
  public bool Photo { get; set; }
  public string identification { get; set; }
}

QueryInputModel

This class contains the user query model
{
  public string Query { get; set; }
  public string ContinuationToken { get; set; }
}

UserQueryModel

This class contains the user model.

{
public IEnumerable<UserModel> models { get; set; }
public string ContinuationToken { get; set; }
}

IUserApplication Interface

Create

This function save the user personal data in the Cosmos DB.
public Task<Result<string>> Create(UserModel item);

Get

This function get the user from Cosmos DB.
public Task<Result<UserModel>> Get(string id);

UpdateUser

This function update the user data in the Cosmos DB.
public Task<Result<string>> Update(UserModel item);

GetAll

This function get all users from Cosmos DB.
public Task<Result<UserQueryModel>> GetAll(QueryInputModel query, CancellationToken token);

Delete

This function delete a user from Cosmos DB.
public Task<Result<string>> Delete(string id);

Third Party Classes

System.Collections.Generic.IEnumerable

Exposes an enumerator, which supports a simple iteration over a non-generic collection.

System.Threading.CancellationToken

Propagates notification that operations should be canceled.

Users Functions

Scopes

Azure Function

This function is a HTTP Post and it is called  with the route: permissions/UpdateScopes

The user currently logged in is validated with the function validAuthorized in order to pass the parameters to the function ValidateTokenAsync.

Optional: The  validScopes function sets the roles for the users to be created.

The model parameter LoginDto is created.

The  UpdateScopes function updates the role of users in the Cosmos DB.

React

the addedituser.js component shows the front view.

Only an user registered with the scope BarracudaSuperAdmin or any of the next scopes like user.create, users.update can create or update an user with the scope according to the role.

CreateUser

Azure Function

This function is a HTTP Post and it is called  with the route: users/Create

The user currently logged in is validated with the function validAuthorized in order to pass the parameters to the function ValidateTokenAsync.

The UserModel model is created.

The Create function save the user in the Cosmos DB.

React

The profile.js component shows the front user data view in order to create the UserModel object.

The bottomBar.js component shows the front view.

The API CreateUser is called with the model from usersApi.js

GetUser

Azure Function

This function is a HTTP Get and it is called  with the route: users/Get/{id}

The user currently logged in is validated with the function validAuthorized in order to pass the parameters to the function ValidateTokenAsync.

The Get function get the user from Cosmos DB.

React

The profile.js component shows the front user data view.

The API Get is called with the model from usersApi.js

UpdateUser

Azure Function

This function is a HTTP Put and it is called  with the route: users/Update

The user currently logged in is validated with the function validAuthorized in order to pass the parameters to the function ValidateTokenAsync.

The UserModel model is created.

The Get function get the user from Cosmos DB.

React

the addedituser.js component shows the front view.

The API Update is called with the model from usersApi.js

GetAll

Azure Function

This function is a HTTP Post and it is called  with the route: users/GetAll

The user currently logged in is validated with the function validAuthorized in order to pass the parameters to the function ValidateTokenAsync.

The QueryInputModel model is created.

The GetAll function get the user from Cosmos DB.

React

The users.js component shows the front user data view.

The API GetAll is called with the model from usersApi.js

DeleteUser

Azure Function

This function is a HTTP Delete and it is called  with the route: users/Delete/{id}

The user currently logged in is validated with the function validAuthorized in order to pass the parameters to the function ValidateTokenAsync.

The Delete function deletes the user from Cosmos DB.

React

the users.js component shows the front view.

The API Delete is called with the id from usersApi.js

Scopes Description

This section explains how to set the scopes for users according to their roles, this way you can control how many user types can configure the system according to the requirements.

For instance the organization chart below explains the users scopes according to the roles.

BarracudaSuperAdmin has all the permissions and this variable is set in the file local.settings.json.

local.settings.json is located in the path: Barracuda\Examples\Auth\local.settings.json

React

the addedituser.js component shows the front view.

Only an user registered with the scope BarracudaSuperAdmin or any of the next scopes like user.create, users.update can create or update an user with the scope according to the role.

Tenants Description

This section explains how to set the tenants for users according to their roles, this way you can control how many users have access in an especific tenant according to the requirements.

For instance the organization chart below explains the tenants according to the roles.

BarracudaSuperAdmin has all the permissions and this variable is set in the file local.settings.json.

local.settings.json is located in the path: Barracuda\Examples\Auth\local.settings.json

React

the addedituser.js component shows the front view.

Only an user registered with the scope BarracudaSuperAdmin or any of the next scopes like user.create, users.update can create or update an user with the tenant according to the role.

Video Tutorials

Download Barracuda from Github

In this video tutorial you will be guide step by step to how to clone the solucion Barracuda source code and examples from the website Github.

https://github.com/jelzGames/Barracuda

Barracuda Identity Provider

In this video you will see all the azure functions available for the authentification method Single Sign On (SSO) and azure functions available for admin users included in the Barracuda Identity Provider Package.

Create Certificate

There is a ReadMe.md file that contains extra information to know how to create a certificate for your application.

The ReadMe.md file is located in the path: Barracuda/blob/main/Examples/React/Source/README.md

Next Open API Package
Table of Contents