Middleware secure

Enable secure interceptor/middleware for the server.


go get github.com/rookie-ninja/rk-boot
go get github.com/rookie-ninja/rk-grpc

General options

These are general options to start a gRPC server with rk-boot

name description type default value
grpc.name The name of grpc server string N/A
grpc.port The port of grpc server integer nil, server won’t start
grpc.enabled Enable grpc entry bool false
grpc.description Description of grpc entry. string ""

Secure options

name description type default value
grpc.interceptors.secure.enabled Enable secure interceptor boolean false
grpc.interceptors.secure.xssProtection X-XSS-Protection header value. string “1; mode=block”
grpc.interceptors.secure.contentTypeNosniff X-Content-Type-Options header value. string nosniff
grpc.interceptors.secure.xFrameOptions X-Frame-Options header value. string SAMEORIGIN
grpc.interceptors.secure.hstsMaxAge Strict-Transport-Security header value. int 0
grpc.interceptors.secure.hstsExcludeSubdomains Excluding subdomains of HSTS. bool false
grpc.interceptors.secure.hstsPreloadEnabled Enabling HSTS preload. bool false
grpc.interceptors.secure.contentSecurityPolicy Content-Security-Policy header value. string ""
grpc.interceptors.secure.cspReportOnly Content-Security-Policy-Report-Only header value. bool false
grpc.interceptors.secure.referrerPolicy Referrer-Policy header value. string ""
grpc.interceptors.secure.ignorePrefix Ignoring path prefix. []string []

Quick start

1.Create boot.yaml

  - name: greeter                     # Required
    port: 8080                        # Required
    enabled: true                     # Required
      enabled: true                   # Optional, default: false
        enabled: true                 # Optional, default: false

2.Create main.go

// Copyright (c) 2021 rookie-ninja
// Use of this source code is governed by an Apache-style
// license that can be found in the LICENSE file.
package main

import (
	_ "github.com/rookie-ninja/rk-grpc/boot"

// Application entrance.
func main() {
	// Create a new boot instance.
	boot := rkboot.NewBoot()

	// Bootstrap

	// Wait for shutdown sig


$ curl -vs localhost:8080/rk/v1/healthy
  < X-Content-Type-Options: nosniff
  < X-Frame-Options: SAMEORIGIN
  < X-Xss-Protection: 1; mode=block
  < Date: Sun, 05 Dec 2021 18:32:24 GMT
  < Content-Length: 17


Last modified December 12, 2021 : Update based on rk-boot@v1.4.0 (233e143)