Skip to content

Commit b09692f

Browse files
authored
Expose Authorization interface to be able to use it on the server (#1119)
1 parent caa6ac0 commit b09692f

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

internal/jwt_authorization.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ type JWTAuthProvider struct {
3232
}
3333

3434

35-
func NewJwtAuthorizationProvider(privateKey []byte) auth.AuthorizationProvider {
35+
func NewAdminJwtAuthorizationProvider(privateKey []byte) auth.AuthorizationProvider {
3636
return &JWTAuthProvider{
3737
PrivateKey: privateKey,
3838
}

internal/jwt_authorization_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func (s *jwtAuthSuite) TearDownTest() {
5252
}
5353

5454
func (s *jwtAuthSuite) TestCorrectTokenCreation() {
55-
authorizer := NewJwtAuthorizationProvider(s.key)
55+
authorizer := NewAdminJwtAuthorizationProvider(s.key)
5656
authToken, err := authorizer.GetAuthToken()
5757
s.NoError(err)
5858

@@ -73,7 +73,7 @@ func (s *jwtAuthSuite) TestCorrectTokenCreation() {
7373
}
7474

7575
func (s *jwtAuthSuite) TestIncorrectPrivateKeyForTokenCreation() {
76-
authorizer := NewJwtAuthorizationProvider([]byte{})
76+
authorizer := NewAdminJwtAuthorizationProvider([]byte{})
7777
_, err := authorizer.GetAuthToken()
7878
s.EqualError(err, "failed to parse PEM block containing the private key")
7979
}

worker/worker.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,9 @@ type (
193193
// NonDeterministicWorkflowPolicy is an enum for configuring how client's decision task handler deals with
194194
// mismatched history events (presumably arising from non-deterministic workflow definitions).
195195
NonDeterministicWorkflowPolicy = internal.NonDeterministicWorkflowPolicy
196+
197+
// AuthorizationProvider is the interface that contains the method to get the auth token
198+
AuthorizationProvider = auth.AuthorizationProvider
196199
)
197200

198201
const (
@@ -324,7 +327,7 @@ func SetBinaryChecksum(checksum string) {
324327
internal.SetBinaryChecksum(checksum)
325328
}
326329

327-
// NewJwtAuthorizationProvider creates a JwtAuthorizationProvider instance.
328-
func NewJwtAuthorizationProvider(privateKey []byte) auth.AuthorizationProvider {
329-
return internal.NewJwtAuthorizationProvider(privateKey)
330+
// NewAdminJwtAuthorizationProvider creates a JwtAuthorizationProvider instance.
331+
func NewAdminJwtAuthorizationProvider(privateKey []byte) AuthorizationProvider {
332+
return internal.NewAdminJwtAuthorizationProvider(privateKey)
330333
}

0 commit comments

Comments
 (0)