LogoLogo
Ockam.ioOpen Source CodeContact usSign up
  • Intro to Ockam
  • Ockam's core concepts
  • Get started demo
  • Quickstarts
    • Add secure connectivity to your SaaS product
    • Snowflake federated queries to Postgres
    • Postgres to Snowflake
    • Snowflake to Postgres
    • Kafka to Snowflake
    • Snowflake to Kafka
    • Snowflake stage as SFTP server
    • Snowflake stage as WebDAV file share
    • Snowflake hosted private APIs
    • Federated queries from Snowflake
  • ENCRYPTED PORTALS TO ...
    • Databases
      • PostgreSQL
        • Docker
        • Kubernetes
        • Amazon RDS
        • Amazon Aurora
      • MongoDB
        • Docker
        • Kubernetes
        • Amazon EC2
      • InfluxDB
        • Amazon Timestream
    • APIs
      • Nodejs
      • Python
    • AI
      • Amazon Bedrock
      • Amazon EC2
      • Azure OpenAI
    • Code Repos
      • Gitlab Enterprise
    • Kafka
      • Apache Kafka
        • Docker
      • Redpanda
        • Self Hosted
      • Confluent
        • Cloud
      • Warpstream
        • Cloud
      • Instaclustr
        • Cloud
      • Aiven
        • Cloud
  • Reference
    • Command
      • Nodes and Workers
      • Routing and Transports
      • Relays and Portals
      • Identities and Vaults
      • Secure Channels
      • Verifiable Credentials
      • Guides
        • AWS Marketplace
          • Ockam Node
          • Ockam Node for Amazon MSK
          • Ockam Node for Amazon RDS Postgres
          • Ockam Node for Amazon Timestream InfluxDB
          • Ockam Node for Amazon Redshift
          • Ockam Node for Amazon Bedrock
      • Manual
    • Programming Libraries
      • Rust
        • Nodes and Workers
        • Routing and Transports
        • Identities and Vaults
        • Secure Channels
        • Credentials and Authorities
        • Implementation and Internals
          • Nodes and Workers
        • docs.rs/ockam
    • Protocols
      • Nodes and Workers
      • Routing and Transports
      • Keys and Vaults
      • Identities and Credentials
      • Secure Channels
      • Access Controls and Policies
Powered by GitBook
On this page
  • Run
  • Walkthrough
  • Administrator
  • Bank Corp
  • Analysis Corp
  • Recap
  • Cleanup

Was this helpful?

Edit on GitHub
Export as PDF
  1. ENCRYPTED PORTALS TO ...
  2. Code Repos

Gitlab Enterprise

PreviousCode ReposNextKafka

Last updated 11 months ago

Was this helpful?

Let's connect a nodejs app in one company's Amazon VPC with a CodeRepository hosted on a Gitlab Server in another company's Amazon VPC. The example uses AWS CLI to create these VPCs.

Each company’s network is private, isolated, and doesn't expose ports. To learn how end-to-end trust is established, please read: “”

Run

Then run the following commands:

# Clone the Ockam repo from Github.
git clone --depth 1 https://github.com/build-trust/ockam && cd ockam

# Navigate to this example’s directory.
cd examples/command/portals/coderepos/gitlab/amazon_ec2/aws_cli

# Run the example, use Ctrl-C to exit at any point.
./run.sh

If everything runs as expected, you'll see the message: The example run was successful 🥳

Walkthrough

Administrator

  • In a typical production setup an administrator or provisioning pipeline generates enrollment tickets and gives them to nodes that are being provisioned. In our example, the run function is acting on your behalf as the administrator of the Ockam project.

Bank Corp

First, the bank_corp/run.sh script creates a network to host the database:

We are now ready to create an EC2 instance where the Gitlab server and Ockam outlet node will run:

When the instance is started, the run_gitlab.sh script is executed:

    • Password can be used to access the gitlab console from local machine

When the instance is started, the run_ockam.sh script is executed:

  • We then create an Ockam node:

Analysis Corp

First, the analysis_corp/run.sh script creates a network to host the nodejs application:

We are now ready to create an EC2 instance where the Ockam inlet node will run:

The instance is started and the run_repoaccess.sh script is executed:

The instance is started and the run_ockam.sh script is executed:

  • We then create an Ockam node:

We finally wait for the instance to be ready and install the nodejs application:

Once the nodejs application is started:

Recap

We connected a nodejs app in one virtual private network with a Gitlab CodeRepository in another virtual private network over an end-to-end encrypted portal.

