Skip to content

Commit

Permalink
Merge pull request #72 from Baroshem/feat/enabled-config-option
Browse files Browse the repository at this point in the history
feat: add enabled config option
  • Loading branch information
Baroshem authored Jan 2, 2023
2 parents 2f54817 + 4ec9fe8 commit 6633b39
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion docs/content/1.getting-started/2.configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export interface ModuleOptions {
allowedMethodsRestricter: MiddlewareConfiguration<AllowedHTTPMethods> | false;
hidePoweredBy: boolean;
basicAuth: MiddlewareConfiguration<BasicAuth> | boolean;
enabled: boolean;
}
```
Expand Down Expand Up @@ -148,7 +149,8 @@ security: {
throwError?: true,
},
hidePoweredBy: true,
basicAuth: false
basicAuth: false,
enabled: true,
}
```
Expand Down
3 changes: 2 additions & 1 deletion src/defaultConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,6 @@ export const defaultSecurityConfig: ModuleOptions = {
...defaultThrowErrorValue
},
hidePoweredBy: true,
basicAuth: false
basicAuth: false,
enabled: true
}
2 changes: 2 additions & 0 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ export default defineNuxtModule<ModuleOptions>({
...defaultSecurityConfig
})
const securityOptions = nuxt.options.security
// Disabled module when `enabled` is set to `false`
if (!securityOptions.enabled) return

// Register nitro plugin to replace default 'X-Powered-By' header with custom one that does not indicate what is the framework underneath the app.
if (securityOptions.hidePoweredBy) {
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,5 @@ export interface ModuleOptions {
allowedMethodsRestricter: MiddlewareConfiguration<AllowedHTTPMethods> | false;
hidePoweredBy: boolean;
basicAuth: MiddlewareConfiguration<BasicAuth> | boolean;
enabled: boolean;
}

1 comment on commit 6633b39

@vercel
Copy link

@vercel vercel bot commented on 6633b39 Jan 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nuxt-security – ./

nuxt-security-baroshem.vercel.app
nuxt-security.vercel.app
nuxt-security-git-main-baroshem.vercel.app

Please sign in to comment.