Skip to content

Commit

Permalink
removed write access to policy map, added check for api limit zero value
Browse files Browse the repository at this point in the history
  • Loading branch information
dencoded committed Dec 19, 2018
1 parent e4c3892 commit 2cbba97
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ func (t BaseMiddleware) ApplyPolicies(key string, session *user.SessionState) er
}

// check if we already have limit on API level specified when policy was created
if accessRights.Limit == nil {
if accessRights.Limit == nil || *accessRights.Limit == (user.APILimit{}) {
// limit was not specified on API level so we will populate it from policy
accessRights.Limit = &user.APILimit{
QuotaMax: policy.QuotaMax,
Expand All @@ -292,9 +292,6 @@ func (t BaseMiddleware) ApplyPolicies(key string, session *user.SessionState) er
}
}

// adjust policy access right with limit on API level
policy.AccessRights[apiID] = accessRights

// overwrite session access right for this API
rights[apiID] = accessRights

Expand Down

0 comments on commit 2cbba97

Please sign in to comment.