diff options
author | Quentin Dufour <quentin@deuxfleurs.fr> | 2023-09-26 08:40:30 +0200 |
---|---|---|
committer | Quentin Dufour <quentin@deuxfleurs.fr> | 2023-09-26 08:40:30 +0200 |
commit | d8633d7fb89b55996f25e1a67180408c805ba15f (patch) | |
tree | 50c7b637e1f89c6ffcf8fcc7bf99429e91c944ef | |
parent | 982bd8a43c50bb5845b694dbd0b3e0ffbf43dad7 (diff) | |
download | guichet-d8633d7fb89b55996f25e1a67180408c805ba15f.tar.gz guichet-d8633d7fb89b55996f25e1a67180408c805ba15f.zip |
final
-rw-r--r-- | api.go | 7 | ||||
-rw-r--r-- | garage.go | 15 | ||||
-rw-r--r-- | integration/config/bottin.json | 10 | ||||
-rw-r--r-- | invite.go | 1 | ||||
-rw-r--r-- | templates/garage_website_inspect.html | 6 | ||||
-rw-r--r-- | website.go | 19 |
6 files changed, 44 insertions, 14 deletions
@@ -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 } @@ -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:*" ] } @@ -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"> @@ -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) { |