rkgrpccsrf

package
v1.2.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 31, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

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 rkgrpccsrf is a CSRF interceptor for grpc framework

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Interceptor

func Interceptor(h http.Handler, opts ...Option) http.Handler

Types

type Option

type Option func(*optionSet)

Option if for middleware options while creating middleware

func WithCookieDomain

func WithCookieDomain(val string) Option

WithCookieDomain provide domain of the CSRF cookie. Optional. Default value "".

func WithCookieHTTPOnly

func WithCookieHTTPOnly(val bool) Option

WithCookieHTTPOnly indicates if CSRF cookie is HTTP only. Optional. Default value false.

func WithCookieMaxAge

func WithCookieMaxAge(val int) Option

WithCookieMaxAge provide max age (in seconds) of the CSRF cookie. Optional. Default value 86400 (24hr).

func WithCookieName

func WithCookieName(val string) Option

WithCookieName provide name of the CSRF cookie. This cookie will store CSRF token. Optional. Default value "csrf".

func WithCookiePath

func WithCookiePath(val string) Option

WithCookiePath provide path of the CSRF cookie. Optional. Default value "".

func WithCookieSameSite

func WithCookieSameSite(val string) Option

WithCookieSameSite indicates SameSite mode of the CSRF cookie. Optional. Default value SameSiteDefaultMode.

func WithEntryNameAndType

func WithEntryNameAndType(entryName, entryType string) Option

WithEntryNameAndType provide entry name and entry type.

func WithIgnorePrefix

func WithIgnorePrefix(paths ...string) Option

WithIgnorePrefix provide paths prefix that will ignore. Mainly used for swagger main page and RK TV entry.

func WithSkipper

func WithSkipper(skip Skipper) Option

WithSkipper provide Skipper.

func WithTokenLength

func WithTokenLength(val int) Option

WithTokenLength the length of the generated token. Optional. Default value 32.

func WithTokenLookup

func WithTokenLookup(val string) Option

WithTokenLookup a string in the form of "<source>:<key>" that is used to extract token from the request. Optional. Default value "header:X-CSRF-Token". Possible values: - "header:<name>" - "form:<name>" - "query:<name>" Optional. Default value "header:X-CSRF-Token".

type Skipper

type Skipper func(*http.Request) bool

Skipper default skipper will always return false

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL