mirror of
https://gitlab.crans.org/nounous/ghostream.git
synced 2024-12-22 08:02:19 +00:00
Ignore stream name case
This commit is contained in:
parent
a429216735
commit
dc594d091c
@ -10,19 +10,19 @@ func TestBasicLogin(t *testing.T) {
|
|||||||
|
|
||||||
// Test good credentials
|
// Test good credentials
|
||||||
backend, _ := New(&Options{Credentials: basicCredentials})
|
backend, _ := New(&Options{Credentials: basicCredentials})
|
||||||
ok, err := backend.Login("demo", "demo")
|
ok, _, err := backend.Login("demo", "demo")
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Error("Error while logging with the basic authentication:", err)
|
t.Error("Error while logging with the basic authentication:", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test bad username
|
// Test bad username
|
||||||
ok, err = backend.Login("baduser", "demo")
|
ok, _, err = backend.Login("baduser", "demo")
|
||||||
if ok {
|
if ok {
|
||||||
t.Error("Authentification failed to fail:", err)
|
t.Error("Authentification failed to fail:", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test bad password
|
// Test bad password
|
||||||
ok, err = backend.Login("demo", "badpass")
|
ok, _, err = backend.Login("demo", "badpass")
|
||||||
if ok {
|
if ok {
|
||||||
t.Error("Authentification failed to fail:", err)
|
t.Error("Authentification failed to fail:", err)
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ func Serve(streams *messaging.Streams, authBackend auth.Backend, cfg *Options) {
|
|||||||
|
|
||||||
if len(split) > 1 {
|
if len(split) > 1 {
|
||||||
// password was provided so it is a streamer
|
// password was provided so it is a streamer
|
||||||
name, password := split[0], split[1]
|
name, password := strings.ToLower(split[0]), split[1]
|
||||||
if authBackend != nil {
|
if authBackend != nil {
|
||||||
// check password
|
// check password
|
||||||
ok, username, err := authBackend.Login(name, password)
|
ok, username, err := authBackend.Login(name, password)
|
||||||
@ -94,7 +94,7 @@ func Serve(streams *messaging.Streams, authBackend auth.Backend, cfg *Options) {
|
|||||||
go handleStreamer(s, streams, name)
|
go handleStreamer(s, streams, name)
|
||||||
} else {
|
} else {
|
||||||
// password was not provided so it is a viewer
|
// password was not provided so it is a viewer
|
||||||
name := split[0]
|
name := strings.ToLower(split[0])
|
||||||
|
|
||||||
// Send stream
|
// Send stream
|
||||||
go handleViewer(s, streams, name)
|
go handleViewer(s, streams, name)
|
||||||
|
@ -52,7 +52,7 @@ func viewerHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
host = realHost
|
host = realHost
|
||||||
}
|
}
|
||||||
host = strings.Replace(host, ".", "-", -1)
|
host = strings.ToLower(strings.Replace(host, ".", "-", -1))
|
||||||
if streamID, ok := cfg.MapDomainToStream[host]; ok {
|
if streamID, ok := cfg.MapDomainToStream[host]; ok {
|
||||||
// Move home page to /about
|
// Move home page to /about
|
||||||
if path == "about" {
|
if path == "about" {
|
||||||
@ -97,6 +97,7 @@ func staticHandler() http.Handler {
|
|||||||
func statisticsHandler(w http.ResponseWriter, r *http.Request) {
|
func statisticsHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
// Retrieve stream name from URL
|
// Retrieve stream name from URL
|
||||||
name := strings.SplitN(strings.Replace(r.URL.Path[7:], "/", "", -1), "@", 2)[0]
|
name := strings.SplitN(strings.Replace(r.URL.Path[7:], "/", "", -1), "@", 2)[0]
|
||||||
|
name = strings.ToLower(name)
|
||||||
userCount := 0
|
userCount := 0
|
||||||
|
|
||||||
// Clients have a unique generated identifier per session, that expires in 40 seconds.
|
// Clients have a unique generated identifier per session, that expires in 40 seconds.
|
||||||
|
Loading…
Reference in New Issue
Block a user