mirror of
https://github.com/absmach/magistrala.git
synced 2026-06-23 04:10:28 +00:00
SMQ-3171 - Add domain ID to channel authorization request (#3179)
Signed-off-by: Felix Gateru <felix.gateru@gmail.com>
This commit is contained in:
@@ -1010,7 +1010,7 @@ func (cr *channelRepository) CheckConnection(ctx context.Context, conn channels.
|
||||
}
|
||||
|
||||
func (cr *channelRepository) ClientAuthorize(ctx context.Context, conn channels.Connection) error {
|
||||
query := `SELECT 1 FROM connections WHERE channel_id = :channel_id AND client_id = :client_id AND type = :type LIMIT 1`
|
||||
query := `SELECT 1 FROM connections WHERE channel_id = :channel_id AND client_id = :client_id AND domain_id = :domain_id AND type = :type LIMIT 1`
|
||||
dbConn := toDBConnection(conn)
|
||||
rows, err := cr.db.NamedQueryContext(ctx, query, dbConn)
|
||||
if err != nil {
|
||||
|
||||
@@ -67,6 +67,7 @@ func (svc service) Authorize(ctx context.Context, req channels.AuthzReq) error {
|
||||
case policies.ClientType:
|
||||
// Optimization: Add cache
|
||||
if err := svc.repo.ClientAuthorize(ctx, channels.Connection{
|
||||
DomainID: req.DomainID,
|
||||
ChannelID: req.ChannelID,
|
||||
ClientID: req.ClientID,
|
||||
Type: req.Type,
|
||||
|
||||
Reference in New Issue
Block a user