ABAC
ABAC ๋ชจ๋ธ์ด๋?โ
ABAC๋ ์์ฑ-๊ธฐ๋ฐ ์ ๊ทผ ์ ์ด(Attribute-Based Access Control)
์
๋๋ค. ์ด๊ฒ์ ๋ณด์ ์ฃผ์ฒด(Subject), ๋์(Object) ํน์ ์ก์
(Action) ์ ์์ฑ(Attribute) ์ ์ฌ์ฉํด์ ์ ๊ทผ ์ ์ด๋ฅผ ์ค์ ํ ์ ์๋ค๋ ๋ป์
๋๋ค. XACML์ด๋ผ๋ ๋ณต์กํ ABAC ์ ๊ทผ ์ ์ด ์ธ์ด์ ๋ํด ์๋ง ๋ค์ด๋ณธ ์ ์ด ์์ ๊ฒ์
๋๋ค. XACML๊ณผ ๋น๊ตํ๋ฉด, Casbin์ ABAC๋ ๋งค์ฐ ๋จ์ํฉ๋๋ค. ABAC ๋ชจ๋ธ์์๋ ๋ฌธ์์ด ๋์ , ๊ตฌ์กฐ์ฒด(ํน์ ํด๋์ค, ํ๋ก๊ทธ๋๋ฐ ์ธ์ด์ ๋ฐ๋ผ ๋ค๋ฆ) ์ธ์คํด์ค๋ฅผ ์ฌ์ฉํด์ ๋ชจ๋ธ์ ๊ตฌ์ฑํ ์ ์์ต๋๋ค.
ABAC ์์ฑ ์์ :
[request_definition]
r = sub, obj, act
[policy_definition]
p = sub, obj, act
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = r.sub == r.obj.Owner
Matcher ์กฐ๊ฑด์์์ r.obj
๋์ r.obj.Owner
๋ฅผ ์ฌ์ฉํ์์ต๋๋ค. Enforce()
ํจ์์ ์ ๋ฌ๋ r.obj
์๋ ๋ฌธ์์ด ๋์ ๊ตฌ์กฐ์ฒด(ํน์ ํด๋์ค) ์ธ์คํด์ค๊ฐ ๋ค์ด๊ฐ ์ ์์ต๋๋ค. Casbin์ ๋ฆฌํ๋ ์
์ ์ฌ์ฉํด์ obj
๊ตฌ์กฐ์ฒด(ํน์ ํด๋์ค) ์ธ์คํด์ค์์ ๋ฉค๋ฒ ๋ณ์๋ฅผ ์ถ์ถํฉ๋๋ค.
์ฌ๊ธฐ์ r.obj
์ ๊ตฌ์กฐ์ฒด(ํน์ ํด๋์ค) ์ ์ธ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
type testResource struct {
Name string
Owner string
}
ABAC ์ฌ์ฉ๋ฒโ
๊ฐ๋จํ, ABAC๋ฅผ ์ฌ์ฉํ๊ธฐ ์ํด์๋ ๋ค์ 2๊ฐ์ง๊ฐ ํ์ํฉ๋๋ค.
- ์กฐ๊ฑด์์ ์์ฑ์ ์ฌ์ฉํฉ๋๋ค.
- Casbin์
Enforce()
ํจ์์ ๊ตฌ์กฐ์ฒด(ํน์ ํด๋์ค) ์ธ์คํด์ค๋ฅผ ์ธ์๋ก ์ ๋ฌํฉ๋๋ค.
Currently, only request elements like r.sub
, r.obj
, r.act
and so on support ABAC. You cannot use it on policy elements like p.sub
๊ฐ์ด policy ๋์๋ ์ฌ์ฉํ ์ ์์ต๋๋ค. ์๋ํ๋ฉด, Casbin์ ์ ์ฑ
(Policy)์ ๋ ๊ตฌ์กฐ์ฒด(ํน์ ํด๋์ค)๋ฅผ ์ ์ธํ ์ ์๊ธฐ ๋๋ฌธ์
๋๋ค.
You can use multiple ABAC attributes in a matcher, for example: m = r.sub.Domain == r.obj.Domain
.
If you need to use comma in policy which conflicts with csv's separator and we need to escape it. Casbin parses policy file through csv library, you could surround statement with quotation marks. For example, "keyMatch("bob", r.sub.Role)"
will not be split.
Scaling the model for complex and large number of ABAC rules.โ
The above instance of ABAC implementation is at its core very simple, but oftentimes the authorization system needs a very complex and large number of ABAC rules. To fit this necessity the above implementation will increase the verbosity of the model to a large extent. So, itโs wise to add the rules in the policy instead of in the model. This is done by introducing a eval()
functional construct. Below is the example instance to manage such ABAC models.
This is the definition of the CONF
file used for defining the ABAC model.
[request_definition]
r = sub, obj, act
[policy_definition]
p = sub_rule, obj, act
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = eval(p.sub_rule) && r.obj == p.obj && r.act == p.act
Here, p.sub_rule
is of type struct or class(user-defined type) which consists of necessary attributes to be used in the policy.
This is the policy that is used against the model for Enforcement
. Now, you can use the object instance which is passed to eval()
as a parameter to define certain ABAC constraints.
p, r.sub.Age > 18, /data1, read
p, r.sub.Age < 60, /data2, write