$ whoami
$ whoami
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http)
throws Exception {
http
.authorizeHttpRequests((requests) -> requests
.antMatchers("/", "/home").permitAll()
.anyRequest().authenticated()
)
.formLogin((form) -> form
.loginPage("/login")
.permitAll()
)
.logout((logout) -> logout.permitAll());
return http.build();
}
if
blocks, it can be nicer, but it’s still usually
tied to a specific framework
alg=none
)alg=none
lets you create valid tokens with no signature).
Combined with poorly designed libraries, it also lets an attacker
exploit alg confusion: the service verifies the token with a public key,
expecting the token to be signed with RSA, but the attacker provides a
token signed with a HMAC, using the public key as the secret.
// fact
right("file.txt", "read");
// rule
can_read($file) <- right($file, "read");
// check
check if right("file.txt", "read");
// policy
allow if right("file.txt", "read");
// in the token
check if time($time), $time < 2022-10-21T00:00:00Z;
right("organization", "<org1_id>", "read");
right("organization", "<org2_id>", "write");
right("account", "<acct1_id>", "write");
// in the service
time(2022-10-20T00:00:00Z);
allow if right("organization", "<org1_id>", "write")
or right("account", "<acct1_id>", "write");
clementd Here the token carries 1 check that must always be fulfilled
(a TTL check)
It also carries information about the holder: they’re allowed to perform
read operation across the whole ORG1 organization, and write operation
for ORG2. They are also allowed to perform write operations on ACCT1
(accounts are part of orgs) On the service side, the current time is
provided (which will allow the token check to pass), and a policy checks
that the account being accessed can be edited by the holder (either with
direct account access, or through an organization).
$time
bit, it’s called a datalog variable and it
is used for unifying facts with rules.
check if time($time), $time < 2022-10-20T00:00:00Z;
check if source_ip($source_ip), $source_ip == "1.2.3.4";
check if group("admin") trusting ed25519/<public_key>;
clementd & geal