Skip to main content
All CollectionsIntegrations
Integrating Custom Door Access app with Archie
Integrating Custom Door Access app with Archie

Setting up your custom door access

Camilo avatar
Written by Camilo
Updated over a week ago

We’ve recently introduced an new feature that lets you integrate a custom door access app with Archie. In this article, we’ll walk you through how this feature works and outline the steps required to complete the integration process.

If you're setting up custom door access with Archie, you'll need to configure a few key components. Here are the steps on how to do it.

Step 1. Configure Your Redirect URL

When setting up custom door access, you'll need to provide a URL where Archie will redirect users when they click on the "Key" icon in the mobile app. This URL is important as it handles the authentication and access request for the door.

Once you have the URL set, go to "Settings/Integrations/App marketplace", click the "Door access" tab, and click "View Integration" under "Custom door access", and click "Setup custom door access".

Proceed to add a Name to identify this entry, and the URL.

Step 2. Handling the Redirect URL

When a user clicks the "Key" icon, the Archie app will open a WebView that directs to the URL you specified. The URL will include a param "data" which is encrypted with a private key (given in your custom integration page).

Step 3. Decrypting the Data

The data object will contain the user object and the space object, you will have to decrypt it with the key to get the JSON data. Form there, you can use Archie API and the provider API to get the data needed to open the door on your provider. For instance you could get the user, verify if he has a subscription or any other information to display the right doors and open the door in the provider with their API.

To access the Archie API, go to "Settings/Integrations/Developer portal", you can then proceed to create an application that will give you a Client ID and Client Secret key to generate an access token to access the Archie API.

Here are some examples Decrypt functions.

// DecryptMessage : decrypt message with AES from base64 encoded string
func DecryptMessage(secret string, encrypted string)(string, error) {
ciphertext, _: = base64.StdEncoding.DecodeString(encrypted)
// create a 32 byte long key from the secret. Note that extra bytes are ignored if the secret is longer than 32 bytes
key: = [] byte(secret)[: 32]
c, err: = aes.NewCipher(key)
if err != nil {
return "", err
}
gcm, err: = cipher.NewGCM(c)
if err != nil {
return "", err
}
nonceSize: = gcm.NonceSize()
if len(ciphertext) < nonceSize {
return "", errorsP.New("ciphertext is too short")
}
nonce, ciphertext: = ciphertext[: nonceSize], ciphertext[nonceSize: ]
plaintext, err: = gcm.Open(nil, nonce, ciphertext, nil)
if err != nil {
panic(err)
}
return string(plaintext), nil
}

In JavaScript (Node.js):

// DecryptMessage : decrypt message with AES from base64 encoded string

function DecryptMessage(secret, encrypted) {
const ciphertext = Buffer.from(encrypted, 'base64');
// create a 32 byte long key from the secret. Note that extra bytes are ignored if the secret is longer than 32 bytes
const key = Buffer.from(secret).slice(0, 32);
const cipher = crypto.createCipheriv('aes-256-gcm', key, '');
const nonceSize = cipher.getAuthTag().length;

if (ciphertext.length < nonceSize) {
throw new Error('ciphertext is too short');
}

const nonce = ciphertext.slice(0, nonceSize);
const ciphertextToDecrypt = ciphertext.slice(nonceSize);
const plaintext = cipher.decrypt(nonce, ciphertextToDecrypt, null);
return plaintext.toString();
}

Did this answer your question?