Skip to content

Commit

Permalink
add some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
CodingSinger committed Feb 4, 2020
1 parent c2158c4 commit 16e49e6
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions filter/access_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
4 changes: 4 additions & 0 deletions filter/authenticator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 2 additions & 0 deletions filter/filter_impl/auth/accesskey_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, ""),
Expand Down
1 change: 1 addition & 0 deletions filter/filter_impl/auth/consumer_sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
}

Expand Down
1 change: 1 addition & 0 deletions filter/filter_impl/auth/default_authenticator.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func init() {
extension.SetAuthenticator(constant.DEFAULT_AUTHENTICATOR, GetDefaultAuthenticator)
}

// The default implemetation of Authenticator
type DefaultAuthenticator struct {
}

Expand Down
1 change: 1 addition & 0 deletions filter/filter_impl/auth/provider_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
}

Expand Down
1 change: 1 addition & 0 deletions filter/filter_impl/auth/sign_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 16e49e6

Please sign in to comment.