code refactoring, updated dockerfile
This commit is contained in:
@@ -27,5 +27,7 @@ RUN apk update && \
|
|||||||
|
|
||||||
COPY --from=build /usr/src/yt-dlp-webui/yt-dlp-webui /app
|
COPY --from=build /usr/src/yt-dlp-webui/yt-dlp-webui /app
|
||||||
|
|
||||||
|
ENV JWT_SECRET=secret
|
||||||
|
|
||||||
EXPOSE 3033
|
EXPOSE 3033
|
||||||
CMD [ "./yt-dlp-webui" , "--out", "/downloads" ]
|
ENTRYPOINT [ "./yt-dlp-webui" , "--out", "/downloads" ]
|
||||||
|
|||||||
@@ -43,9 +43,7 @@ export default function Login() {
|
|||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({ secret })
|
||||||
secret
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
res.ok ? navigate('/') : setFormHasError(true)
|
res.ok ? navigate('/') : setFormHasError(true)
|
||||||
}
|
}
|
||||||
@@ -60,6 +58,11 @@ export default function Login() {
|
|||||||
<Title fontWeight={'500'} fontSize={16} color={'gray'}>
|
<Title fontWeight={'500'} fontSize={16} color={'gray'}>
|
||||||
Authentication token will expire after 30 days.
|
Authentication token will expire after 30 days.
|
||||||
</Title>
|
</Title>
|
||||||
|
<Title fontWeight={'500'} fontSize={16} color={'gray'}>
|
||||||
|
In order to enable RPC authentication append the --auth
|
||||||
|
<br />
|
||||||
|
and --secret [secret] flags.
|
||||||
|
</Title>
|
||||||
<TextField
|
<TextField
|
||||||
id="outlined-password-input"
|
id="outlined-password-input"
|
||||||
label="RPC secret"
|
label="RPC secret"
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ var Authenticated = func(c *fiber.Ctx) error {
|
|||||||
if _, ok := t.Method.(*jwt.SigningMethodHMAC); !ok {
|
if _, ok := t.Method.(*jwt.SigningMethodHMAC); !ok {
|
||||||
return nil, fmt.Errorf("unexpected signing method: %v", t.Header["alg"])
|
return nil, fmt.Errorf("unexpected signing method: %v", t.Header["alg"])
|
||||||
}
|
}
|
||||||
return []byte(os.Getenv("JWTSECRET")), nil
|
return []byte(os.Getenv("JWT_SECRET")), nil
|
||||||
})
|
})
|
||||||
|
|
||||||
if claims, ok := token.Claims.(jwt.MapClaims); ok && token.Valid {
|
if claims, ok := token.Claims.(jwt.MapClaims); ok && token.Valid {
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ func Login(ctx *fiber.Ctx) error {
|
|||||||
"expiresAt": time.Now().Add(time.Minute * 30),
|
"expiresAt": time.Now().Add(time.Minute * 30),
|
||||||
})
|
})
|
||||||
|
|
||||||
tokenString, err := token.SignedString([]byte(os.Getenv("JWTSECRET")))
|
tokenString, err := token.SignedString([]byte(os.Getenv("JWT_SECRET")))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ctx.SendStatus(fiber.StatusInternalServerError)
|
return ctx.SendStatus(fiber.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user