-
Notifications
You must be signed in to change notification settings - Fork 458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FR: Limit ssh access based on OAuth groups/roles #547
Comments
Hi @LecrisUT this is part of our paid solution. As you mention one of the options to solve this is using the The difference between extensions and critical options is that a server/client must understand the critical options, but it can ignore unknown extensions. |
I will try this out on a cloud node to see how it would affect other implementations. Will this become available to self-hosted |
Any info on how the Otherwise, can someone suggest some methods of reading the ssh certificate options in script? Probably I'll have to use openssl, but if there is a more convenient tool, it would be much appreciated. |
@LecrisUT you might want to use extensions because the sshd implementation might refuse to authenticate a cert with an unknown critical option. Right now only 2 critical options are defined for a client cert. The docs about SSH certificates are in /~https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.certkeys |
Use case
If we have multiple machines, or a machine can have custom ssh access, e.g. Github or Gitea access, it would be better to have control over the user+domain the user can have ssh access. Currently this can be done with modifying the ssh template, but it would be great to have something accessible via cli/default template.
Also this would make it easier to integrate with LDAP's group management.
Implementation
Server side
For the host certificate either in the extension or critical options (still don't know the difference between them), we could add a key-value pair for
principal
or for a defaultgroup
to.Token.Groups
array so that we can query the membership of users later on.On the
sshd.config
side, the simplest implementation would be to create a simple command (preferably baked instep-cli
for security) to input inAuthorizedPrincipalsCommand
, and upon success it would output the contents of.ssh/authorized_principals
or the username (and.Token.preferred_username
?) if the file does not exist, otherwise output an empty string so that it fails authentication. A mock-up command of this would be:Client side
For the client if authenticating via OAuth, simply store the groups it belongs to into an extension/critical options which are obtained via the
.Token
. This can be done either viaroles
or specific mappers on the OAuth. From my default keycloak setting I have added a scope based onroles
(/resource_access/ClientID/roles
) and one based on custom mappers (groups
), and here's a stripped down version of it:IMO the mappers is easier to setup as it takes all of the groups it belongs to, but with roles, we can change the name to better suit the certificate's names.
Some customization could be to allow/deny
gitea@gitea.example.com
out of the gate based on role mapping, although it shouldn't be necessary.Things to consider
.ssh/authorized_principals
The text was updated successfully, but these errors were encountered: