mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-31 06:52:06 -05:00
refactor authentication code
moved api_key secret manipulation (generating and getting) into authentiation/utils, and added a property on the model, to facilitate easier matching of authenticated requests and the api keys they used
This commit is contained in:
@@ -5,14 +5,13 @@ from sqlalchemy.dialects.postgresql import (
|
||||
UUID,
|
||||
JSON
|
||||
)
|
||||
|
||||
from sqlalchemy import UniqueConstraint
|
||||
|
||||
from app.encryption import (
|
||||
hashpw,
|
||||
check_hash
|
||||
)
|
||||
|
||||
from app.authentication.utils import get_secret
|
||||
from app import (
|
||||
db,
|
||||
encryption
|
||||
@@ -135,6 +134,10 @@ class ApiKey(db.Model, Versioned):
|
||||
UniqueConstraint('service_id', 'name', name='uix_service_to_key_name'),
|
||||
)
|
||||
|
||||
@property
|
||||
def unsigned_secret(self):
|
||||
return get_secret(self.secret)
|
||||
|
||||
|
||||
KEY_TYPE_NORMAL = 'normal'
|
||||
KEY_TYPE_TEAM = 'team'
|
||||
|
||||
Reference in New Issue
Block a user