Skip to content

Commit 284f49a

Browse files
committed
cicd: add mkdocs deployment
1 parent d910af2 commit 284f49a

22 files changed

Lines changed: 1207 additions & 1 deletion

codes/ldap-to-postgres.py

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
import ldap3
2+
import psycopg2
3+
from psycopg2 import sql
4+
5+
# LDAP connection settings
6+
LDAP_SERVER = "ldaps://192.168.0.144:1636"
7+
LDAP_BASE_DN = "o=gluu"
8+
LDAP_BIND_DN = "cn=directory manager"
9+
LDAP_PASSWORD = "#####"
10+
11+
# PostgreSQL connection settings
12+
PG_HOST = "192.168.0.145"
13+
PG_PORT = "5432"
14+
PG_DATABASE = "gluudb"
15+
PG_USER = "gluu"
16+
PG_PASSWORD = "#####"
17+
18+
def connect_ldap():
19+
server = ldap3.Server(LDAP_SERVER, use_ssl=True, get_info=ldap3.ALL)
20+
ldap_conn = ldap3.Connection(server, LDAP_BIND_DN, LDAP_PASSWORD, auto_bind=True, client_strategy='SYNC')
21+
ldap_conn.open()
22+
ldap_conn.bind()
23+
return ldap_conn
24+
25+
def connect_postgresql():
26+
return psycopg2.connect(
27+
host=PG_HOST,
28+
port=PG_PORT,
29+
database=PG_DATABASE,
30+
user=PG_USER,
31+
password=PG_PASSWORD
32+
)
33+
34+
def extract_ldap_data(ldap_conn):
35+
search_filter = "(objectClass=*)"
36+
attributes = ["*"]
37+
print("searching for data")
38+
ldap_conn.search(
39+
search_base=LDAP_BASE_DN,
40+
search_scope=ldap3.SUBTREE,
41+
search_filter=search_filter,
42+
attributes=attributes
43+
)
44+
print("data extracted")
45+
for entry in ldap_conn.response:
46+
print(entry)
47+
return ldap_conn.response
48+
49+
def transform_data(ldap_data):
50+
print("transforming data")
51+
transformed_data = []
52+
for dn, attrs in ldap_data:
53+
record = {
54+
"dn": dn,
55+
"attributes": {k: v[0].decode() if isinstance(v[0], bytes) else v[0] for k, v in attrs.items() if v}
56+
}
57+
transformed_data.append(record)
58+
print("data transformed")
59+
return transformed_data
60+
61+
def create_table(pg_conn):
62+
with pg_conn.cursor() as cur:
63+
cur.execute("""
64+
CREATE TABLE IF NOT EXISTS ldap_data (
65+
id SERIAL PRIMARY KEY,
66+
dn TEXT,
67+
attributes JSONB
68+
)
69+
""")
70+
pg_conn.commit()
71+
72+
def load_data_to_postgresql(pg_conn, transformed_data):
73+
with pg_conn.cursor() as cur:
74+
for record in transformed_data:
75+
cur.execute(
76+
sql.SQL("INSERT INTO ldap_data (dn, attributes) VALUES (%s, %s)"),
77+
(record["dn"], psycopg2.Json(record["attributes"]))
78+
)
79+
pg_conn.commit()
80+
81+
def main():
82+
ldap_conn = connect_ldap()
83+
pg_conn = connect_postgresql()
84+
85+
try:
86+
ldap_data = extract_ldap_data(ldap_conn)
87+
print("extracted ldap data: ", ldap_data)
88+
transformed_data = transform_data(ldap_data)
89+
print("transformed data: ", transformed_data)
90+
91+
create_table(pg_conn)
92+
print("created table")
93+
except Exception as e:
94+
print(e)
95+
96+
97+
# load_data_to_postgresql(pg_conn, transformed_data)
98+
99+
# print("Migration completed successfully.")
100+
# finally:
101+
# ldap_conn.unbind_s()
102+
# pg_conn.close()
103+
104+
if __name__ == "__main__":
105+
main()

