mirror of
https://github.com/datarhei/core.git
synced 2025-10-05 07:57:13 +08:00
Fix basic auth, disable localhost, replace template func
This commit is contained in:
@@ -15,11 +15,11 @@ import (
|
||||
// about the API version and build infos.
|
||||
type AboutHandler struct {
|
||||
restream restream.Restreamer
|
||||
auths []string
|
||||
auths func() []string
|
||||
}
|
||||
|
||||
// NewAbout returns a new About type
|
||||
func NewAbout(restream restream.Restreamer, auths []string) *AboutHandler {
|
||||
func NewAbout(restream restream.Restreamer, auths func() []string) *AboutHandler {
|
||||
return &AboutHandler{
|
||||
restream: restream,
|
||||
auths: auths,
|
||||
@@ -36,11 +36,12 @@ func NewAbout(restream restream.Restreamer, auths []string) *AboutHandler {
|
||||
// @Router /api [get]
|
||||
func (p *AboutHandler) About(c echo.Context) error {
|
||||
user, _ := c.Get("user").(string)
|
||||
disablelocalhost, _ := c.Get("disablelocalhost").(bool)
|
||||
|
||||
if user == "$anon" {
|
||||
if user == "$anon" || (user == "$localhost" && !disablelocalhost) {
|
||||
return c.JSON(http.StatusOK, api.MinimalAbout{
|
||||
App: app.Name,
|
||||
Auths: p.auths,
|
||||
Auths: p.auths(),
|
||||
Version: api.VersionMinimal{
|
||||
Number: app.Version.MajorString(),
|
||||
},
|
||||
@@ -52,7 +53,7 @@ func (p *AboutHandler) About(c echo.Context) error {
|
||||
about := api.About{
|
||||
App: app.Name,
|
||||
Name: p.restream.Name(),
|
||||
Auths: p.auths,
|
||||
Auths: p.auths(),
|
||||
ID: p.restream.ID(),
|
||||
CreatedAt: createdAt.Format(time.RFC3339),
|
||||
Uptime: uint64(time.Since(createdAt).Seconds()),
|
||||
|
Reference in New Issue
Block a user