Skip to content

Commit acd9dd5

Browse files
committed
chore: rollback changes to v1/authorization
1 parent 1fdaa41 commit acd9dd5

File tree

5 files changed

+11
-38
lines changed

5 files changed

+11
-38
lines changed

v1/authorization/http_server.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ func getAuthorizedUser(r *http.Request, ts TenantService) (*influxdb.User, error
133133
return ts.FindUserByID(ctx, a.GetUserID())
134134
}
135135

136-
// postAuthorizationRequest encapsulates HTTP client authentication parameters.
137136
type postAuthorizationRequest struct {
138137
Token string `json:"token"`
139138
Status influxdb.Status `json:"status"`
@@ -146,7 +145,6 @@ type postAuthorizationRequest struct {
146145
type authResponse struct {
147146
ID platform.ID `json:"id"`
148147
Token string `json:"token"`
149-
HashedToken string `json:"hashedToken"`
150148
Status influxdb.Status `json:"status"`
151149
Description string `json:"description"`
152150
OrgID platform.ID `json:"orgID"`
@@ -176,7 +174,6 @@ func (h *AuthHandler) newAuthResponse(ctx context.Context, a *influxdb.Authoriza
176174
res := &authResponse{
177175
ID: a.ID,
178176
Token: a.Token,
179-
HashedToken: a.HashedToken,
180177
Status: a.Status,
181178
Description: a.Description,
182179
OrgID: a.OrgID,
@@ -212,7 +209,6 @@ func (a *authResponse) toInfluxdb() *influxdb.Authorization {
212209
res := &influxdb.Authorization{
213210
ID: a.ID,
214211
Token: a.Token,
215-
HashedToken: a.HashedToken,
216212
Status: a.Status,
217213
Description: a.Description,
218214
OrgID: a.OrgID,
@@ -249,8 +245,7 @@ func newPostAuthorizationRequest(a *influxdb.Authorization) (*postAuthorizationR
249245
Description: a.Description,
250246
Permissions: a.Permissions,
251247
Token: a.Token,
252-
//HashedToken: a.HashedToken,
253-
Status: a.Status,
248+
Status: a.Status,
254249
}
255250

256251
if a.UserID.Valid() {

v1/authorization/http_server_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ func TestService_handleGetAuthorization(t *testing.T) {
304304
},
305305
},
306306
},
307-
HashedToken: "hello",
307+
Token: "hello",
308308
}, nil
309309
}
310310

@@ -461,15 +461,15 @@ func TestService_handleGetAuthorizations(t *testing.T) {
461461
return []*influxdb.Authorization{
462462
{
463463
ID: itesting.MustIDBase16("0d0a657820696e74"),
464-
HashedToken: "hello",
464+
Token: "hello",
465465
UserID: itesting.MustIDBase16("2070616e656d2076"),
466466
OrgID: itesting.MustIDBase16("3070616e656d2076"),
467467
Description: "t1",
468468
Permissions: influxdb.OperPermissions(),
469469
},
470470
{
471471
ID: itesting.MustIDBase16("6669646573207375"),
472-
HashedToken: "example",
472+
Token: "example",
473473
UserID: itesting.MustIDBase16("6c7574652c206f6e"),
474474
OrgID: itesting.MustIDBase16("9d70616e656d2076"),
475475
Description: "t2",
@@ -553,15 +553,15 @@ func TestService_handleGetAuthorizations(t *testing.T) {
553553
return []*influxdb.Authorization{
554554
{
555555
ID: itesting.MustIDBase16("0d0a657820696e74"),
556-
HashedToken: "hello",
556+
Token: "hello",
557557
UserID: itesting.MustIDBase16("2070616e656d2076"),
558558
OrgID: itesting.MustIDBase16("3070616e656d2076"),
559559
Description: "t1",
560560
Permissions: influxdb.OperPermissions(),
561561
},
562562
{
563563
ID: itesting.MustIDBase16("6669646573207375"),
564-
HashedToken: "example",
564+
Token: "example",
565565
UserID: itesting.MustIDBase16("6c7574652c206f6e"),
566566
OrgID: itesting.MustIDBase16("9d70616e656d2076"),
567567
Description: "t2",
@@ -629,15 +629,15 @@ func TestService_handleGetAuthorizations(t *testing.T) {
629629
return []*influxdb.Authorization{
630630
{
631631
ID: itesting.MustIDBase16("0d0a657820696e74"),
632-
HashedToken: "hello",
632+
Token: "hello",
633633
UserID: itesting.MustIDBase16("2070616e656d2076"),
634634
OrgID: itesting.MustIDBase16("3070616e656d2076"),
635635
Description: "t1",
636636
Permissions: influxdb.OperPermissions(),
637637
},
638638
{
639639
ID: itesting.MustIDBase16("6669646573207375"),
640-
HashedToken: "example",
640+
Token: "example",
641641
UserID: itesting.MustIDBase16("6c7574652c206f6e"),
642642
OrgID: itesting.MustIDBase16("9d70616e656d2076"),
643643
Description: "t2",
@@ -928,7 +928,7 @@ func jsonDiffErr(s1, s2 string) (diff string, err error) {
928928

929929
var authorizationCmpOptions = cmp.Options{
930930
cmpopts.EquateEmpty(),
931-
cmpopts.IgnoreFields(influxdb.Authorization{}, "ID", "Token", "HashedToken", "CreatedAt", "UpdatedAt"),
931+
cmpopts.IgnoreFields(influxdb.Authorization{}, "ID", "Token", "CreatedAt", "UpdatedAt"),
932932
cmp.Comparer(func(x, y []byte) bool {
933933
return bytes.Equal(x, y)
934934
}),

v1/authorization/storage.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ const MaxIDGenerationN = 100
1414
const ReservedIDs = 1000
1515

1616
var (
17-
authBucket = []byte("legacy/authorizationsv1")
18-
authIndex = []byte("legacy/authorizationindexv1")
19-
hashedAuthIndex = []byte("legacy/authorizationhashedindexv1")
17+
authBucket = []byte("legacy/authorizationsv1")
18+
authIndex = []byte("legacy/authorizationindexv1")
2019
)
2120

2221
type Store struct {

v1/authorization/storage_authorization.go

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,7 @@ func authIndexBucket(tx kv.Tx) (kv.Bucket, error) {
2727
return b, nil
2828
}
2929

30-
func hashedAuthIndexKey(n string) []byte {
31-
return []byte(n)
32-
}
33-
34-
func hashedAuthIndexBucket(tx kv.Tx) (kv.Bucket, error) {
35-
b, err := tx.Bucket([]byte(hashedAuthIndex))
36-
if err != nil {
37-
return nil, UnexpectedAuthIndexError(err)
38-
}
39-
40-
return b, nil
41-
}
42-
4330
func encodeAuthorization(a *influxdb.Authorization) ([]byte, error) {
44-
if len(a.Token) > 0 && len(a.HashedToken) > 0 {
45-
return nil, &errors.Error{
46-
Code: errors.EInvalid,
47-
Msg: "authorization can not contained Token and HashedToken",
48-
}
49-
}
50-
5131
switch a.Status {
5232
case influxdb.Active, influxdb.Inactive:
5333
case "":

v1/authorization/storage_authorization_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ func TestAuth(t *testing.T) {
8282
},
8383
},
8484
{
85-
// VALIS: add tests for hashed tokens
8685
name: "read",
8786
setup: setup,
8887
results: func(t *testing.T, store *Store, tx kv.Tx) {

0 commit comments

Comments
 (0)