New option to disable provider edition
continuous-integration/drone/push Build encountered an error
Details
continuous-integration/drone/push Build encountered an error
Details
This will be useful for the demo instance
This commit is contained in:
parent
c5131b4f91
commit
497269f811
|
@ -100,6 +100,9 @@ func getProviderSettingsState(cfg *config.Options, c *gin.Context) {
|
||||||
if err != forms.DoneForm {
|
if err != forms.DoneForm {
|
||||||
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"errmsg": err.Error()})
|
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"errmsg": err.Error()})
|
||||||
return
|
return
|
||||||
|
} else if cfg.DisableProviders {
|
||||||
|
c.AbortWithStatusJSON(http.StatusForbidden, gin.H{"errmsg": "Cannot change provider settings as DisableProviders parameter is set."})
|
||||||
|
return
|
||||||
} else if _, err = src.NewDNSServiceProvider(); err != nil {
|
} else if _, err = src.NewDNSServiceProvider(); err != nil {
|
||||||
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"errmsg": err.Error()})
|
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"errmsg": err.Error()})
|
||||||
return
|
return
|
||||||
|
|
|
@ -39,18 +39,39 @@ import (
|
||||||
|
|
||||||
func declareProvidersRoutes(cfg *config.Options, router *gin.RouterGroup) {
|
func declareProvidersRoutes(cfg *config.Options, router *gin.RouterGroup) {
|
||||||
router.GET("/providers", getProviders)
|
router.GET("/providers", getProviders)
|
||||||
router.POST("/providers", addProvider)
|
router.POST("/providers", func(c *gin.Context) {
|
||||||
|
if cfg.DisableProviders {
|
||||||
|
c.AbortWithStatusJSON(http.StatusForbidden, gin.H{"errmsg": "Cannot add provider as DisableProviders parameter is set."})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
addProvider(c)
|
||||||
|
})
|
||||||
|
|
||||||
apiProvidersMetaRoutes := router.Group("/providers/:pid")
|
apiProvidersMetaRoutes := router.Group("/providers/:pid")
|
||||||
apiProvidersMetaRoutes.Use(ProviderMetaHandler)
|
apiProvidersMetaRoutes.Use(ProviderMetaHandler)
|
||||||
|
|
||||||
apiProvidersMetaRoutes.DELETE("", deleteProvider)
|
apiProvidersMetaRoutes.DELETE("", func(c *gin.Context) {
|
||||||
|
if cfg.DisableProviders {
|
||||||
|
c.AbortWithStatusJSON(http.StatusForbidden, gin.H{"errmsg": "Cannot delete provider as DisableProviders parameter is set."})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteProvider(c)
|
||||||
|
})
|
||||||
|
|
||||||
apiProviderRoutes := router.Group("/providers/:pid")
|
apiProviderRoutes := router.Group("/providers/:pid")
|
||||||
apiProviderRoutes.Use(ProviderHandler)
|
apiProviderRoutes.Use(ProviderHandler)
|
||||||
|
|
||||||
apiProviderRoutes.GET("", GetProvider)
|
apiProviderRoutes.GET("", GetProvider)
|
||||||
apiProviderRoutes.PUT("", UpdateProvider)
|
apiProviderRoutes.PUT("", func(c *gin.Context) {
|
||||||
|
if cfg.DisableProviders {
|
||||||
|
c.AbortWithStatusJSON(http.StatusForbidden, gin.H{"errmsg": "Cannot update provider as DisableProviders parameter is set."})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateProvider(c)
|
||||||
|
})
|
||||||
|
|
||||||
apiProviderRoutes.GET("/domains", getDomainsHostedByProvider)
|
apiProviderRoutes.GET("/domains", getDomainsHostedByProvider)
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ func (o *Options) declareFlags() {
|
||||||
flag.StringVar(&o.DevProxy, "dev", o.DevProxy, "Proxify traffic to this host for static assets")
|
flag.StringVar(&o.DevProxy, "dev", o.DevProxy, "Proxify traffic to this host for static assets")
|
||||||
flag.StringVar(&o.AdminBind, "admin-bind", o.AdminBind, "Bind port/socket for administration interface")
|
flag.StringVar(&o.AdminBind, "admin-bind", o.AdminBind, "Bind port/socket for administration interface")
|
||||||
flag.StringVar(&o.Bind, "bind", ":8081", "Bind port/socket")
|
flag.StringVar(&o.Bind, "bind", ":8081", "Bind port/socket")
|
||||||
|
flag.BoolVar(&o.DisableProviders, "disable-providers-edit", o.DisableProviders, "Disallow all actions on provider (add/edit/delete)")
|
||||||
flag.Var(&o.ExternalURL, "externalurl", "Begining of the URL, before the base, that should be used eg. in mails")
|
flag.Var(&o.ExternalURL, "externalurl", "Begining of the URL, before the base, that should be used eg. in mails")
|
||||||
flag.StringVar(&o.BaseURL, "baseurl", o.BaseURL, "URL prepended to each URL")
|
flag.StringVar(&o.BaseURL, "baseurl", o.BaseURL, "URL prepended to each URL")
|
||||||
flag.StringVar(&o.DefaultNameServer, "default-ns", o.DefaultNameServer, "Adress to the default name server")
|
flag.StringVar(&o.DefaultNameServer, "default-ns", o.DefaultNameServer, "Adress to the default name server")
|
||||||
|
|
|
@ -52,6 +52,9 @@ type Options struct {
|
||||||
// DefaultNameServer is the NS server suggested by default.
|
// DefaultNameServer is the NS server suggested by default.
|
||||||
DefaultNameServer string
|
DefaultNameServer string
|
||||||
|
|
||||||
|
// DisableProviders should disallow all actions on provider (add/edit/delete) through public API.
|
||||||
|
DisableProviders bool
|
||||||
|
|
||||||
// ExternalAuth is the URL of the login form to use instead of the embedded one.
|
// ExternalAuth is the URL of the login form to use instead of the embedded one.
|
||||||
ExternalAuth URL
|
ExternalAuth URL
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,10 @@ func init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeclareRoutes(cfg *config.Options, router *gin.Engine) {
|
func DeclareRoutes(cfg *config.Options, router *gin.Engine) {
|
||||||
|
if cfg.DisableProviders {
|
||||||
|
CustomHeadHTML += `<script type="text/javascript">window.disable_providers = true;</script>`
|
||||||
|
}
|
||||||
|
|
||||||
if HideVoxPeople {
|
if HideVoxPeople {
|
||||||
CustomHeadHTML += "<style>#voxpeople { display: none !important; }</style>"
|
CustomHeadHTML += "<style>#voxpeople { display: none !important; }</style>"
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,13 +111,15 @@
|
||||||
>
|
>
|
||||||
<div class="card-header d-flex justify-content-between">
|
<div class="card-header d-flex justify-content-between">
|
||||||
{$t("provider.title")}
|
{$t("provider.title")}
|
||||||
<Button
|
{#if !window.disable_providers}
|
||||||
size="sm"
|
<Button
|
||||||
color="light"
|
size="sm"
|
||||||
href="/providers/new"
|
color="light"
|
||||||
>
|
href="/providers/new"
|
||||||
<Icon name="plus" />
|
>
|
||||||
</Button>
|
<Icon name="plus" />
|
||||||
|
</Button>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{#if !$providers || !$providersSpecs}
|
{#if !$providers || !$providersSpecs}
|
||||||
<div class="d-flex justify-content-center">
|
<div class="d-flex justify-content-center">
|
||||||
|
|
|
@ -41,15 +41,17 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Container class="flex-fill pt-4 pb-5">
|
<Container class="flex-fill pt-4 pb-5">
|
||||||
<Button
|
{#if !window.disable_providers}
|
||||||
type="button"
|
<Button
|
||||||
color="primary"
|
type="button"
|
||||||
class="float-end"
|
color="primary"
|
||||||
on:click={() => goto('providers/new')}
|
class="float-end"
|
||||||
>
|
on:click={() => goto('providers/new')}
|
||||||
<Icon name="plus" />
|
>
|
||||||
{$t('common.add-new-thing', { thing: $t('provider.kind') })}
|
<Icon name="plus" />
|
||||||
</Button>
|
{$t('common.add-new-thing', { thing: $t('provider.kind') })}
|
||||||
|
</Button>
|
||||||
|
{/if}
|
||||||
<h1 class="text-center mb-4">
|
<h1 class="text-center mb-4">
|
||||||
{$t('provider.title')}
|
{$t('provider.title')}
|
||||||
</h1>
|
</h1>
|
||||||
|
|
Loading…
Reference in New Issue