Analysis Corp. does not get unfettered access to Bank Corp.’s network. It gets access only to the codebase hosted on the Gitlab server. Bank Corp. does not get unfettered access to Analysis Corp.’s network. It gets access only to respond to queries over a tcp connection. Bank Corp. cannot initiate connections.

Cleanup

To delete all AWS resources:

./run.sh cleanup

This example requires Bash, Git, AWS CLI, Influx CLI, jq. Please set up these tools for your operating system. In particular you need to with aws sso login.

The , that you ran above, and its are full of comments and meant to be read. The example setup is only a few simple steps, so please take some time to read and explore.

The calls the which invokes the to create an new identity, sign into Ockam Orchestrator, set up a new Ockam project, make you the administrator of this project, and get a project membership .

The run function then . The tickets are valid for 10 minutes. Each ticket can be redeemed only once and assigns to its redeemer. The is meant for the Ockam node that will run in Bank Corp.’s network. The is meant for the Ockam node that will run in Analysis Corp.’s network.

The run function passes the enrollment tickets as variables of the run scripts provisioning and .

We and tag it.

We and attach it to the VPC.

We and to the Internet via the gateway.

We , and associated to the route table.

We finally so that there is:

,

from the local machine running the example, to access Gitlab on port 22 and 80.

An SSH keypair to access gitlab repository is created and, .

We .

We to access EC2 and to obtain gitlab password to be able to login to gitlab console.

We above and a start script based on run_ockam.sh and run_gitlab.sh where:

created by the administrator and given as a parameter to run.sh.

in run_gitlab.sh script

We and .

We wait for 3 minutes for gitlab to be setup and

.

.

.

.

.

.

The .

The .

With .

A . The policy authorizes identities with a credential containing the attribute gitlab-inlet="true".

With capable of forwarding the TCP traffic to the TCP outlet.

We and tag it.

We and attach it to the VPC.

We and to the Internet via the gateway.

We , and associated to the route table.

We finally so that there is:

,

And to download and install the nodejs application from local machine running the script.

We .

We above and a start script based on run_ockam.sh where:

created by the administrator and given as a parameter to run.sh.

The is created on the EC2 with details of the private SSH key and permissions are updated

The .

The .

With .

A . The policy authorizes identities with a credential containing the attribute gitlab-outlet="true".

The has code to access the code repository on port 1222 configured

We can then and:

.

.

.

.

It will .

It that clones the repository, makes sure README.md file exists, inserts a line to the README.md file, does a commit and push the commit to the remote gitlab server.

Sensitive business data in the Gitlab Codebase is only accessible to Bank Corp. and Analysis Corp. All data is with strong forward secrecy as it moves through the Internet. The communication channel is and . Keys and credentials are automatically rotated. Access to connect with InfluxDB can be easily revoked.

All are secure-by-default. Only project members, with valid credentials, can connect with each other. NAT’s are traversed using a relay and outgoing tcp connections. Bank Corp. or Analysis Corp. don’t expose any listening endpoints on the Internet. Their networks are completely closed and protected from any attacks from the Internet.

login to your AWS account
run.sh script
accompanying files
Bank Corp.'s network
Analysis Corp.'s network
create a VPC
create an Internet gateway
create a route table
create a route
create two subnets, located in two distinct availability zones
create a security group
one TCP egress to the Internet
one ingress to EC2 running Gitlab
the public key is saved in a variable
select an AMI
create an ec2 keypair
start an instance using the AMI
ENROLLMENT_TICKET is replaced by the enrollment ticket
SSH_PUBLIC_KEY is replaced with the Public IP of the EC2 instance
tag the created instance
wait for it to be available
check it's availability
Gitlab and it's dependencies are installed
Gitlab SSH Port is mapped to 222
Obtain gitlab root password to create access token
Disable public signups
Create demo_project
Configure access via created SSH Key
ockam executable is installed
enrollment ticket is used to create a default identity and make it a project member
a TCP outlet
policy associated to the outlet
a relay
create a VPC
create an Internet gateway
create a route table
create a route
create a subnet
create a security group
One TCP egress to the Internet
One SSH ingress
select an AMI
start an instance using the AMI
ENROLLMENT_TICKET is replaced by the enrollment ticket
ssh config file
ockam executable is installed
enrollment ticket is used to create a default identity and make it a project member
a TCP inlet
policy associated to the inlet
app.js file
in tcp inlet
SSH to the instance
Copy app.js
Copy SSH Private key for Repository access
Install nodejs
Start the nodejs application
connect to the Ockam inlet at port 1222
executes the run function
encrypted
mutually authenticated
authorized
access controls
How does Ockam work?
run.sh script
run function
enroll command
generates two new enrollment tickets
first ticket
second ticket
credential
attributes