Skip to content

compiuta-origin/connhex-firebase-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Connhex Firebase Examples

Firebase Cloud Functions examples and starter code for building custom Connhex integrations.

Clone this repository, configure Firebase and Connhex, then replace or extend the example functions with your own integration logic. The examples show how to wrap Connhex APIs in custom server-side lambda functions that can be called by apps, automations, or other backends.

Structure

functions/
  main.py                 # Firebase exports only
  connhex/                # Shared Connhex client/auth helpers
  examples/               # One module per integration example

Examples

Bearer token team onboarding

onboard_user_to_team adds a Connhex identity to a Connhex IAM team using a caller-provided Connhex bearer token.

This example requires an Authorization: Bearer <connhex-user-token> header. It uses the caller's Connhex bearer token for both authorization and the team API call.

Request

curl -X POST "https://<region>-<firebase-project>.cloudfunctions.net/onboard_user_to_team" \
  -H "Authorization: Bearer <connhex-user-token>" \
  -H "Content-Type: application/json" \
  -d '{
    "teamId": "my-team",
    "membershipId": "connhex-identity-id"
  }'

Required Connhex permissions

The function checks these pairs through POST /iam/introspect_pairs before making any team changes:

  • resource iam:teams:{teamId}, action iam:teams:get
  • resource iam:teams:{teamId}, action iam:teamUsers:list
  • resource iam:teams:{teamId}, action iam:teamUsers:create

Deployment

Firebase uses .firebaserc to decide which Firebase project receives deployments from this folder.

Copy the example file:

cp .firebaserc.example .firebaserc

Then replace your-firebase-project-id with your Firebase project ID:

{
  "projects": {
    "default": "my-firebase-project-id"
  }
}

Copy the local example environment file:

cd functions
cp ../.env.example .env

Then set the required environment variables in the .env file:

CONNHEX_DOMAIN=your-connhex-domain

Python environment for deployment

Firebase expects the Python virtual environment inside the functions folder to be named venv when deploying Python functions.

Create it and install the function dependencies before deploying:

cd functions
python -m venv venv
. venv/bin/activate
pip install -r requirements.txt

Deploy all functions

You can deploy all functions with:

cd ..
firebase login
firebase deploy --only functions

Deploy a target function

You can deploy only a target function (e.g: onboard_user_to_team) with:

firebase deploy --only functions:onboard_user_to_team

The deployed endpoint will look like this:

https://<region>-<firebase-project-id>.cloudfunctions.net/onboard_user_to_team

About

Firebase Cloud Functions examples and starter code for building custom Connhex integrations

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages