     @remoteAddr = @options.remoteAddr
 
 class RequestFilter
+  constructor: (@environment)->
   run: (request, next)->
     next null, request
 
 class AuthenticateFilter extends RequestFilter
   run: (request, callback)->
-    authenticator = authenticators[request[0].authentication?.type]
+    authenticator = authenticators[request.authentication?.type]
     if not authenticator
       return callback "wrong/unsupported authentication type request", request
 
-    if not authenticator.authenticate(request[0].authentication.key)
+    authenticated = authenticator.authenticate(request.authentication.key, @environment.kodingKey())
+    if not authenticated
       return callback "couldnt authenticate request", request
+
+    # TODO: check timestamp validuntil
+    request.username = authenticated.username
 
     callback null, request
 

      if err
        return callback err, request
      cnt++
      console.log ">>> #{cnt}"
      if self.filters[cnt]?
        self.filters[cnt].run request, next
      else
        console.log "calling callback - #{cnt}"
        callback null, request
    @filters[0].run request, next


    throw "every worker needs a name" if not @kiteName? and not @kiteName
    @localStore = new Store
    @remoteStore = new Store
    @environment = new Environment username: @username
    @requestFilters = new RequestFilters [new AuthenticateFilter(@environment)]

  callRemote: (client, method, args)=>
    scrubber = new Scrubber @localStore
