Skip to content

Commit

Permalink
fix: internal rules
Browse files Browse the repository at this point in the history
  • Loading branch information
liuyu committed Sep 19, 2024
1 parent be51fb9 commit 7303d09
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions internal/authorization/ts_app_authorizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -578,12 +578,25 @@ func (t *TsAuthorizer) getAppRules(position int, app *application.Application,
}
ruleAddResources(othersResources, ruleOthers)
ruleAddDomain(domains, ruleOthers)
if entrance.AuthLevel == "private" {
if entrance.AuthLevel != internal {
ruleAddDomain(localDomains, ruleOthers)
}

appendRule(ruleOthers)

// if policy is internal, local and non-local must add two individual rules
if entrance.AuthLevel == internal {
ruleOthersLocal := &AccessControlRule{
Position: position,
Policy: defaultLocalPolicy,
DefaultRule: true,
}

ruleAddResources(othersResources, ruleOthersLocal)
ruleAddDomain(localDomains, ruleOthersLocal)
appendRule(ruleOthersLocal)
}

// add app root path to default policy with options.
ruleRoot := &AccessControlRule{
Position: position,
Expand All @@ -593,19 +606,24 @@ func (t *TsAuthorizer) getAppRules(position int, app *application.Application,
DefaultRule: true,
}
ruleAddDomain(domains, ruleRoot)
if entrance.AuthLevel == "private" {
if entrance.AuthLevel != internal {
ruleAddDomain(localDomains, ruleRoot)
}

appendRule(ruleRoot)

// if policy is internal, local and non-local must add two individual rules
if entrance.AuthLevel == internal {
ruleOthersForLocal := &AccessControlRule{
Position: position,
Policy: NewLevel(public),
DefaultRule: true,
ruleRootLocal := &AccessControlRule{
Position: position,
Policy: defaultLocalPolicy,
OneTimeValid: policy.OneTime,
ValidDuration: time.Duration(policy.Duration) * time.Second,
DefaultRule: true,
}
ruleAddDomain(localDomains, ruleOthersForLocal)
appendRule(ruleOthersForLocal)

ruleAddDomain(localDomains, ruleRootLocal)
appendRule(ruleRootLocal)
}
}

Expand Down

0 comments on commit 7303d09

Please sign in to comment.