forked from hashicorp/vault-guides
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding sentinel policy to enforce username for ssh secret engine
- Loading branch information
1 parent
1910808
commit 120068d
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import "strings" | ||
import "strings" | ||
|
||
username_match = func() { | ||
# Make sure there is request data | ||
if length(request.data else 0) is 0 { | ||
return false | ||
} | ||
|
||
# Make sure request data includes username | ||
if length(request.data.username else 0) is 0 { | ||
return false | ||
} | ||
|
||
# Make sure the supplied username matches the user's name | ||
if request.data.username != identity.entity.aliases[0].name { | ||
return false | ||
} | ||
|
||
return true | ||
} | ||
|
||
main = rule { | ||
strings.has_prefix(request.path, "ssh-client-signer/sign/my-role") and username_match() | ||
} |