mirror of
https://github.com/valitydev/bouncer-client-erlang.git
synced 2024-11-06 00:25:18 +00:00
MSPF-629: Update proto (#4)
* MSPF-629: Update proto * MSPF-629: Format
This commit is contained in:
parent
4cb77d31e4
commit
03905ab4fa
@ -2,7 +2,7 @@
|
||||
[{<<"bear">>,{pkg,<<"bear">>,<<"0.8.7">>},3},
|
||||
{<<"bouncer_proto">>,
|
||||
{git,"git@github.com:rbkmoney/bouncer-proto.git",
|
||||
{ref,"298356b934e097393593785560c04bfa152ea0b5"}},
|
||||
{ref,"99003d3e835ce15abbc7901a60a20f6552ed8589"}},
|
||||
0},
|
||||
{<<"cache">>,{pkg,<<"cache">>,<<"2.2.0">>},1},
|
||||
{<<"certifi">>,{pkg,<<"certifi">>,<<"2.5.1">>},2},
|
||||
|
@ -24,7 +24,7 @@
|
||||
fragments => #{context_fragment_id() => context_fragment()}
|
||||
}.
|
||||
|
||||
-type judgement() :: allowed | forbidden.
|
||||
-type judgement() :: allowed | forbidden | {restricted, bouncer_restriction_thrift:'Restrictions'()}.
|
||||
|
||||
-type service_name() :: atom().
|
||||
|
||||
@ -78,10 +78,12 @@ collect_fragments_(FragmentID, ContextFragment = #bctx_v1_ContextFragment{}, Acc
|
||||
|
||||
%%
|
||||
|
||||
parse_judgement(#bdcs_Judgement{resolution = allowed}) ->
|
||||
parse_judgement(#bdcs_Judgement{resolution = {allowed, #bdcs_ResolutionAllowed{}}}) ->
|
||||
allowed;
|
||||
parse_judgement(#bdcs_Judgement{resolution = forbidden}) ->
|
||||
forbidden.
|
||||
parse_judgement(#bdcs_Judgement{resolution = {forbidden, #bdcs_ResolutionForbidden{}}}) ->
|
||||
forbidden;
|
||||
parse_judgement(#bdcs_Judgement{resolution = {restricted, #bdcs_ResolutionRestricted{restrictions = Restrictions}}}) ->
|
||||
{restricted, Restrictions}.
|
||||
|
||||
%%
|
||||
|
||||
|
@ -98,7 +98,12 @@ end_per_testcase(_Name, C) ->
|
||||
empty_judge(C) ->
|
||||
mock_services(
|
||||
[
|
||||
{bouncer, fun('Judge', _) -> {ok, #bdcs_Judgement{resolution = allowed}} end}
|
||||
{bouncer, fun('Judge', _) ->
|
||||
{ok, #bdcs_Judgement{
|
||||
resolution = {allowed, #bdcs_ResolutionAllowed{}},
|
||||
resolution_legacy = allowed
|
||||
}}
|
||||
end}
|
||||
],
|
||||
C
|
||||
),
|
||||
@ -116,9 +121,15 @@ validate_user_fragment(C) ->
|
||||
#bctx_v1_ContextFragment{
|
||||
user = #bctx_v1_User{id = UserID, realm = #bctx_v1_Entity{id = UserRealm}}
|
||||
} ->
|
||||
{ok, #bdcs_Judgement{resolution = allowed}};
|
||||
{ok, #bdcs_Judgement{
|
||||
resolution = {allowed, #bdcs_ResolutionAllowed{}},
|
||||
resolution_legacy = allowed
|
||||
}};
|
||||
_ ->
|
||||
{ok, #bdcs_Judgement{resolution = forbidden}}
|
||||
{ok, #bdcs_Judgement{
|
||||
resolution = {forbidden, #bdcs_ResolutionForbidden{}},
|
||||
resolution_legacy = forbidden
|
||||
}}
|
||||
end
|
||||
end}
|
||||
],
|
||||
@ -146,9 +157,15 @@ validate_env_fragment(C) ->
|
||||
{bouncer, fun('Judge', {_RulesetID, Fragments}) ->
|
||||
case get_time(Fragments) of
|
||||
Time ->
|
||||
{ok, #bdcs_Judgement{resolution = allowed}};
|
||||
{ok, #bdcs_Judgement{
|
||||
resolution = {allowed, #bdcs_ResolutionAllowed{}},
|
||||
resolution_legacy = allowed
|
||||
}};
|
||||
_ ->
|
||||
{ok, #bdcs_Judgement{resolution = forbidden}}
|
||||
{ok, #bdcs_Judgement{
|
||||
resolution = {forbidden, #bdcs_ResolutionForbidden{}},
|
||||
resolution_legacy = forbidden
|
||||
}}
|
||||
end
|
||||
end}
|
||||
],
|
||||
@ -169,9 +186,15 @@ validate_auth_fragment(C) ->
|
||||
{bouncer, fun('Judge', {_RulesetID, Fragments}) ->
|
||||
case get_auth_method(Fragments) of
|
||||
Method ->
|
||||
{ok, #bdcs_Judgement{resolution = allowed}};
|
||||
{ok, #bdcs_Judgement{
|
||||
resolution = {allowed, #bdcs_ResolutionAllowed{}},
|
||||
resolution_legacy = allowed
|
||||
}};
|
||||
_ ->
|
||||
{ok, #bdcs_Judgement{resolution = forbidden}}
|
||||
{ok, #bdcs_Judgement{
|
||||
resolution = {forbidden, #bdcs_ResolutionForbidden{}},
|
||||
resolution_legacy = forbidden
|
||||
}}
|
||||
end
|
||||
end}
|
||||
],
|
||||
@ -192,13 +215,22 @@ validate_requester_fragment(C) ->
|
||||
{bouncer, fun('Judge', {_RulesetID, Fragments}) ->
|
||||
case get_ip(Fragments) of
|
||||
undefined ->
|
||||
{ok, #bdcs_Judgement{resolution = forbidden}};
|
||||
{ok, #bdcs_Judgement{
|
||||
resolution = {forbidden, #bdcs_ResolutionForbidden{}},
|
||||
resolution_legacy = forbidden
|
||||
}};
|
||||
BinaryIP ->
|
||||
case binary_to_list(BinaryIP) of
|
||||
IP ->
|
||||
{ok, #bdcs_Judgement{resolution = allowed}};
|
||||
{ok, #bdcs_Judgement{
|
||||
resolution = {allowed, #bdcs_ResolutionAllowed{}},
|
||||
resolution_legacy = allowed
|
||||
}};
|
||||
_ ->
|
||||
{ok, #bdcs_Judgement{resolution = forbidden}}
|
||||
{ok, #bdcs_Judgement{
|
||||
resolution = {forbidden, #bdcs_ResolutionForbidden{}},
|
||||
resolution_legacy = forbidden
|
||||
}}
|
||||
end
|
||||
end
|
||||
end}
|
||||
@ -225,12 +257,21 @@ validate_complex_fragment(C) ->
|
||||
auth = #bctx_v1_Auth{},
|
||||
user = #bctx_v1_User{}
|
||||
} ->
|
||||
{ok, #bdcs_Judgement{resolution = allowed}};
|
||||
{ok, #bdcs_Judgement{
|
||||
resolution = {allowed, #bdcs_ResolutionAllowed{}},
|
||||
resolution_legacy = allowed
|
||||
}};
|
||||
_ ->
|
||||
{ok, #bdcs_Judgement{resolution = forbidden}}
|
||||
{ok, #bdcs_Judgement{
|
||||
resolution = {forbidden, #bdcs_ResolutionForbidden{}},
|
||||
resolution_legacy = forbidden
|
||||
}}
|
||||
end;
|
||||
_ ->
|
||||
{ok, #bdcs_Judgement{resolution = forbidden}}
|
||||
{ok, #bdcs_Judgement{
|
||||
resolution = {forbidden, #bdcs_ResolutionForbidden{}},
|
||||
resolution_legacy = forbidden
|
||||
}}
|
||||
end
|
||||
end}
|
||||
],
|
||||
@ -269,9 +310,15 @@ validate_remote_user_fragment(C) ->
|
||||
{bouncer, fun('Judge', {_RulesetID, Fragments}) ->
|
||||
case get_user_id(Fragments) of
|
||||
UserID ->
|
||||
{ok, #bdcs_Judgement{resolution = allowed}};
|
||||
{ok, #bdcs_Judgement{
|
||||
resolution = {allowed, #bdcs_ResolutionAllowed{}},
|
||||
resolution_legacy = allowed
|
||||
}};
|
||||
_ ->
|
||||
{ok, #bdcs_Judgement{resolution = forbidden}}
|
||||
{ok, #bdcs_Judgement{
|
||||
resolution = {forbidden, #bdcs_ResolutionForbidden{}},
|
||||
resolution_legacy = forbidden
|
||||
}}
|
||||
end
|
||||
end}
|
||||
],
|
||||
|
Loading…
Reference in New Issue
Block a user