Skip to content
This repository was archived by the owner on Sep 3, 2025. It is now read-only.

Commit 78709b2

Browse files
committed
Dropped support for Redis and MySQL. Switched to yaml config file .
1 parent f29e2d8 commit 78709b2

File tree

13 files changed

+368
-454
lines changed

13 files changed

+368
-454
lines changed

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
**GO-WebRados**
1+
**WebRados**
22
---------
33

4-
**Go-WebRados** is a simple and high performance HTTP service for **CEPH** distributed file system.
4+
**WebRados** is a simple and high performance HTTP service for **CEPH** distributed file system.
55
The main goal of this tool is to provide simple HTTP interface for **Ceph's** bare **RADOS** layer.
6-
**Go-WebRados** is not a replacement for **RadosGW** as is does not have all reach APIs and features of RadosGW(S3, Swift, etc ...), instead it stands for simplicity and performance.
6+
**WebRados** is not a replacement for **RadosGW** as is does not have all reach APIs and features of RadosGW(S3, Swift, etc ...), instead it stands for simplicity and performance.
77

8-
GO-WebRados relies on HTTP methods to interact with RADOS object, thus it can provide access to objects store in RADOS directly from internet browser .
8+
WebRados relies on HTTP methods to interact with RADOS object, thus it can provide access to objects store in RADOS directly from internet browser .
99
The ide is to have web accessible storage for millions of relatively small files, which can be accessed from browser directly.
1010

11-
GO-WebRados relies on C bindings of **Ceph** so in order to run this program you need to install Ceph packages.
12-
Running Ceph services on computer which hosts GO-WebRados is not required, it's even better to have a dedicated server or server for running GO-WebRados
11+
WebRados relies on C bindings of **Ceph** so in order to run this program you need to install Ceph packages.
12+
Running Ceph services on computer which hosts WebRados is not required, it's even better to have a dedicated server or server for running WebRados
1313

1414
### **Download and install**
1515
---------
1616

17-
You can build GO-WebRados from source or download precompiled binaries. If you already have installed Cephs packages and want to make things easy ,
18-
just download te GO-WebRados binary, make it executeable, and you are ready to run .
17+
You can build WebRados from source or download precompiled binaries. If you already have installed Cephs packages and want to make things easy ,
18+
just download te WebRados binary, make it executeable, and you are ready to run .
1919

2020
Building from a source is also easy.
2121

@@ -127,15 +127,15 @@ Configuration file is pretty simple and intuitive.
127127

128128
### **users.txt file**
129129

130-
GO-Webrados can dynamically update users from ```users.txt``` file .
130+
Webrados can dynamically update users from ```users.txt``` file .
131131
```users.txt``` should contain user and md5hash of password divided by space in each line.
132132
`echo -n SecretPaSs | md5sum |awk '{print $1}'` on Linux systemd will output md5hash for using it as password in `users.txt` file
133-
GO-Webrados will periodically read ```uesrs.txt``` file and automatically update users in memory.
133+
Webrados will periodically read ```uesrs.txt``` file and automatically update users in memory.
134134

135135
### **Large files**
136136

137137
In order to be able to store large file in RADOS directly files needs to be split to smaller chunks.
138-
GO-WebRados will automatically set maximum chunk size to **OSDMaxObjectSize** of Ceph and split files in accordance to that.
138+
WebRados will automatically set maximum chunk size to **OSDMaxObjectSize** of Ceph and split files in accordance to that.
139139

140140
### **Special commands**
141141

auth/authenticate.go

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package auth
2+
3+
import (
4+
"bufio"
5+
"crypto/md5"
6+
"encoding/hex"
7+
"net/http"
8+
"os"
9+
"strings"
10+
"time"
11+
"wrados"
12+
)
13+
14+
var users = map[string]string{
15+
//"test": "secret",
16+
}
17+
18+
func PopulateUsers() {
19+
for {
20+
c, e := os.Open("users.txt")
21+
content := bufio.NewScanner(c)
22+
if e != nil {
23+
wrados.Writelog(e)
24+
}
25+
26+
for content.Scan() {
27+
if len(content.Text()) > 0 {
28+
z := strings.Split(content.Text(), " ")
29+
if _, ok := users[z[0]]; !ok {
30+
wrados.Writelog("Found new user: " + z[0] + ", enabling!")
31+
users[z[0]] = z[1]
32+
}
33+
}
34+
//fmt.Println(content.Text())
35+
}
36+
_ = c.Close()
37+
time.Sleep(10 * time.Second)
38+
}
39+
}
40+
41+
func isAuthorised(username, password string) bool {
42+
43+
md5HashInBytes := md5.Sum([]byte(password))
44+
md5HashInString := hex.EncodeToString(md5HashInBytes[:])
45+
46+
pass, ok := users[username]
47+
48+
if !ok {
49+
return false
50+
}
51+
return md5HashInString == pass
52+
}
53+
54+
func authenticate(w http.ResponseWriter, r *http.Request) bool {
55+
//w.Header().Add("Content-Type", "application/json")
56+
username, password, ok := r.BasicAuth()
57+
if !ok {
58+
w.Header().Add("WWW-Authenticate", `Basic realm="Authentication Required"`)
59+
w.WriteHeader(http.StatusUnauthorized)
60+
_, _ = w.Write([]byte("No basic auth present\n"))
61+
wrados.Writelog("401 Unauthorized: No basic auth present")
62+
return false
63+
}
64+
65+
if !isAuthorised(username, password) {
66+
w.Header().Add("WWW-Authenticate", `Basic realm="Give username and password"`)
67+
w.WriteHeader(http.StatusUnauthorized)
68+
_, _ = w.Write([]byte("Invalid Credentials\n"))
69+
wrados.Writelog("401 Unauthorized: Invalid Credentials")
70+
return false
71+
}
72+
w.WriteHeader(http.StatusOK)
73+
return true
74+
75+
}

config.ini

Lines changed: 0 additions & 36 deletions
This file was deleted.

config.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
main:
2+
listen : 0.0.0.0:8080
3+
dispatchers : 20
4+
serveruser : admin
5+
serverpass : 261a5983599fd57a016122ec85599ec4
6+
dangerzone : yes
7+
readonly : no
8+
authread : no
9+
authwrite : yes
10+
radoconns : 25
11+
logfile : no
12+
logpath: /opt/webrados.log
13+
allpools: no
14+
poollist:
15+
- bublics
16+
- donuts
17+
- images
18+
cache:
19+
shards: 1024
20+
lifewindow: 10
21+
cleanwindow: 1
22+
maxrntriesinwindow: 600000
23+
maxentrysize: 5000
24+
maxcachemb: 1024
25+
monitoring:
26+
enabled : yes
27+
url: 127.0.0.1:9090
28+
user: admin
29+
pass: admin

0 commit comments

Comments
 (0)