Add context.Context as an output to Authorize interfaces

This commit is contained in:
Cory Slep 2019-09-14 16:35:48 +02:00
parent 9b139af408
commit d87793a589
13 changed files with 103 additions and 95 deletions

View File

@ -174,7 +174,7 @@ func (b *baseActor) PostInbox(c context.Context, w http.ResponseWriter, r *http.
return true, nil
}
// Check the peer request is authentic.
authenticated, err := b.delegate.AuthenticatePostInbox(c, w, r)
c, authenticated, err := b.delegate.AuthenticatePostInbox(c, w, r)
if err != nil {
return true, err
} else if !authenticated {
@ -256,7 +256,7 @@ func (b *baseActor) GetInbox(c context.Context, w http.ResponseWriter, r *http.R
return false, nil
}
// Delegate authenticating and authorizing the request.
authenticated, err := b.delegate.AuthenticateGetInbox(c, w, r)
c, authenticated, err := b.delegate.AuthenticateGetInbox(c, w, r)
if err != nil {
return true, err
} else if !authenticated {
@ -309,7 +309,7 @@ func (b *baseActor) PostOutbox(c context.Context, w http.ResponseWriter, r *http
return true, nil
}
// Delegate authenticating and authorizing the request.
authenticated, err := b.delegate.AuthenticatePostOutbox(c, w, r)
c, authenticated, err := b.delegate.AuthenticatePostOutbox(c, w, r)
if err != nil {
return true, err
} else if !authenticated {
@ -370,7 +370,7 @@ func (b *baseActor) GetOutbox(c context.Context, w http.ResponseWriter, r *http.
return false, nil
}
// Delegate authenticating and authorizing the request.
authenticated, err := b.delegate.AuthenticateGetOutbox(c, w, r)
c, authenticated, err := b.delegate.AuthenticateGetOutbox(c, w, r)
if err != nil {
return true, err
} else if !authenticated {

View File

@ -77,9 +77,9 @@ func TestBaseActorSocialProtocol(t *testing.T) {
delegate, _, a := setupFn(ctl)
resp := httptest.NewRecorder()
req := toAPRequest(toGetInboxRequest())
delegate.EXPECT().AuthenticateGetInbox(ctx, resp, req).DoAndReturn(func(ctx context.Context, resp http.ResponseWriter, req *http.Request) (bool, error) {
delegate.EXPECT().AuthenticateGetInbox(ctx, resp, req).DoAndReturn(func(ctx context.Context, resp http.ResponseWriter, req *http.Request) (context.Context, bool, error) {
resp.WriteHeader(http.StatusForbidden)
return false, nil
return ctx, false, nil
})
// Run the test
handled, err := a.GetInbox(ctx, resp, req)
@ -95,7 +95,7 @@ func TestBaseActorSocialProtocol(t *testing.T) {
delegate, clock, a := setupFn(ctl)
resp := httptest.NewRecorder()
req := toAPRequest(toGetInboxRequest())
delegate.EXPECT().AuthenticateGetInbox(ctx, resp, req).Return(true, nil)
delegate.EXPECT().AuthenticateGetInbox(ctx, resp, req).Return(ctx, true, nil)
delegate.EXPECT().GetInbox(ctx, req).Return(testOrderedCollectionUniqueElems, nil)
clock.EXPECT().Now().Return(now())
// Run the test
@ -119,7 +119,7 @@ func TestBaseActorSocialProtocol(t *testing.T) {
delegate, clock, a := setupFn(ctl)
resp := httptest.NewRecorder()
req := toAPRequest(toGetInboxRequest())
delegate.EXPECT().AuthenticateGetInbox(ctx, resp, req).Return(true, nil)
delegate.EXPECT().AuthenticateGetInbox(ctx, resp, req).Return(ctx, true, nil)
delegate.EXPECT().GetInbox(ctx, req).Return(testOrderedCollectionDupedElems, nil)
clock.EXPECT().Now().Return(now())
// Run the test
@ -152,9 +152,9 @@ func TestBaseActorSocialProtocol(t *testing.T) {
delegate, _, a := setupFn(ctl)
resp := httptest.NewRecorder()
req := toAPRequest(toPostOutboxRequest(testCreateNoId))
delegate.EXPECT().AuthenticatePostOutbox(ctx, resp, req).DoAndReturn(func(ctx context.Context, resp http.ResponseWriter, req *http.Request) (bool, error) {
delegate.EXPECT().AuthenticatePostOutbox(ctx, resp, req).DoAndReturn(func(ctx context.Context, resp http.ResponseWriter, req *http.Request) (context.Context, bool, error) {
resp.WriteHeader(http.StatusForbidden)
return false, nil
return ctx, false, nil
})
// Run the test
handled, err := a.PostOutbox(ctx, resp, req)
@ -170,7 +170,7 @@ func TestBaseActorSocialProtocol(t *testing.T) {
delegate, _, a := setupFn(ctl)
resp := httptest.NewRecorder()
req := toAPRequest(toPostOutboxUnknownRequest())
delegate.EXPECT().AuthenticatePostOutbox(ctx, resp, req).Return(true, nil)
delegate.EXPECT().AuthenticatePostOutbox(ctx, resp, req).Return(ctx, true, nil)
// Run the test
handled, err := a.PostOutbox(ctx, resp, req)
// Verify results
@ -185,7 +185,7 @@ func TestBaseActorSocialProtocol(t *testing.T) {
delegate, _, a := setupFn(ctl)
resp := httptest.NewRecorder()
req := toAPRequest(toPostOutboxRequest(testCreateNoId))
delegate.EXPECT().AuthenticatePostOutbox(ctx, resp, req).Return(true, nil)
delegate.EXPECT().AuthenticatePostOutbox(ctx, resp, req).Return(ctx, true, nil)
delegate.EXPECT().AddNewIds(ctx, toDeserializedForm(testCreateNoId)).DoAndReturn(func(c context.Context, activity Activity) error {
activity = withNewId(activity)
return nil
@ -212,7 +212,7 @@ func TestBaseActorSocialProtocol(t *testing.T) {
delegate, _, a := setupFn(ctl)
resp := httptest.NewRecorder()
req := toAPRequest(toPostOutboxRequest(testMyNote))
delegate.EXPECT().AuthenticatePostOutbox(ctx, resp, req).Return(true, nil)
delegate.EXPECT().AuthenticatePostOutbox(ctx, resp, req).Return(ctx, true, nil)
delegate.EXPECT().WrapInCreate(ctx, toDeserializedForm(testMyNote), mustParse(testMyOutboxIRI)).DoAndReturn(func(c context.Context, t vocab.Type, u *url.URL) (vocab.ActivityStreamsCreate, error) {
return wrappedInCreate(t), nil
})
@ -240,7 +240,7 @@ func TestBaseActorSocialProtocol(t *testing.T) {
delegate, _, a := setupFn(ctl)
resp := httptest.NewRecorder()
req := toAPRequest(toPostOutboxRequest(testCreateNoId))
delegate.EXPECT().AuthenticatePostOutbox(ctx, resp, req).Return(true, nil)
delegate.EXPECT().AuthenticatePostOutbox(ctx, resp, req).Return(ctx, true, nil)
delegate.EXPECT().AddNewIds(ctx, toDeserializedForm(testCreateNoId)).DoAndReturn(func(c context.Context, activity Activity) error {
activity = withNewId(activity)
return nil
@ -265,7 +265,7 @@ func TestBaseActorSocialProtocol(t *testing.T) {
delegate, _, a := setupFn(ctl)
resp := httptest.NewRecorder()
req := toAPRequest(toPostOutboxRequest(testCreateNoId))
delegate.EXPECT().AuthenticatePostOutbox(ctx, resp, req).Return(true, nil)
delegate.EXPECT().AuthenticatePostOutbox(ctx, resp, req).Return(ctx, true, nil)
delegate.EXPECT().AddNewIds(ctx, toDeserializedForm(testCreateNoId)).DoAndReturn(func(c context.Context, activity Activity) error {
activity = withNewId(activity)
return nil
@ -304,9 +304,9 @@ func TestBaseActorSocialProtocol(t *testing.T) {
delegate, _, a := setupFn(ctl)
resp := httptest.NewRecorder()
req := toAPRequest(toGetOutboxRequest())
delegate.EXPECT().AuthenticateGetOutbox(ctx, resp, req).DoAndReturn(func(ctx context.Context, resp http.ResponseWriter, req *http.Request) (bool, error) {
delegate.EXPECT().AuthenticateGetOutbox(ctx, resp, req).DoAndReturn(func(ctx context.Context, resp http.ResponseWriter, req *http.Request) (context.Context, bool, error) {
resp.WriteHeader(http.StatusForbidden)
return false, nil
return ctx, false, nil
})
// Run the test
handled, err := a.GetOutbox(ctx, resp, req)
@ -322,7 +322,7 @@ func TestBaseActorSocialProtocol(t *testing.T) {
delegate, clock, a := setupFn(ctl)
resp := httptest.NewRecorder()
req := toAPRequest(toGetOutboxRequest())
delegate.EXPECT().AuthenticateGetOutbox(ctx, resp, req).Return(true, nil)
delegate.EXPECT().AuthenticateGetOutbox(ctx, resp, req).Return(ctx, true, nil)
delegate.EXPECT().GetOutbox(ctx, req).Return(testOrderedCollectionUniqueElems, nil)
clock.EXPECT().Now().Return(now())
// Run the test
@ -379,9 +379,9 @@ func TestBaseActorFederatingProtocol(t *testing.T) {
delegate, _, a := setupFn(ctl)
resp := httptest.NewRecorder()
req := toAPRequest(toPostInboxRequest(testCreate))
delegate.EXPECT().AuthenticatePostInbox(ctx, resp, req).DoAndReturn(func(ctx context.Context, resp http.ResponseWriter, req *http.Request) (bool, error) {
delegate.EXPECT().AuthenticatePostInbox(ctx, resp, req).DoAndReturn(func(ctx context.Context, resp http.ResponseWriter, req *http.Request) (context.Context, bool, error) {
resp.WriteHeader(http.StatusForbidden)
return false, nil
return ctx, false, nil
})
// Run the test
handled, err := a.PostInbox(ctx, resp, req)
@ -397,7 +397,7 @@ func TestBaseActorFederatingProtocol(t *testing.T) {
delegate, _, a := setupFn(ctl)
resp := httptest.NewRecorder()
req := toAPRequest(toPostInboxUnknownRequest())
delegate.EXPECT().AuthenticatePostInbox(ctx, resp, req).Return(true, nil)
delegate.EXPECT().AuthenticatePostInbox(ctx, resp, req).Return(ctx, true, nil)
// Run the test
handled, err := a.PostInbox(ctx, resp, req)
// Verify results
@ -412,7 +412,7 @@ func TestBaseActorFederatingProtocol(t *testing.T) {
delegate, _, a := setupFn(ctl)
resp := httptest.NewRecorder()
req := toAPRequest(toPostOutboxRequest(testCreateNoId))
delegate.EXPECT().AuthenticatePostInbox(ctx, resp, req).Return(true, nil)
delegate.EXPECT().AuthenticatePostInbox(ctx, resp, req).Return(ctx, true, nil)
// Run the test
handled, err := a.PostInbox(ctx, resp, req)
// Verify results
@ -427,7 +427,7 @@ func TestBaseActorFederatingProtocol(t *testing.T) {
delegate, _, a := setupFn(ctl)
resp := httptest.NewRecorder()
req := toAPRequest(toPostInboxRequest(testCreate))
delegate.EXPECT().AuthenticatePostInbox(ctx, resp, req).Return(true, nil)
delegate.EXPECT().AuthenticatePostInbox(ctx, resp, req).Return(ctx, true, nil)
delegate.EXPECT().AuthorizePostInbox(ctx, resp, toDeserializedForm(testCreate)).DoAndReturn(func(ctx context.Context, resp http.ResponseWriter, activity Activity) (bool, error) {
resp.WriteHeader(http.StatusForbidden)
return false, nil
@ -446,7 +446,7 @@ func TestBaseActorFederatingProtocol(t *testing.T) {
delegate, _, a := setupFn(ctl)
resp := httptest.NewRecorder()
req := toAPRequest(toPostInboxRequest(testCreate))
delegate.EXPECT().AuthenticatePostInbox(ctx, resp, req).Return(true, nil)
delegate.EXPECT().AuthenticatePostInbox(ctx, resp, req).Return(ctx, true, nil)
delegate.EXPECT().AuthorizePostInbox(ctx, resp, toDeserializedForm(testCreate)).Return(true, nil)
delegate.EXPECT().PostInbox(ctx, mustParse(testMyInboxIRI), toDeserializedForm(testCreate)).Return(nil)
delegate.EXPECT().InboxForwarding(ctx, mustParse(testMyInboxIRI), toDeserializedForm(testCreate)).Return(nil)
@ -464,7 +464,7 @@ func TestBaseActorFederatingProtocol(t *testing.T) {
delegate, _, a := setupFn(ctl)
resp := httptest.NewRecorder()
req := toAPRequest(toPostInboxRequest(testCreate))
delegate.EXPECT().AuthenticatePostInbox(ctx, resp, req).Return(true, nil)
delegate.EXPECT().AuthenticatePostInbox(ctx, resp, req).Return(ctx, true, nil)
delegate.EXPECT().AuthorizePostInbox(ctx, resp, toDeserializedForm(testCreate)).Return(true, nil)
delegate.EXPECT().PostInbox(ctx, mustParse(testMyInboxIRI), toDeserializedForm(testCreate)).Return(ErrObjectRequired)
// Run the test
@ -481,7 +481,7 @@ func TestBaseActorFederatingProtocol(t *testing.T) {
delegate, _, a := setupFn(ctl)
resp := httptest.NewRecorder()
req := toAPRequest(toPostInboxRequest(testCreate))
delegate.EXPECT().AuthenticatePostInbox(ctx, resp, req).Return(true, nil)
delegate.EXPECT().AuthenticatePostInbox(ctx, resp, req).Return(ctx, true, nil)
delegate.EXPECT().AuthorizePostInbox(ctx, resp, toDeserializedForm(testCreate)).Return(true, nil)
delegate.EXPECT().PostInbox(ctx, mustParse(testMyInboxIRI), toDeserializedForm(testCreate)).Return(ErrTargetRequired)
// Run the test
@ -512,9 +512,9 @@ func TestBaseActorFederatingProtocol(t *testing.T) {
delegate, _, a := setupFn(ctl)
resp := httptest.NewRecorder()
req := toAPRequest(toGetInboxRequest())
delegate.EXPECT().AuthenticateGetInbox(ctx, resp, req).DoAndReturn(func(ctx context.Context, resp http.ResponseWriter, req *http.Request) (bool, error) {
delegate.EXPECT().AuthenticateGetInbox(ctx, resp, req).DoAndReturn(func(ctx context.Context, resp http.ResponseWriter, req *http.Request) (context.Context, bool, error) {
resp.WriteHeader(http.StatusForbidden)
return false, nil
return ctx, false, nil
})
// Run the test
handled, err := a.GetInbox(ctx, resp, req)
@ -530,7 +530,7 @@ func TestBaseActorFederatingProtocol(t *testing.T) {
delegate, clock, a := setupFn(ctl)
resp := httptest.NewRecorder()
req := toAPRequest(toGetInboxRequest())
delegate.EXPECT().AuthenticateGetInbox(ctx, resp, req).Return(true, nil)
delegate.EXPECT().AuthenticateGetInbox(ctx, resp, req).Return(ctx, true, nil)
delegate.EXPECT().GetInbox(ctx, req).Return(testOrderedCollectionUniqueElems, nil)
clock.EXPECT().Now().Return(now())
// Run the test
@ -554,7 +554,7 @@ func TestBaseActorFederatingProtocol(t *testing.T) {
delegate, clock, a := setupFn(ctl)
resp := httptest.NewRecorder()
req := toAPRequest(toGetInboxRequest())
delegate.EXPECT().AuthenticateGetInbox(ctx, resp, req).Return(true, nil)
delegate.EXPECT().AuthenticateGetInbox(ctx, resp, req).Return(ctx, true, nil)
delegate.EXPECT().GetInbox(ctx, req).Return(testOrderedCollectionDupedElems, nil)
clock.EXPECT().Now().Return(now())
// Run the test
@ -615,9 +615,9 @@ func TestBaseActorFederatingProtocol(t *testing.T) {
delegate, _, a := setupFn(ctl)
resp := httptest.NewRecorder()
req := toAPRequest(toGetOutboxRequest())
delegate.EXPECT().AuthenticateGetOutbox(ctx, resp, req).DoAndReturn(func(ctx context.Context, resp http.ResponseWriter, req *http.Request) (bool, error) {
delegate.EXPECT().AuthenticateGetOutbox(ctx, resp, req).DoAndReturn(func(ctx context.Context, resp http.ResponseWriter, req *http.Request) (context.Context, bool, error) {
resp.WriteHeader(http.StatusForbidden)
return false, nil
return ctx, false, nil
})
// Run the test
handled, err := a.GetOutbox(ctx, resp, req)
@ -633,7 +633,7 @@ func TestBaseActorFederatingProtocol(t *testing.T) {
delegate, clock, a := setupFn(ctl)
resp := httptest.NewRecorder()
req := toAPRequest(toGetOutboxRequest())
delegate.EXPECT().AuthenticateGetOutbox(ctx, resp, req).Return(true, nil)
delegate.EXPECT().AuthenticateGetOutbox(ctx, resp, req).Return(ctx, true, nil)
delegate.EXPECT().GetOutbox(ctx, req).Return(testOrderedCollectionUniqueElems, nil)
clock.EXPECT().Now().Return(now())
// Run the test
@ -676,7 +676,7 @@ func TestBaseActor(t *testing.T) {
delegate, _, a := setupFn(ctl)
resp := httptest.NewRecorder()
req := toAPRequest(toPostInboxRequest(testCreate))
delegate.EXPECT().AuthenticatePostInbox(ctx, resp, req).Return(true, nil)
delegate.EXPECT().AuthenticatePostInbox(ctx, resp, req).Return(ctx, true, nil)
delegate.EXPECT().AuthorizePostInbox(ctx, resp, toDeserializedForm(testCreate)).Return(true, nil)
delegate.EXPECT().PostInbox(ctx, mustParse(testMyInboxIRI), toDeserializedForm(testCreate)).Return(nil)
delegate.EXPECT().InboxForwarding(ctx, mustParse(testMyInboxIRI), toDeserializedForm(testCreate)).Return(nil)
@ -694,7 +694,7 @@ func TestBaseActor(t *testing.T) {
delegate, _, a := setupFn(ctl)
resp := httptest.NewRecorder()
req := toAPRequest(toPostOutboxRequest(testCreateNoId))
delegate.EXPECT().AuthenticatePostOutbox(ctx, resp, req).Return(true, nil)
delegate.EXPECT().AuthenticatePostOutbox(ctx, resp, req).Return(ctx, true, nil)
delegate.EXPECT().AddNewIds(ctx, toDeserializedForm(testCreateNoId)).DoAndReturn(func(c context.Context, activity Activity) error {
activity = withNewId(activity)
return nil
@ -721,7 +721,7 @@ func TestBaseActor(t *testing.T) {
delegate, _, a := setupFn(ctl)
resp := httptest.NewRecorder()
req := toAPRequest(toPostOutboxRequest(testCreateNoId))
delegate.EXPECT().AuthenticatePostOutbox(ctx, resp, req).Return(true, nil)
delegate.EXPECT().AuthenticatePostOutbox(ctx, resp, req).Return(ctx, true, nil)
delegate.EXPECT().AddNewIds(ctx, toDeserializedForm(testCreateNoId)).DoAndReturn(func(c context.Context, activity Activity) error {
activity = withNewId(activity)
return nil

View File

@ -32,7 +32,7 @@ type CommonBehavior interface {
// Finally, if the authentication and authorization succeeds, then
// authenticated must be true and error nil. The request will continue
// to be processed.
AuthenticateGetInbox(c context.Context, w http.ResponseWriter, r *http.Request) (authenticated bool, err error)
AuthenticateGetInbox(c context.Context, w http.ResponseWriter, r *http.Request) (out context.Context, authenticated bool, err error)
// AuthenticateGetOutbox delegates the authentication of a GET to an
// outbox.
//
@ -52,7 +52,7 @@ type CommonBehavior interface {
// Finally, if the authentication and authorization succeeds, then
// authenticated must be true and error nil. The request will continue
// to be processed.
AuthenticateGetOutbox(c context.Context, w http.ResponseWriter, r *http.Request) (authenticated bool, err error)
AuthenticateGetOutbox(c context.Context, w http.ResponseWriter, r *http.Request) (out context.Context, authenticated bool, err error)
// GetOutbox returns the OrderedCollection inbox of the actor for this
// context. It is up to the implementation to provide the correct
// collection for the kind of authorization given in the request.

View File

@ -75,7 +75,7 @@ type DelegateActor interface {
// Finally, if the authentication and authorization succeeds, then
// authenticated must be true and error nil. The request will continue
// to be processed.
AuthenticatePostInbox(c context.Context, w http.ResponseWriter, r *http.Request) (authenticated bool, err error)
AuthenticatePostInbox(c context.Context, w http.ResponseWriter, r *http.Request) (out context.Context, authenticated bool, err error)
// AuthenticateGetInbox delegates the authentication of a GET to an
// inbox.
//
@ -95,7 +95,7 @@ type DelegateActor interface {
// Finally, if the authentication and authorization succeeds, then
// authenticated must be true and error nil. The request will continue
// to be processed.
AuthenticateGetInbox(c context.Context, w http.ResponseWriter, r *http.Request) (authenticated bool, err error)
AuthenticateGetInbox(c context.Context, w http.ResponseWriter, r *http.Request) (out context.Context, authenticated bool, err error)
// AuthorizePostInbox delegates the authorization of an activity that
// has been sent by POST to an inbox.
//
@ -201,7 +201,7 @@ type DelegateActor interface {
// Finally, if the authentication and authorization succeeds, then
// authenticated must be true and error nil. The request will continue
// to be processed.
AuthenticatePostOutbox(c context.Context, w http.ResponseWriter, r *http.Request) (authenticated bool, err error)
AuthenticatePostOutbox(c context.Context, w http.ResponseWriter, r *http.Request) (out context.Context, authenticated bool, err error)
// AuthenticateGetOutbox delegates the authentication of a GET to an
// outbox.
//
@ -221,7 +221,7 @@ type DelegateActor interface {
// Finally, if the authentication and authorization succeeds, then
// authenticated must be true and error nil. The request will continue
// to be processed.
AuthenticateGetOutbox(c context.Context, w http.ResponseWriter, r *http.Request) (authenticated bool, err error)
AuthenticateGetOutbox(c context.Context, w http.ResponseWriter, r *http.Request) (out context.Context, authenticated bool, err error)
// WrapInCreate wraps the provided object in a Create ActivityStreams
// activity. The provided URL is the actor's outbox endpoint.
//

View File

@ -49,7 +49,7 @@ type FederatingProtocol interface {
// Finally, if the authentication and authorization succeeds, then
// authenticated must be true and error nil. The request will continue
// to be processed.
AuthenticatePostInbox(c context.Context, w http.ResponseWriter, r *http.Request) (authenticated bool, err error)
AuthenticatePostInbox(c context.Context, w http.ResponseWriter, r *http.Request) (out context.Context, authenticated bool, err error)
// Blocked should determine whether to permit a set of actors given by
// their ids are able to interact with this particular end user due to
// being blocked or other application-specific logic.

View File

@ -1,5 +1,5 @@
// Code generated by MockGen. DO NOT EDIT.
// Source: common_behavior.go
// Source: pub/common_behavior.go
// Package pub is a generated GoMock package.
package pub
@ -37,12 +37,13 @@ func (m *MockCommonBehavior) EXPECT() *MockCommonBehaviorMockRecorder {
}
// AuthenticateGetInbox mocks base method
func (m *MockCommonBehavior) AuthenticateGetInbox(c context.Context, w http.ResponseWriter, r *http.Request) (bool, error) {
func (m *MockCommonBehavior) AuthenticateGetInbox(c context.Context, w http.ResponseWriter, r *http.Request) (context.Context, bool, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "AuthenticateGetInbox", c, w, r)
ret0, _ := ret[0].(bool)
ret1, _ := ret[1].(error)
return ret0, ret1
ret0, _ := ret[0].(context.Context)
ret1, _ := ret[1].(bool)
ret2, _ := ret[2].(error)
return ret0, ret1, ret2
}
// AuthenticateGetInbox indicates an expected call of AuthenticateGetInbox
@ -52,12 +53,13 @@ func (mr *MockCommonBehaviorMockRecorder) AuthenticateGetInbox(c, w, r interface
}
// AuthenticateGetOutbox mocks base method
func (m *MockCommonBehavior) AuthenticateGetOutbox(c context.Context, w http.ResponseWriter, r *http.Request) (bool, error) {
func (m *MockCommonBehavior) AuthenticateGetOutbox(c context.Context, w http.ResponseWriter, r *http.Request) (context.Context, bool, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "AuthenticateGetOutbox", c, w, r)
ret0, _ := ret[0].(bool)
ret1, _ := ret[1].(error)
return ret0, ret1
ret0, _ := ret[0].(context.Context)
ret1, _ := ret[1].(bool)
ret2, _ := ret[2].(error)
return ret0, ret1, ret2
}
// AuthenticateGetOutbox indicates an expected call of AuthenticateGetOutbox

View File

@ -1,5 +1,5 @@
// Code generated by MockGen. DO NOT EDIT.
// Source: delegate_actor.go
// Source: pub/delegate_actor.go
// Package pub is a generated GoMock package.
package pub
@ -67,12 +67,13 @@ func (mr *MockDelegateActorMockRecorder) PostOutboxRequestBodyHook(c, r, data in
}
// AuthenticatePostInbox mocks base method
func (m *MockDelegateActor) AuthenticatePostInbox(c context.Context, w http.ResponseWriter, r *http.Request) (bool, error) {
func (m *MockDelegateActor) AuthenticatePostInbox(c context.Context, w http.ResponseWriter, r *http.Request) (context.Context, bool, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "AuthenticatePostInbox", c, w, r)
ret0, _ := ret[0].(bool)
ret1, _ := ret[1].(error)
return ret0, ret1
ret0, _ := ret[0].(context.Context)
ret1, _ := ret[1].(bool)
ret2, _ := ret[2].(error)
return ret0, ret1, ret2
}
// AuthenticatePostInbox indicates an expected call of AuthenticatePostInbox
@ -82,12 +83,13 @@ func (mr *MockDelegateActorMockRecorder) AuthenticatePostInbox(c, w, r interface
}
// AuthenticateGetInbox mocks base method
func (m *MockDelegateActor) AuthenticateGetInbox(c context.Context, w http.ResponseWriter, r *http.Request) (bool, error) {
func (m *MockDelegateActor) AuthenticateGetInbox(c context.Context, w http.ResponseWriter, r *http.Request) (context.Context, bool, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "AuthenticateGetInbox", c, w, r)
ret0, _ := ret[0].(bool)
ret1, _ := ret[1].(error)
return ret0, ret1
ret0, _ := ret[0].(context.Context)
ret1, _ := ret[1].(bool)
ret2, _ := ret[2].(error)
return ret0, ret1, ret2
}
// AuthenticateGetInbox indicates an expected call of AuthenticateGetInbox
@ -183,12 +185,13 @@ func (mr *MockDelegateActorMockRecorder) Deliver(c, outbox, activity interface{}
}
// AuthenticatePostOutbox mocks base method
func (m *MockDelegateActor) AuthenticatePostOutbox(c context.Context, w http.ResponseWriter, r *http.Request) (bool, error) {
func (m *MockDelegateActor) AuthenticatePostOutbox(c context.Context, w http.ResponseWriter, r *http.Request) (context.Context, bool, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "AuthenticatePostOutbox", c, w, r)
ret0, _ := ret[0].(bool)
ret1, _ := ret[1].(error)
return ret0, ret1
ret0, _ := ret[0].(context.Context)
ret1, _ := ret[1].(bool)
ret2, _ := ret[2].(error)
return ret0, ret1, ret2
}
// AuthenticatePostOutbox indicates an expected call of AuthenticatePostOutbox
@ -198,12 +201,13 @@ func (mr *MockDelegateActorMockRecorder) AuthenticatePostOutbox(c, w, r interfac
}
// AuthenticateGetOutbox mocks base method
func (m *MockDelegateActor) AuthenticateGetOutbox(c context.Context, w http.ResponseWriter, r *http.Request) (bool, error) {
func (m *MockDelegateActor) AuthenticateGetOutbox(c context.Context, w http.ResponseWriter, r *http.Request) (context.Context, bool, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "AuthenticateGetOutbox", c, w, r)
ret0, _ := ret[0].(bool)
ret1, _ := ret[1].(error)
return ret0, ret1
ret0, _ := ret[0].(context.Context)
ret1, _ := ret[1].(bool)
ret2, _ := ret[2].(error)
return ret0, ret1, ret2
}
// AuthenticateGetOutbox indicates an expected call of AuthenticateGetOutbox

View File

@ -1,5 +1,5 @@
// Code generated by MockGen. DO NOT EDIT.
// Source: federating_protocol.go
// Source: pub/federating_protocol.go
// Package pub is a generated GoMock package.
package pub
@ -52,12 +52,13 @@ func (mr *MockFederatingProtocolMockRecorder) PostInboxRequestBodyHook(c, r, act
}
// AuthenticatePostInbox mocks base method
func (m *MockFederatingProtocol) AuthenticatePostInbox(c context.Context, w http.ResponseWriter, r *http.Request) (bool, error) {
func (m *MockFederatingProtocol) AuthenticatePostInbox(c context.Context, w http.ResponseWriter, r *http.Request) (context.Context, bool, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "AuthenticatePostInbox", c, w, r)
ret0, _ := ret[0].(bool)
ret1, _ := ret[1].(error)
return ret0, ret1
ret0, _ := ret[0].(context.Context)
ret1, _ := ret[1].(bool)
ret2, _ := ret[2].(error)
return ret0, ret1, ret2
}
// AuthenticatePostInbox indicates an expected call of AuthenticatePostInbox

View File

@ -1,5 +1,5 @@
// Code generated by MockGen. DO NOT EDIT.
// Source: social_protocol.go
// Source: pub/social_protocol.go
// Package pub is a generated GoMock package.
package pub
@ -51,12 +51,13 @@ func (mr *MockSocialProtocolMockRecorder) PostOutboxRequestBodyHook(c, r, data i
}
// AuthenticatePostOutbox mocks base method
func (m *MockSocialProtocol) AuthenticatePostOutbox(c context.Context, w http.ResponseWriter, r *http.Request) (bool, error) {
func (m *MockSocialProtocol) AuthenticatePostOutbox(c context.Context, w http.ResponseWriter, r *http.Request) (context.Context, bool, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "AuthenticatePostOutbox", c, w, r)
ret0, _ := ret[0].(bool)
ret1, _ := ret[1].(error)
return ret0, ret1
ret0, _ := ret[0].(context.Context)
ret1, _ := ret[1].(bool)
ret2, _ := ret[2].(error)
return ret0, ret1, ret2
}
// AuthenticatePostOutbox indicates an expected call of AuthenticatePostOutbox

View File

@ -401,7 +401,7 @@ func mustSerializeToBytes(t vocab.Type) []byte {
// mustSerialize serializes a type or panics.
func mustSerialize(t vocab.Type) map[string]interface{} {
m, err := serialize(t)
m, err := streams.Serialize(t)
if err != nil {
panic(err)
}
@ -474,7 +474,7 @@ func toAPRequest(r *http.Request) *http.Request {
// toPostInboxRequest creates a new POST HTTP request with the given type as
// the payload.
func toPostInboxRequest(t vocab.Type) *http.Request {
m, err := serialize(t)
m, err := streams.Serialize(t)
if err != nil {
panic(err)
}
@ -489,7 +489,7 @@ func toPostInboxRequest(t vocab.Type) *http.Request {
// toPostOutboxRequest creates a new POST HTTP request with the given type as
// the payload.
func toPostOutboxRequest(t vocab.Type) *http.Request {
m, err := serialize(t)
m, err := streams.Serialize(t)
if err != nil {
panic(err)
}

View File

@ -39,22 +39,22 @@ func (a *sideEffectActor) PostOutboxRequestBodyHook(c context.Context, r *http.R
}
// AuthenticatePostInbox defers to the delegate to authenticate the request.
func (a *sideEffectActor) AuthenticatePostInbox(c context.Context, w http.ResponseWriter, r *http.Request) (authenticated bool, err error) {
func (a *sideEffectActor) AuthenticatePostInbox(c context.Context, w http.ResponseWriter, r *http.Request) (out context.Context, authenticated bool, err error) {
return a.s2s.AuthenticatePostInbox(c, w, r)
}
// AuthenticateGetInbox defers to the delegate to authenticate the request.
func (a *sideEffectActor) AuthenticateGetInbox(c context.Context, w http.ResponseWriter, r *http.Request) (authenticated bool, err error) {
func (a *sideEffectActor) AuthenticateGetInbox(c context.Context, w http.ResponseWriter, r *http.Request) (out context.Context, authenticated bool, err error) {
return a.common.AuthenticateGetInbox(c, w, r)
}
// AuthenticatePostOutbox defers to the delegate to authenticate the request.
func (a *sideEffectActor) AuthenticatePostOutbox(c context.Context, w http.ResponseWriter, r *http.Request) (authenticated bool, err error) {
func (a *sideEffectActor) AuthenticatePostOutbox(c context.Context, w http.ResponseWriter, r *http.Request) (out context.Context, authenticated bool, err error) {
return a.c2s.AuthenticatePostOutbox(c, w, r)
}
// AuthenticateGetOutbox defers to the delegate to authenticate the request.
func (a *sideEffectActor) AuthenticateGetOutbox(c context.Context, w http.ResponseWriter, r *http.Request) (authenticated bool, err error) {
func (a *sideEffectActor) AuthenticateGetOutbox(c context.Context, w http.ResponseWriter, r *http.Request) (out context.Context, authenticated bool, err error) {
return a.common.AuthenticateGetOutbox(c, w, r)
}

View File

@ -37,9 +37,9 @@ func TestPassThroughMethods(t *testing.T) {
defer ctl.Finish()
_, fp, _, _, _, a := setupFn(ctl)
req := toAPRequest(toPostInboxRequest(testCreate))
fp.EXPECT().AuthenticatePostInbox(ctx, resp, req).Return(true, testErr)
fp.EXPECT().AuthenticatePostInbox(ctx, resp, req).Return(ctx, true, testErr)
// Run
b, err := a.AuthenticatePostInbox(ctx, resp, req)
_, b, err := a.AuthenticatePostInbox(ctx, resp, req)
// Verify
assertEqual(t, b, true)
assertEqual(t, err, testErr)
@ -50,9 +50,9 @@ func TestPassThroughMethods(t *testing.T) {
defer ctl.Finish()
c, _, _, _, _, a := setupFn(ctl)
req := toAPRequest(toGetInboxRequest())
c.EXPECT().AuthenticateGetInbox(ctx, resp, req).Return(true, testErr)
c.EXPECT().AuthenticateGetInbox(ctx, resp, req).Return(ctx, true, testErr)
// Run
b, err := a.AuthenticateGetInbox(ctx, resp, req)
_, b, err := a.AuthenticateGetInbox(ctx, resp, req)
// Verify
assertEqual(t, b, true)
assertEqual(t, err, testErr)
@ -63,9 +63,9 @@ func TestPassThroughMethods(t *testing.T) {
defer ctl.Finish()
_, _, sp, _, _, a := setupFn(ctl)
req := toAPRequest(toPostOutboxRequest(testCreate))
sp.EXPECT().AuthenticatePostOutbox(ctx, resp, req).Return(true, testErr)
sp.EXPECT().AuthenticatePostOutbox(ctx, resp, req).Return(ctx, true, testErr)
// Run
b, err := a.AuthenticatePostOutbox(ctx, resp, req)
_, b, err := a.AuthenticatePostOutbox(ctx, resp, req)
// Verify
assertEqual(t, b, true)
assertEqual(t, err, testErr)
@ -76,9 +76,9 @@ func TestPassThroughMethods(t *testing.T) {
defer ctl.Finish()
c, _, _, _, _, a := setupFn(ctl)
req := toAPRequest(toGetOutboxRequest())
c.EXPECT().AuthenticateGetOutbox(ctx, resp, req).Return(true, testErr)
c.EXPECT().AuthenticateGetOutbox(ctx, resp, req).Return(ctx, true, testErr)
// Run
b, err := a.AuthenticateGetOutbox(ctx, resp, req)
_, b, err := a.AuthenticateGetOutbox(ctx, resp, req)
// Verify
assertEqual(t, b, true)
assertEqual(t, err, testErr)

View File

@ -50,7 +50,7 @@ type SocialProtocol interface {
// Finally, if the authentication and authorization succeeds, then
// authenticated must be true and error nil. The request will continue
// to be processed.
AuthenticatePostOutbox(c context.Context, w http.ResponseWriter, r *http.Request) (authenticated bool, err error)
AuthenticatePostOutbox(c context.Context, w http.ResponseWriter, r *http.Request) (out context.Context, authenticated bool, err error)
// Callbacks returns the application logic that handles ActivityStreams
// received from C2S clients.
//