Skip to content

ferronicardoso/poc-oci-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

OCI Vault Secret Reader - POC

Oracle Cloud License: MIT

Proof of Concept (POC) - Integration examples with OCI Vault Secrets in multiple programming languages.

This repository contains functional implementations to retrieve secrets from Oracle Cloud Infrastructure (OCI) Vaults using different programming languages. Each implementation demonstrates best practices and language-specific patterns.


πŸ“‹ Table of Contents


🎯 Overview

This project provides practical examples of how to access secrets stored in OCI Vault through console applications in:

  • .NET 9 (C#)
  • Python 3.8+
  • Node.js 18+ (JavaScript/ES Modules)
  • Java 17+ (Maven)

All implementations:

  • βœ… Use authentication via OCI configuration file
  • βœ… Decode secrets in Base64 format
  • βœ… Implement robust error handling
  • βœ… Follow best practices for each language
  • βœ… Are production-ready

πŸ“¦ Prerequisites

General

  • Active Oracle Cloud Infrastructure account
  • Read permissions on OCI Vault
  • OCI configuration file (~/.oci/config)
  • OCI API private key

By Language

Language Requirements
.NET .NET 9 SDK
Python Python 3.8+ and pip
JavaScript Node.js 18.0+ and npm
Java Java 17+, Maven 3.6+

πŸ” OCI Configuration

Before running any implementation, configure your OCI credentials:

1. Create the configuration file

mkdir -p ~/.oci
touch ~/.oci/config

2. Configure the ~/.oci/config file

[DEFAULT]
user=ocid1.user.oc1..xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
fingerprint=xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx
tenancy=ocid1.tenancy.oc1..xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
region=sa-saopaulo-1
key_file=~/.oci/oci_api_key.pem

3. Add your private key

Place your API private key in the path specified in key_file:

chmod 600 ~/.oci/oci_api_key.pem

πŸš€ Available Implementations

🟦 .NET 9 (C#)

.NET

Implementation using .NET 9 with official OCI SDK.

πŸ“– Complete Documentation

cd dotnet/OciVaultSecretReader
dotnet run -- <secret-ocid>

🟨 Python

Python

Python implementation using OCI Python SDK with type hints.

πŸ“– Complete Documentation

cd python/oci-vault-secret-reader
pip install -r requirements.txt
python oci_vault_secret_reader.py <secret-ocid>

🟩 Node.js (JavaScript)

Node.js

Node.js implementation using ES Modules and OCI SDK.

πŸ“– Complete Documentation

cd javascript/oci-vault-secret-reader
npm install
node index.js <secret-ocid>

β˜• Java (Maven)

Java

Java 17+ implementation with Maven and OCI Java SDK.

πŸ“– Complete Documentation

cd java/oci-vault-secret-reader
mvn clean package
java -jar target/oci-vault-secret-reader-1.0.0.jar <secret-ocid>

πŸ“ Project Structure

PocOciSdk/
β”œβ”€β”€ README.md                              # This file
β”œβ”€β”€ LICENSE                                # MIT License
β”œβ”€β”€ .gitignore
β”‚
β”œβ”€β”€ dotnet/                                # .NET Implementation
β”‚   β”œβ”€β”€ OciVaultSecretReader/
β”‚   β”‚   β”œβ”€β”€ Program.cs
β”‚   β”‚   β”œβ”€β”€ OciVaultSecretReader.csproj
β”‚   β”‚   └── .gitignore
β”‚   └── README.md
β”‚
β”œβ”€β”€ python/                                # Python Implementation
β”‚   β”œβ”€β”€ oci-vault-secret-reader/
β”‚   β”‚   β”œβ”€β”€ oci_vault_secret_reader.py
β”‚   β”‚   β”œβ”€β”€ requirements.txt
β”‚   β”‚   └── .gitignore
β”‚   └── README.md
β”‚
β”œβ”€β”€ javascript/                            # Node.js Implementation
β”‚   β”œβ”€β”€ oci-vault-secret-reader/
β”‚   β”‚   β”œβ”€β”€ index.js
β”‚   β”‚   β”œβ”€β”€ package.json
β”‚   β”‚   └── .gitignore
β”‚   └── README.md
β”‚
└── java/                                  # Java Implementation
    β”œβ”€β”€ oci-vault-secret-reader/
    β”‚   β”œβ”€β”€ src/main/java/com/example/oci/
    β”‚   β”‚   └── OciVaultSecretReader.java
    β”‚   β”œβ”€β”€ pom.xml
    β”‚   └── .gitignore
    └── README.md

πŸ’‘ How to Use

Step 1: Clone the Repository

git clone <repository-url>
cd PocOciSdk

Step 2: Configure OCI

Follow the instructions in OCI Configuration.

Step 3: Choose an Implementation

Navigate to the desired language directory and follow the specific instructions in the corresponding README.

Step 4: Execute

All implementations follow the same usage pattern:

<execution-command> <secret-ocid>

OCID Example:

ocid1.vaultsecret.oc1.sa-saopaulo-1.amaaaaaaaswkexiaspam2smuu5siwrmp346xirulfeyw3qung3xfj5tsbkia

Expected Output

=== OCI Vault Secret Reader ===

Fetching secret: ocid1.vaultsecret.oc1.sa-saopaulo-1.xxxxx...

Secret retrieved successfully!
Secret ID: ocid1.vaultsecret.oc1.sa-saopaulo-1.xxxxx
Version: 1
Stages: CURRENT
Creation time: 2025-10-23T10:00:00.000Z

Secret Value:
<your-secret-value-here>

πŸ“š Additional Resources


🀝 Contributing

Contributions are welcome! Feel free to:

  1. Fork the project
  2. Create a branch for your feature (git checkout -b feature/MyFeature)
  3. Commit your changes (git commit -m 'Add MyFeature')
  4. Push to the branch (git push origin feature/MyFeature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License. See the LICENSE file for details.


✨ Project Status

Language Status Last Update
.NET 9 βœ… Functional 2025-10-23
Python βœ… Functional 2025-10-23
JavaScript βœ… Functional 2025-10-23
Java βœ… Functional 2025-10-23

Developed by Raphael A. F. Cardoso

⬆ Back to top