|
|
|
@ -5,15 +5,14 @@ import (
|
|
|
|
|
|
|
|
|
|
"github.com/go-chi/chi"
|
|
|
|
|
"github.com/smallstep/certificates/api"
|
|
|
|
|
"github.com/smallstep/certificates/authority"
|
|
|
|
|
"github.com/smallstep/certificates/authority/config"
|
|
|
|
|
"github.com/smallstep/certificates/authority/mgmt"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// CreateAuthConfigRequest represents the body for a CreateAuthConfig request.
|
|
|
|
|
type CreateAuthConfigRequest struct {
|
|
|
|
|
ASN1DN *authority.ASN1DN `json:"asn1dn,omitempty"`
|
|
|
|
|
Claims *config.Claims `json:"claims,omitempty"`
|
|
|
|
|
DisableIssuedAtCheck bool `json:"disableIssuedAtCheck,omitempty"`
|
|
|
|
|
ASN1DN *config.ASN1DN `json:"asn1dn,omitempty"`
|
|
|
|
|
Claims *mgmt.Claims `json:"claims,omitempty"`
|
|
|
|
|
Backdate string `json:"backdate,omitempty"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -24,9 +23,8 @@ func (car *CreateAuthConfigRequest) Validate() error {
|
|
|
|
|
|
|
|
|
|
// UpdateAuthConfigRequest represents the body for a UpdateAuthConfig request.
|
|
|
|
|
type UpdateAuthConfigRequest struct {
|
|
|
|
|
ASN1DN *authority.ASN1DN `json:"asn1dn"`
|
|
|
|
|
Claims *config.Claims `json:"claims"`
|
|
|
|
|
DisableIssuedAtCheck bool `json:"disableIssuedAtCheck,omitempty"`
|
|
|
|
|
ASN1DN *config.ASN1DN `json:"asn1dn"`
|
|
|
|
|
Claims *mgmt.Claims `json:"claims"`
|
|
|
|
|
Backdate string `json:"backdate,omitempty"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -53,7 +51,7 @@ func (h *Handler) CreateAuthConfig(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
ctx := r.Context()
|
|
|
|
|
|
|
|
|
|
var body CreateAuthConfigRequest
|
|
|
|
|
if err := ReadJSON(r.Body, &body); err != nil {
|
|
|
|
|
if err := api.ReadJSON(r.Body, &body); err != nil {
|
|
|
|
|
api.WriteError(w, err)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
@ -61,9 +59,8 @@ func (h *Handler) CreateAuthConfig(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
api.WriteError(w, err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ac := config.AuthConfig{
|
|
|
|
|
Status: config.StatusActive,
|
|
|
|
|
DisableIssuedAtCheck: body.DisableIssuedAtCheck,
|
|
|
|
|
ac := &mgmt.AuthConfig{
|
|
|
|
|
Status: mgmt.StatusActive,
|
|
|
|
|
Backdate: "1m",
|
|
|
|
|
}
|
|
|
|
|
if body.ASN1DN != nil {
|
|
|
|
@ -84,11 +81,12 @@ func (h *Handler) CreateAuthConfig(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
|
|
|
|
|
// UpdateAuthConfig updates an existing AuthConfig.
|
|
|
|
|
func (h *Handler) UpdateAuthConfig(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
/*
|
|
|
|
|
ctx := r.Context()
|
|
|
|
|
id := chi.URLParam(r, "id")
|
|
|
|
|
|
|
|
|
|
var body UpdateAuthConfigRequest
|
|
|
|
|
if err := ReadJSON(r.Body, &body); err != nil {
|
|
|
|
|
if err := api.ReadJSON(r.Body, &body); err != nil {
|
|
|
|
|
api.WriteError(w, err)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
@ -96,12 +94,12 @@ func (h *Handler) UpdateAuthConfig(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
api.WriteError(w, err)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if ac, err := h.db.GetAuthConfig(ctx, id); err != nil {
|
|
|
|
|
ac, err := h.db.GetAuthConfig(ctx, id)
|
|
|
|
|
if err != nil {
|
|
|
|
|
api.WriteError(w, err)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ac.DisableIssuedAtCheck = body.DisableIssuedAtCheck
|
|
|
|
|
ac.Status = body.Status
|
|
|
|
|
if body.ASN1DN != nil {
|
|
|
|
|
ac.ASN1DN = body.ASN1DN
|
|
|
|
@ -118,4 +116,5 @@ func (h *Handler) UpdateAuthConfig(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
api.JSON(w, ac)
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|