diff --git a/docs/swagger.yaml b/docs/swagger.yaml index a82c173..ba2525c 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -129,6 +129,8 @@ definitions: type: object domain.AuthData: properties: + appName: + type: string applicationId: type: integer domainId: diff --git a/domain/secure.go b/domain/secure.go index abaedf2..a273bbf 100644 --- a/domain/secure.go +++ b/domain/secure.go @@ -11,6 +11,7 @@ type AuthenticateResponse struct { } type AuthData struct { + AppName string SystemId int DomainId int ServiceId int diff --git a/entity/token.go b/entity/token.go index 5074262..8c22b67 100644 --- a/entity/token.go +++ b/entity/token.go @@ -12,6 +12,7 @@ type Token struct { } type AuthData struct { + AppName string SystemId int DomainId int ApplicationGroupId int diff --git a/repository/token.go b/repository/token.go index fbb15f8..95f58fc 100644 --- a/repository/token.go +++ b/repository/token.go @@ -101,7 +101,7 @@ func (r Token) DeleteToken(ctx context.Context, tokens []string) (int, error) { func (r Token) AuthDataByToken(ctx context.Context, token string) (*entity.AuthData, error) { q := ` -SELECT system_id, domain_id, application_group_id, app_id, token.expire_time, token.created_at +SELECT system_id, domain_id, application_group_id, app_id, application.name AS app_name , token.expire_time, token.created_at FROM token LEFT JOIN application ON token.app_id = application.id diff --git a/service/secure/service.go b/service/secure/service.go index 6c630d0..1be0219 100644 --- a/service/secure/service.go +++ b/service/secure/service.go @@ -45,6 +45,7 @@ func (s Service) Authenticate(ctx context.Context, token string) (*domain.AuthDa } return &domain.AuthData{ + AppName: authData.AppName, SystemId: authData.SystemId, DomainId: authData.DomainId, ServiceId: authData.ApplicationGroupId, diff --git a/tests/secure_test.go b/tests/secure_test.go index a77de37..d3a4afc 100644 --- a/tests/secure_test.go +++ b/tests/secure_test.go @@ -69,6 +69,7 @@ func (s *SecureSuite) TestAuthenticate_Success() { Authenticated: true, ErrorReason: "", AuthData: &domain.AuthData{ + AppName: "test_application", SystemId: 1, DomainId: 3, ServiceId: 5, @@ -110,6 +111,7 @@ func (s *SecureSuite) TestAuthenticate_NotExpired() { Authenticated: true, ErrorReason: "", AuthData: &domain.AuthData{ + AppName: "test_application", SystemId: 1, DomainId: 3, ServiceId: 5,