docs/blogs/index.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
blog:
3+
pagination: true
4+
pagination_per_page: 6
5+
---
6+
7+
# DevOps Blogs
8+
9+
<div class="blog-hero">
10+
<h2>🚀 DevOps Insights & Tutorials</h2>
11+
<p>Practical guides and real-world experiences</p>
12+
</div>
13+
14+
<style>
15+
.blog-hero {
16+
text-align: center;
17+
padding: 1rem;
18+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
19+
color: white;
20+
border-radius: 8px;
21+
margin-bottom: 1.5rem;
22+
}
23+
24+
.blog-hero h2 {
25+
margin: 0 0 0.5rem 0;
26+
font-size: 1.8rem;
27+
}
28+
29+
.blog-hero p {
30+
margin: 0;
31+
font-size: 1rem;
32+
opacity: 0.9;
33+
}
34+
</style>
35+
36+
## ✍️ Writing Guidelines
37+
38+
!!! tip "Create a New Blog Post"
39+
1. Create a new `.md` file in `docs/blogs/posts/`
40+
2. Add frontmatter with metadata:
41+
```yaml
42+
---
43+
date: 2024-01-15
44+
categories:
45+
- Infrastructure
46+
- Tutorial
47+
authors:
48+
- your-name
49+
---
50+
```
51+
3. Write your content in Markdown
52+
4. Use `<!-- more -->` to create post excerpts
53+
5. The blog will automatically appear on this page
54+
55+
## Latest Blogs
56+
<!-- BLOG-POST-LIST:START -->
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
---
2+
date: 2024-01-10
3+
categories:
4+
- Security
5+
- Git
6+
- Tutorial
7+
---
8+
9+
# Git Commit Signature Verification
10+
11+
Learn how to set up GPG commit signing to verify the authenticity of your Git commits and enhance your repository security.
12+
13+
<!-- more -->
14+
15+
## Why Sign Your Commits?
16+
17+
- **Authentication**: Prove commits are actually from you
18+
- **Integrity**: Ensure commits haven't been tampered with
19+
- **Trust**: Build confidence in your codebase
20+
- **Compliance**: Meet security requirements for sensitive projects
21+
22+
## Prerequisites
23+
24+
Install GnuPG on your system:
25+
26+
```bash
27+
sudo apt-get install gnupg
28+
```
29+
30+
## Step 1: Generate GPG Key
31+
32+
Create a new GPG key pair with your details:
33+
34+
```bash
35+
gpg --full-generate-key
36+
```
37+
38+
Choose:
39+
40+
- Key type: RSA and RSA (default)
41+
- Key size: 4096 bits
42+
- Expiration: 1-2 years (recommended)
43+
- Enter your name and email (must match Git config)
44+
45+
## Step 2: Export Public Key
46+
47+
Get your public key in text format:
48+
49+
```bash
50+
gpg --armor --export [email-id/key-id] > gpg.key
51+
cat gpg.key
52+
```
53+
54+
## Step 3: Add Key to GitHub
55+
56+
1. Copy the public key content
57+
2. Go to GitHub Settings → SSH and GPG keys
58+
3. Click "New GPG key"
59+
4. Paste your public key
60+
61+
For detailed steps, check this [comprehensive guide](https://medium.com/big0one/how-to-create-a-verified-commit-in-github-using-gpg-key-signature-16acee004e0f).
62+
63+
## Step 4: Configure Git Client
64+
65+
First, find your secret key ID:
66+
67+
```bash
68+
gpg --list-secret-keys --keyid-format=long
69+
```
70+
71+
Look for the key ID after `rsa4096/` in the output.
72+
73+
Then configure Git:
74+
75+
```bash
76+
git config --global user.signingkey [secret-key-id]
77+
git config --global commit.gpgsign true
78+
git config --global gpg.program $(which gpg)
79+
```
80+
81+
## Step 5: Sign Your Commits
82+
83+
Now all commits will be signed automatically, or manually sign:
84+
85+
```bash
86+
git commit -S -m "Your commit message"
87+
```
88+
89+
## Verification
90+
91+
Verify signed commits:
92+
93+
```bash
94+
git log --show-signature
95+
```
96+
97+
On GitHub, signed commits show a "Verified" badge.
98+
99+
## Troubleshooting
100+
101+
### GPG Agent Issues
102+
103+
```bash
104+
export GPG_TTY=$(tty)
105+
echo 'export GPG_TTY=$(tty)' >> ~/.bashrc
106+
```
107+
108+
### Key Expiration
109+
110+
```bash
111+
gpg --edit-key [key-id]
112+
# Use 'expire' command to extend
113+
```
114+
115+
## Best Practices
116+
117+
- ✅ Use strong passphrases
118+
- ✅ Backup your private key securely
119+
- ✅ Set reasonable expiration dates
120+
- ✅ Revoke compromised keys immediately
121+
- ✅ Use different keys for different purposes
122+
123+
## Next Steps
124+
125+
- Set up commit signing in your IDE
126+
- Configure organization-wide signing policies
127+
- Explore advanced GPG features
128+
- Learn about signed tags
129+
130+
---
131+
132+
> Secure your commits, secure your code! 🔐

docs/database/index.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
title: Database
3+
nav_order: 3
4+
---
5+
6+
## Database
7+
8+
{: .fs-6 .fw-300 }
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
---
2+
parent: Active Directory
3+
title: LDAP Connection
4+
---
5+
6+
## Light Directory Active Server
7+
8+
This doc will help to connect your internal(VM) LDAP server to any LDAP browser (jx explorer, Apache Directory).
9+
Basically, I have installed an application with LDAP server in my Virtual Machine (vmware). After then, I was trying to connect that internal ldap server to Apache Directory in my Host Computer.
10+
Thoug I could access application server through my browser, but could not able to make connection of the ldap server into the Apache Directory. Later I found this solution that is the port of that ldap server was not able to communicate with my host computer even after adding that port into the firewall.
11+
Actually we have to create a tunnel of the ssh server to connect that port.
12+
13+
## LDAP server info
14+
15+
bind dn: cn=admin/directory manager
16+
server address: localhost/ip:port
17+
server password: password
18+
19+
In my case it is:
20+
bind dn: cn=directory manager
21+
server address: localhost:1636
22+
password: password
23+
24+
## Install openssh-server
25+
26+
Make sure that both side of the machine (host computer and VM) have installed the `openssh-server`.
27+
To install openssh server:
28+
29+
```bash
30+
sudo apt install openssh-server
31+
```
32+
33+
To check the ssh status:
34+
35+
```bash
36+
sudo service ssh status
37+
```
38+
39+
## Configure SSH
40+
41+
We need to configure ssh config file as below:
42+
43+
```bash
44+
sudo nano /etc/ssh/sshd_config
45+
```
46+
47+
From this file remove `#` right before `PermitRootLogin` and replace `*-password` with `yes` right after `PermitRootLogin`
48+
49+
Then reload the ssh server:
50+
51+
```bash
52+
sudo systemctl reload ssh
53+
```
54+
55+
## Root login
56+
57+
with `sudo su -` login as a root user. then set a root password with below command:
58+
59+
```bash
60+
sudo passwd
61+
```
62+
63+
## Creating Tunnel
64+
65+
To create tunnel:
66+
67+
```bash
68+
ssh -fNL [port to be used in ldap browser]:ldap server address:ldap server port root@internal ldap server ip address
69+
```
70+
71+
an example:
72+
73+
```bash
74+
ssh -fNL 5909:localhost:1636 [email protected]
75+
```
76+
77+
It may asked a root password just enter the password you have created using `sudo passwd`.
78+
That's all.
79+
80+
## Connecting LDAP server in Apache Directory
81+
82+
Select for a new connection and enter like this accroding to your own ldap server value. Please choose SSL connection if your ldap server has ssl connection.
83+
84+
![Screenshot from 2021-07-27 16-58-18](https://user-images.githubusercontent.com/20867846/127233153-f3613156-1b38-401a-85bc-06ec2ce560df.png)
85+
86+
After then enter the `bind dn` value and ldap server password and finish it.
87+
88+
![Screenshot from 2021-07-27 16-58-48](https://user-images.githubusercontent.com/20867846/127233157-a269ca64-c2c3-4fe5-8b88-ffea405ba3d7.png)
89+
90+
Finally you should see as below if it connect succesfully.
91+
92+
![Screenshot from 2021-07-27 16-59-08](https://user-images.githubusercontent.com/20867846/127233158-d245a917-0d3a-4a38-9296-75c551799510.png)
93+
94+
Thanks.

0 commit comments

Comments
 (0)