From 16e49e63c9d94e091e4d5600b9ad0e7a51977a9f Mon Sep 17 00:00:00 2001 From: Ooo0oO0o0oO <907709476@qq.com> Date: Tue, 4 Feb 2020 12:28:43 +0800 Subject: [PATCH] add some comments --- filter/access_key.go | 2 ++ filter/authenticator.go | 4 ++++ filter/filter_impl/auth/accesskey_storage.go | 2 ++ filter/filter_impl/auth/consumer_sign.go | 1 + filter/filter_impl/auth/default_authenticator.go | 1 + filter/filter_impl/auth/provider_auth.go | 1 + filter/filter_impl/auth/sign_util.go | 1 + 7 files changed, 12 insertions(+) diff --git a/filter/access_key.go b/filter/access_key.go index 36b709daf2..ee2fb919e2 100644 --- a/filter/access_key.go +++ b/filter/access_key.go @@ -14,6 +14,8 @@ type AccessKeyPair struct { Options string `yaml:"options" json:"options,omitempty" property:"options"` } +// This SPI Extension support us to store our AccessKeyPair or load AccessKeyPair from other +// storage, such as filesystem. type AccessKeyStorage interface { GetAccessKeyPair(protocol.Invocation, *common.URL) *AccessKeyPair } diff --git a/filter/authenticator.go b/filter/authenticator.go index b7def1cc98..dcb062133d 100644 --- a/filter/authenticator.go +++ b/filter/authenticator.go @@ -6,6 +6,10 @@ import ( ) type Authenticator interface { + + // give a sign to request Sign(protocol.Invocation, *common.URL) error + + // verify the signature of the request is valid or not Authenticate(protocol.Invocation, *common.URL) error } diff --git a/filter/filter_impl/auth/accesskey_storage.go b/filter/filter_impl/auth/accesskey_storage.go index 924266a0d6..0d50174aad 100644 --- a/filter/filter_impl/auth/accesskey_storage.go +++ b/filter/filter_impl/auth/accesskey_storage.go @@ -8,9 +8,11 @@ import ( "github.com/apache/dubbo-go/protocol" ) +// The default implementation of AccesskeyStorage type DefaultAccesskeyStorage struct { } +// get AccessKeyPair from url by the key "accessKeyId" and "secretAccessKey" func (storage *DefaultAccesskeyStorage) GetAccessKeyPair(invocation protocol.Invocation, url *common.URL) *filter.AccessKeyPair { return &filter.AccessKeyPair{ AccessKey: url.GetParam(constant.ACCESS_KEY_ID_KEY, ""), diff --git a/filter/filter_impl/auth/consumer_sign.go b/filter/filter_impl/auth/consumer_sign.go index 5feb289bf3..8e4c882134 100644 --- a/filter/filter_impl/auth/consumer_sign.go +++ b/filter/filter_impl/auth/consumer_sign.go @@ -12,6 +12,7 @@ import ( "github.com/apache/dubbo-go/protocol" ) +// This filter is working for signing the request on consumer side type ConsumerSignFilter struct { } diff --git a/filter/filter_impl/auth/default_authenticator.go b/filter/filter_impl/auth/default_authenticator.go index 0f0172f696..cc0e2606b3 100644 --- a/filter/filter_impl/auth/default_authenticator.go +++ b/filter/filter_impl/auth/default_authenticator.go @@ -20,6 +20,7 @@ func init() { extension.SetAuthenticator(constant.DEFAULT_AUTHENTICATOR, GetDefaultAuthenticator) } +// The default implemetation of Authenticator type DefaultAuthenticator struct { } diff --git a/filter/filter_impl/auth/provider_auth.go b/filter/filter_impl/auth/provider_auth.go index c13f342534..f4dbcf4436 100644 --- a/filter/filter_impl/auth/provider_auth.go +++ b/filter/filter_impl/auth/provider_auth.go @@ -9,6 +9,7 @@ import ( "github.com/apache/dubbo-go/protocol" ) +// This filter is used to verify the correctness of the signature on provider side type ProviderAuthFilter struct { } diff --git a/filter/filter_impl/auth/sign_util.go b/filter/filter_impl/auth/sign_util.go index 5f7e97ed70..9387314919 100644 --- a/filter/filter_impl/auth/sign_util.go +++ b/filter/filter_impl/auth/sign_util.go @@ -9,6 +9,7 @@ import ( "strings" ) +// get a signature string with given information, such as metadata or parameters func Sign(metadata, key string) string { return doSign([]byte(metadata), key) }