// NewAuthHandler returns a new authorization handler.
NewAuthHandler returns a new authorization handler.
// NewAuthHandler returns a new authorization handler .
func NewAuthHandler(cfg *Config, endpoint, method string, s store.Store, verifier signatureVerifier,
	tm authTokenManager, authorizeActor authorizeActorFunc) *AuthHandler {
	ep := fmt.Sprintf("%s%s", cfg.BasePath, endpoint)
	h := &AuthHandler{
		Config:         cfg,
		tokenVerifier:  auth.NewTokenVerifier(tm, ep, method),
		endpoint:       ep,
		verifier:       verifier,
		activityStore:  s,
		authorizeActor: authorizeActor,
		writeResponse: func(w http.ResponseWriter, status int, body []byte) {
			w.WriteHeader(status)
			if len(body) > 0 {
				if _, err := w.Write(body); err != nil {
					logger.Warnf("[%s] Unable to write response: %s", ep, err)
					return
				}
				logger.Debugf("[%s] Wrote response: %s", ep, body)
			}
		},
	}
	if h.authorizeActor == nil {
		h.authorizeActor = h.ensureActorIsWitnessOrFollower
	}
	return h
}
func NewAuthHandler ( cfg * Config , endpoint , method string , s store . Store , verifier signatureVerifier , tm authTokenManager , authorizeActor authorizeActorFunc ) * AuthHandler { ep := fmt . Sprintf ( " " , cfg . BasePath , endpoint ) h := & AuthHandler { Config : cfg , tokenVerifier : auth . NewTokenVerifier ( tm , ep , method ) , endpoint : ep , verifier : verifier , activityStore : s , authorizeActor : authorizeActor , writeResponse : func ( w http . ResponseWriter , status int , body [ ] byte ) { w . WriteHeader ( status ) if len ( body ) > 0 { if _ , err := w . Write ( body ) ; err != nil { logger . Warnf ( " " , ep , err ) return } logger . Debugf ( " " , ep , body ) } } , } if h . authorizeActor == nil { h . authorizeActor = h . ensureActorIsWitnessOrFollower } return h }
NewAuthHandler returns a new authorization handler.
NewAuthHandler returns a new authorization handler .