2022-02-14 17:22:30 +01:00
|
|
|
package login
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
2022-04-27 01:01:45 +02:00
|
|
|
"github.com/zitadel/logging"
|
2022-04-06 08:13:40 +02:00
|
|
|
|
2022-04-27 01:01:45 +02:00
|
|
|
"github.com/zitadel/zitadel/internal/api/assets"
|
|
|
|
"github.com/zitadel/zitadel/internal/api/authz"
|
2023-12-05 12:12:01 +01:00
|
|
|
"github.com/zitadel/zitadel/internal/i18n"
|
2022-02-14 17:22:30 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
type dynamicResourceData struct {
|
|
|
|
OrgID string `schema:"orgId"`
|
|
|
|
DefaultPolicy bool `schema:"default-policy"`
|
|
|
|
FileName string `schema:"filename"`
|
|
|
|
}
|
|
|
|
|
2023-12-05 12:12:01 +01:00
|
|
|
func (l *Login) handleResources() http.Handler {
|
|
|
|
return http.FileServer(i18n.LoadFilesystem(i18n.LOGIN))
|
2022-02-14 17:22:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (l *Login) handleDynamicResources(w http.ResponseWriter, r *http.Request) {
|
|
|
|
data := new(dynamicResourceData)
|
|
|
|
err := l.getParseData(r, data)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-04-06 08:13:40 +02:00
|
|
|
resourceOwner := authz.GetInstance(r.Context()).InstanceID()
|
2022-02-14 17:22:30 +01:00
|
|
|
if data.OrgID != "" && !data.DefaultPolicy {
|
2022-04-06 08:13:40 +02:00
|
|
|
resourceOwner = data.OrgID
|
2022-02-14 17:22:30 +01:00
|
|
|
}
|
|
|
|
|
2022-04-06 08:13:40 +02:00
|
|
|
err = assets.GetAsset(w, r, resourceOwner, data.FileName, l.staticStorage)
|
|
|
|
logging.WithFields("file", data.FileName, "org", resourceOwner).OnError(err).Warn("asset in login could not be served")
|
2022-02-14 17:22:30 +01:00
|
|
|
}
|