windowsauthmw

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2020 License: MIT Imports: 5 Imported by: 0

README

windowsauthmw

A Go middleware which adds the Windows domain and user name to the request context. It assumes the web application is running under IIS via the HttpPlatformHandler.

It is based on windowsauthtoken by Michael Collins.

There is currently only one method: AddDomainUser which takes and returns an http.Handler.

Wrap your mux with it at the beginning or close to the beginning of your middleware chain. You'll want this invoked early so that the information is added to the Context before you need to use it.

srv := &http.Server{Addr: fmt.Sprintf(":%d", port), Handler: windowsauthmw.AddDomainUser(mux)}

The middlware adds the domain and user name to the context in this format: Domain\Username

It doesn't offer a way to get the value out of the context. That is the responsibility of the application code. Use the provided DomainUserKey to get the value from the context:

ctx := r.Context()
domainUser := ctx.Value(windowsauthmw.DomainUserKey).(string)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddDomainUser

func AddDomainUser(h http.Handler) http.Handler

AddDomainUser adds the Windows domain and user name to the request context.

Types

type ContextKeyType

type ContextKeyType string

ContextKeyType is the type used to create context keys.

const DomainUserKey ContextKeyType = "domain-user"

DomainUserKey is the key to use to get the domain user from the conext.

Jump to

Keyboard shortcuts

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