aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--api.go7
-rw-r--r--garage.go15
-rw-r--r--integration/config/bottin.json10
-rw-r--r--invite.go1
-rw-r--r--templates/garage_website_inspect.html6
-rw-r--r--website.go19
6 files changed, 44 insertions, 14 deletions
diff --git a/api.go b/api.go
index c804276..73fd322 100644
--- a/api.go
+++ b/api.go
@@ -22,8 +22,13 @@ func handleAPIWebsiteList(w http.ResponseWriter, r *http.Request) {
}
if r.Method == http.MethodGet {
+ describe, err := ctrl.Describe()
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ }
+
w.Header().Set("Content-Type", "application/json")
- json.NewEncoder(w).Encode(ctrl.Describe())
+ json.NewEncoder(w).Encode(describe)
return
}
diff --git a/garage.go b/garage.go
index b3ca836..236dcbd 100644
--- a/garage.go
+++ b/garage.go
@@ -194,9 +194,8 @@ func handleWebsiteList(w http.ResponseWriter, r *http.Request) {
return
}
- desc := ctrl.Describe()
- if len(desc.Websites) > 0 {
- http.Redirect(w, r, "/website/inspect/"+desc.Websites[0].Pretty, http.StatusFound)
+ if len(ctrl.PrettyList) > 0 {
+ http.Redirect(w, r, "/website/inspect/"+ctrl.PrettyList[0], http.StatusFound)
} else {
http.Redirect(w, r, "/website/new", http.StatusFound)
}
@@ -245,7 +244,7 @@ func handleWebsiteNew(w http.ResponseWriter, r *http.Request) {
}
type WebsiteInspectTpl struct {
- Ctrl *WebsiteController
+ Describe *WebsiteDescribe
View *WebsiteView
Err error
}
@@ -287,8 +286,14 @@ func handleWebsiteInspect(w http.ResponseWriter, r *http.Request) {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
+
+ describe, err := ctrl.Describe()
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
- tpl := &WebsiteInspectTpl{ ctrl, view, processErr }
+ tpl := &WebsiteInspectTpl{ describe, view, processErr }
tWebsiteInspect := getTemplate("garage_website_inspect.html")
tWebsiteInspect.Execute(w, &tpl)
diff --git a/integration/config/bottin.json b/integration/config/bottin.json
index 0b54e22..4b9f3d7 100644
--- a/integration/config/bottin.json
+++ b/integration/config/bottin.json
@@ -6,8 +6,14 @@
"ANONYMOUS::bind:*,ou=users,dc=bottin,dc=eu:",
"ANONYMOUS::bind:cn=admin,dc=bottin,dc=eu:",
"*,dc=bottin,dc=eu::read:*:* !userpassword",
- "*::read modify:SELF:*",
"cn=admin,dc=bottin,dc=eu::read add modify delete:*:*",
- "*:cn=admin,ou=groups,dc=bottin,dc=eu:read add modify delete:*:*"
+ "*:cn=admin,ou=groups,dc=bottin,dc=eu:read add modify delete:*:*",
+
+ "ANONYMOUS::bind:*,ou=invitations,dc=bottin,dc=eu:",
+ "*,ou=invitations,dc=bottin,dc=eu::delete:SELF:*",
+ "*,ou=invitations,dc=bottin,dc=eu::add:*,ou=users,dc=bottin,dc=eu:*",
+ "*,ou=invitations,dc=bottin,dc=eu::modifyAdd:cn=email,ou=groups,dc=bottin,dc=eu:*",
+
+ "*::read modify:SELF:*"
]
}
diff --git a/invite.go b/invite.go
index 0a0e836..060947a 100644
--- a/invite.go
+++ b/invite.go
@@ -60,6 +60,7 @@ func handleInvitationCode(w http.ResponseWriter, r *http.Request) {
inviteDn := config.InvitationNameAttr + "=" + code_id + "," + config.InvitationBaseDN
err = l.Bind(inviteDn, code_pw)
if err != nil {
+ log.Println(err)
templateInviteInvalidCode := getTemplate("invite_invalid_code.html")
templateInviteInvalidCode.Execute(w, nil)
return
diff --git a/templates/garage_website_inspect.html b/templates/garage_website_inspect.html
index c062ab9..37142df 100644
--- a/templates/garage_website_inspect.html
+++ b/templates/garage_website_inspect.html
@@ -24,7 +24,7 @@
<div class="list-group mt-3">
{{ $view := .View }}
- {{ range $wid := .Ctrl.List }}
+ {{ range $wid := .Describe.Websites }}
{{ if eq $wid.Internal $view.Name.Internal }}
<a href="/website/inspect/{{ $wid.Pretty }}" class="list-group-item list-group-item-action active">
{{ $wid.Url }}
@@ -38,8 +38,8 @@
</div>
<p class="text-center mt-2">
- {{ .Ctrl.WebsiteCount.Current }} sites créés sur {{ .Ctrl.WebsiteCount.Max }}<br/>
- Jusqu'à {{ .Ctrl.User.Quota.WebsiteSizeBurstedPretty }} par site web
+ {{ .Describe.AllowedWebsites.Current }} sites créés sur {{ .Describe.AllowedWebsites.Max }}<br/>
+ Jusqu'à {{ .Describe.BurstBucketQuotaSize }} par site web
</p>
</div>
<div class="col-md-9">
diff --git a/website.go b/website.go
index 7e89a41..6158042 100644
--- a/website.go
+++ b/website.go
@@ -81,16 +81,29 @@ func NewWebsiteController(user *LoggedUser) (*WebsiteController, error) {
}
type WebsiteDescribe struct {
- AllowedWebsites *QuotaStat `json:"quota"`
+ AccessKeyId string `json:"access_key_id"`
+ SecretAccessKey string `json:"secret_access_key"`
+ AllowedWebsites *QuotaStat `json:"quota_website_count"`
+ BurstBucketQuotaSize string `json:"burst_bucket_quota_size"`
Websites []*WebsiteId `json:"vhosts"`
}
-func (w *WebsiteController) Describe() *WebsiteDescribe {
+func (w *WebsiteController) Describe() (*WebsiteDescribe, error) {
+ s3key, err := w.User.S3KeyInfo()
+ if err != nil {
+ return nil, err
+ }
+
r := make([]*WebsiteId, 0, len(w.PrettyList))
for _, k := range w.PrettyList {
r = append(r, w.WebsiteIdx[k])
}
- return &WebsiteDescribe { &w.WebsiteCount, r }
+ return &WebsiteDescribe {
+ *s3key.AccessKeyId,
+ *s3key.SecretAccessKey,
+ &w.WebsiteCount,
+ w.User.Quota.WebsiteSizeBurstedPretty(),
+ r }, nil
}
func (w *WebsiteController) Inspect(pretty string) (*WebsiteView, error) {