Skip to content

Commit 3367a01

Browse files
remove denylist init and rename
1 parent fae76d8 commit 3367a01

15 files changed

+256
-226
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
-- Revert rename table to denylist_entries
2+
3+
BEGIN;
4+
5+
ALTER TABLE public.denylist_entries
6+
RENAME TO public.blacklist_entries;
7+
8+
ALTER SEQUENCE public. denylist_entries_id_seq
9+
RENAME TO public.blacklist_entries_id_seq ;
10+
11+
COMMIT;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
-- Rename table to denylist_entries
2+
3+
BEGIN;
4+
5+
ALTER TABLE public.blacklist_entries
6+
RENAME TO public.denylist_entries;
7+
8+
ALTER SEQUENCE public.blacklist_entries_id_seq
9+
RENAME TO public.denylist_entries_id_seq;
10+
11+
COMMIT;

docker-compose.test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ services:
2222
- SSAS_HASH_ITERATIONS=130000
2323
- SSAS_HASH_KEY_LENGTH=64
2424
- SSAS_HASH_SALT_SIZE=32
25-
- SSAS_TOKEN_BLACKLIST_CACHE_CLEANUP_MINUTES=15
26-
- SSAS_TOKEN_BLACKLIST_CACHE_TIMEOUT_MINUTES=1440
27-
- SSAS_TOKEN_BLACKLIST_CACHE_REFRESH_MINUTES=5
25+
- SSAS_TOKEN_DENYLIST_CACHE_CLEANUP_MINUTES=15
26+
- SSAS_TOKEN_DENYLIST_CACHE_TIMEOUT_MINUTES=1440
27+
- SSAS_TOKEN_DENYLIST_CACHE_REFRESH_MINUTES=5
2828
- SSAS_URL=http://ssas:3004
2929
- SSAS_PUBLIC_URL=http://ssas:3003
3030
- SSAS_CLIENT_ASSERTION_AUD=http://local.testing.cms.gov/api/v2/Token/auth

docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ services:
4141
- SSAS_HASH_ITERATIONS=130000
4242
- SSAS_HASH_KEY_LENGTH=64
4343
- SSAS_HASH_SALT_SIZE=32
44-
- SSAS_TOKEN_BLACKLIST_CACHE_CLEANUP_MINUTES=15
45-
- SSAS_TOKEN_BLACKLIST_CACHE_TIMEOUT_MINUTES=1440
46-
- SSAS_TOKEN_BLACKLIST_CACHE_REFRESH_MINUTES=5
44+
- SSAS_TOKEN_DENYLIST_CACHE_CLEANUP_MINUTES=15
45+
- SSAS_TOKEN_DENYLIST_CACHE_TIMEOUT_MINUTES=1440
46+
- SSAS_TOKEN_DENYLIST_CACHE_REFRESH_MINUTES=5
4747
- SSAS_CLIENT_ASSERTION_AUD=http://local.testing.cms.gov/api/v2/Token/auth
4848
volumes:
4949
- ./shared_files:/usr/local/shared_files

ssas/blacklist.go renamed to ssas/denylist.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@ import (
88
"gorm.io/gorm"
99
)
1010

11-
type BlacklistEntry struct {
11+
type DenylistEntry struct {
1212
gorm.Model
1313
Key string `gorm:"not null" json:"key"`
1414
EntryDate int64 `gorm:"not null" json:"entry_date"`
1515
CacheExpiration int64 `gorm:"not null" json:"cache_expiration"`
1616
}
1717

18-
func CreateBlacklistEntry(ctx context.Context, key string, entryDate time.Time, cacheExpiration time.Time) (entry BlacklistEntry, err error) {
18+
func CreateDenylistEntry(ctx context.Context, key string, entryDate time.Time, cacheExpiration time.Time) (entry DenylistEntry, err error) {
1919
if key == "" {
2020
err = fmt.Errorf("key cannot be blank")
2121
return
2222
}
2323

24-
be := BlacklistEntry{
24+
be := DenylistEntry{
2525
Key: key,
2626
EntryDate: entryDate.Unix(),
2727
CacheExpiration: cacheExpiration.UnixNano(),
@@ -36,7 +36,7 @@ func CreateBlacklistEntry(ctx context.Context, key string, entryDate time.Time,
3636
return
3737
}
3838

39-
func GetUnexpiredBlacklistEntries(ctx context.Context) (entries []BlacklistEntry, err error) {
39+
func GetUnexpiredDenylistEntries(ctx context.Context) (entries []DenylistEntry, err error) {
4040
err = Connection.WithContext(ctx).Order("entry_date, cache_expiration").Where("cache_expiration > ?", time.Now().UnixNano()).Find(&entries).Error
4141
if err != nil {
4242
return

ssas/blacklist_test.go renamed to ssas/denylist_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ func (s *CacheEntriesTestSuite) SetupSuite() {
2121
}
2222

2323
func (s *CacheEntriesTestSuite) TestGetUnexpiredCacheEntries() {
24-
entries, err := GetUnexpiredBlacklistEntries(context.Background())
24+
entries, err := GetUnexpiredDenylistEntries(context.Background())
2525
require.Nil(s.T(), err)
2626
origEntries := len(entries)
2727

2828
entryDate := time.Now().Add(time.Minute * -5).UnixNano()
2929
expiration := time.Now().Add(time.Minute * 5).UnixNano()
30-
e1 := BlacklistEntry{Key: "key1", EntryDate: entryDate, CacheExpiration: expiration}
31-
e2 := BlacklistEntry{Key: "key2", EntryDate: entryDate, CacheExpiration: expiration}
30+
e1 := DenylistEntry{Key: "key1", EntryDate: entryDate, CacheExpiration: expiration}
31+
e2 := DenylistEntry{Key: "key2", EntryDate: entryDate, CacheExpiration: expiration}
3232

3333
if err = s.db.Save(&e1).Error; err != nil {
3434
assert.FailNow(s.T(), err.Error())
@@ -37,7 +37,7 @@ func (s *CacheEntriesTestSuite) TestGetUnexpiredCacheEntries() {
3737
assert.FailNow(s.T(), err.Error())
3838
}
3939

40-
entries, err = GetUnexpiredBlacklistEntries(context.Background())
40+
entries, err = GetUnexpiredDenylistEntries(context.Background())
4141
assert.Nil(s.T(), err)
4242
assert.True(s.T(), len(entries) == origEntries+2)
4343

@@ -47,14 +47,14 @@ func (s *CacheEntriesTestSuite) TestGetUnexpiredCacheEntries() {
4747
assert.Nil(s.T(), err)
4848
}
4949

50-
func (s *CacheEntriesTestSuite) TestCreateBlacklistEntryEmptyKey() {
50+
func (s *CacheEntriesTestSuite) TestCreateDenylistEntryEmptyKey() {
5151
entryDate := time.Now().Add(time.Minute * -5)
5252
expiration := time.Now().Add(time.Minute * 5)
5353

54-
_, err := CreateBlacklistEntry(context.Background(), "", entryDate, expiration)
54+
_, err := CreateDenylistEntry(context.Background(), "", entryDate, expiration)
5555
assert.NotNil(s.T(), err)
5656

57-
e, err := CreateBlacklistEntry(context.Background(), "another_key", entryDate, expiration)
57+
e, err := CreateDenylistEntry(context.Background(), "another_key", entryDate, expiration)
5858
assert.Nil(s.T(), err)
5959
assert.Equal(s.T(), "another_key", e.Key)
6060

ssas/service/admin/api.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ func deactivateSystemCredentials(w http.ResponseWriter, r *http.Request) {
574574
575575
Revoke token
576576
577-
Revokes the specified tokenID by placing it on a blacklist. Will return an HTTP 200 status whether or not the tokenID has been issued.
577+
Revokes the specified tokenID by placing it on a denylist. Will return an HTTP 200 status whether or not the tokenID has been issued.
578578
579579
Produces:
580580
- application/json
@@ -595,12 +595,12 @@ func revokeToken(w http.ResponseWriter, r *http.Request) {
595595
return
596596
}
597597

598-
ssas.SetCtxEntry(r, "Op", "TokenBlacklist")
598+
ssas.SetCtxEntry(r, "Op", "TokenDenylist")
599599
logger := ssas.GetCtxLogger(r.Context())
600600
logger.Infof("Operation Called: admin.revokeToken()")
601601

602-
if err := service.TokenBlacklist.BlacklistToken(r.Context(), tokenID, service.TokenCacheLifetime); err != nil {
603-
logger.Errorf("failed to blacklist token; %s", err)
602+
if err := service.TokenDenylist.DenylistToken(r.Context(), tokenID, service.TokenCacheLifetime); err != nil {
603+
logger.Errorf("failed to denylist token; %s", err)
604604
service.JSONError(w, http.StatusInternalServerError, http.StatusText(http.StatusInternalServerError), "")
605605
}
606606

ssas/service/admin/api_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ type APITestSuite struct {
7070

7171
func (s *APITestSuite) SetupSuite() {
7272
s.db = ssas.Connection
73-
service.StartBlacklist()
73+
service.StartDenylist()
7474
ssas.MaxIPs = 3
7575
s.logEntry = MakeTestStructuredLoggerEntry(logrus.Fields{"cms_id": "A9999", "request_id": uuid.NewUUID().String()})
7676

@@ -291,8 +291,8 @@ func (s *APITestSuite) TestRevokeToken() {
291291
handler.ServeHTTP(rr, req)
292292
assert.Equal(s.T(), http.StatusOK, rr.Result().StatusCode)
293293

294-
assert.True(s.T(), service.TokenBlacklist.IsTokenBlacklisted(tokenID))
295-
assert.False(s.T(), service.TokenBlacklist.IsTokenBlacklisted("this_key_should_not_exist"))
294+
assert.True(s.T(), service.TokenDenylist.IsTokenDenylisted(tokenID))
295+
assert.False(s.T(), service.TokenDenylist.IsTokenDenylisted("this_key_should_not_exist"))
296296
}
297297

298298
func (s *APITestSuite) TestRevokeTokenNoToken() {
@@ -1722,7 +1722,7 @@ func TestSGAAdmin_NoAuth(t *testing.T) {
17221722
os.Setenv("SGA_ADMIN_FEATURE", newFF)
17231723

17241724
db := ssas.Connection
1725-
service.StartBlacklist()
1725+
service.StartDenylist()
17261726
ssas.MaxIPs = 3
17271727

17281728
ctx := context.Background()

ssas/service/main/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ func start(ps *service.Server, as *service.Server, forwarder *http.Server) {
193193

194194
ps.Serve()
195195
as.Serve()
196-
service.StartBlacklist()
196+
service.StartDenylist()
197197
ssas.Logger.Fatal(forwarder.ListenAndServe())
198198
}
199199

ssas/service/public/api_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (s *APITestSuite) SetupSuite() {
4848
s.server = Server()
4949
s.badSigningKeyPath = "../../../shared_files/ssas/admin_test_signing_key.pem"
5050
s.assertAud = "http://local.testing.cms.gov/api/v2/Token/auth"
51-
service.StartBlacklist()
51+
service.StartDenylist()
5252
s.logEntry = MakeTestStructuredLoggerEntry(logrus.Fields{"cms_id": "A9999", "request_id": uuid.NewUUID().String()})
5353

5454
if os.Getenv("SGA_ADMIN_FEATURE") == "true" {

0 commit comments

Comments
 (0)