Skip to content
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

Auth: Fine-grained access control for TLS clients #14099

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
16f202f
api: Add `identity_management` API extension.
markylaing Sep 16, 2024
cd6fd48
lxd: Separate identity handlers by auth method.
markylaing Sep 13, 2024
f26e54a
shared/api: Add metadata to identity API response.
markylaing Sep 13, 2024
bd77f49
lxd/db/cluster: Add metadata to identity API response.
markylaing Sep 13, 2024
ccb7d21
lxd: Add metadata to identity API response.
markylaing Sep 13, 2024
a772e1f
shared/api: Add pending and fine-grained TLS certificate identity types.
markylaing Sep 16, 2024
f8090bb
lxd/db/cluster: Add pending and fine-grained TLS certificate identity…
markylaing Sep 16, 2024
978f055
lxd/db/cluster: Add pending TLS identity metadata type and method.
markylaing Sep 16, 2024
51ede48
lxd/db/cluster: Add method to unpend a TLS certificate.
markylaing Sep 16, 2024
9e02957
lxd/db/cluster: Omit pending TLS identity metadata from API responses.
markylaing Sep 16, 2024
64be20d
lxd/identity: Add pending and fine-grained TLS identity types.
markylaing Sep 16, 2024
d7708eb
lxd/auth/drivers: Handle fine-grained TLS clients in OpenFGA driver.
markylaing Sep 16, 2024
4f3e3ff
lxd: Move CA check into `certificateValidate` method.
markylaing Sep 16, 2024
3a1aa81
lxd: Don't show fine-grained or pending TLS certificates in certifica…
markylaing Sep 16, 2024
02a39e0
lxd: Allow fine-grained TLS identities to authenticate.
markylaing Sep 16, 2024
5392127
lxd: Allow fine-grained TLS identities list resources in any project.
markylaing Sep 16, 2024
477f32d
shared/api: Add API structs for identity creation.
markylaing Sep 16, 2024
983213a
shared/api: Add field to CertificateAddToken.
markylaing Sep 16, 2024
239adc7
lxd: Add `POST /1.0/auth/identities/tls`.
markylaing Sep 16, 2024
1c944d1
lxd: Add `DELETE /1.0/auth/identities/{tls,oidc}/{nameOrIdentifier}`.
markylaing Sep 16, 2024
1be1ecd
lxd: Allow fine-grained TLS identities to be added to groups.
markylaing Sep 16, 2024
f46f652
lxd: Omit pending TLS identities when updating the identity cache.
markylaing Sep 16, 2024
8d6693a
lxd: Skip server certificates that cannot be converted to a valid type.
markylaing Sep 16, 2024
3c68d15
client: Add client methods for creation and deletion of identities.
markylaing Sep 16, 2024
c76cb94
lxc/remote: Update `remote add` to handle tokens issued by identities…
markylaing Sep 16, 2024
5ae3497
lxc/auth: Add commands for creating and deleting identities.
markylaing Sep 16, 2024
29bcbf8
doc: Run make update-api.
markylaing Sep 16, 2024
e1fc039
i18n: Update translations.
markylaing Sep 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions client/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,9 @@ type InstanceServer interface {
GetIdentity(authenticationMethod string, nameOrIdentifier string) (identity *api.Identity, ETag string, err error)
GetCurrentIdentityInfo() (identityInfo *api.IdentityInfo, ETag string, err error)
UpdateIdentity(authenticationMethod string, nameOrIdentifier string, identityPut api.IdentityPut, ETag string) error
CreateTLSIdentity(identity api.TLSIdentitiesPost) error
CreateTLSIdentityToken(identity api.TLSIdentitiesPost) (*api.TLSIdentityToken, error)
DeleteIdentity(authenticationMethod string, nameOrIdentifier string, ETag string) error
GetIdentityProviderGroupNames() (identityProviderGroupNames []string, err error)
GetIdentityProviderGroups() (identityProviderGroups []api.IdentityProviderGroup, err error)
GetIdentityProviderGroup(identityProviderGroupName string) (identityProviderGroup *api.IdentityProviderGroup, ETag string, err error)
Expand Down
50 changes: 50 additions & 0 deletions client/lxd_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,56 @@ func (r *ProtocolLXD) UpdateIdentity(authenticationMethod string, nameOrIdentife
return nil
}

// DeleteIdentity deletes the specified identity.
func (r *ProtocolLXD) DeleteIdentity(authenticationMethod string, nameOrIdentifier string, ETag string) error {
err := r.CheckExtension("identity_management")
if err != nil {
return err
}

_, _, err = r.query(http.MethodDelete, api.NewURL().Path("auth", "identities", authenticationMethod, nameOrIdentifier).String(), nil, ETag)
if err != nil {
return err
}

return nil
}

// CreateTLSIdentity creates a TLS identity.
func (r *ProtocolLXD) CreateTLSIdentity(tlsIdentitiesPost api.TLSIdentitiesPost) error {
err := r.CheckExtension("identity_management")
if err != nil {
return err
}

_, _, err = r.query(http.MethodPost, api.NewURL().Path("auth", "identities", api.AuthenticationMethodTLS).String(), tlsIdentitiesPost, "")
if err != nil {
return err
}

return nil
}

// CreateTLSIdentityToken creates an identity token that can be used by an untrusted client to set up authentication with LXD.
func (r *ProtocolLXD) CreateTLSIdentityToken(tlsIdentitiesPost api.TLSIdentitiesPost) (*api.TLSIdentityToken, error) {
err := r.CheckExtension("identity_management")
if err != nil {
return nil, err
}

if !tlsIdentitiesPost.Token {
return nil, fmt.Errorf("Token needs to be true if requesting a token")
}

var token api.TLSIdentityToken
_, err = r.queryStruct(http.MethodPost, api.NewURL().Path("auth", "identities", api.AuthenticationMethodTLS).String(), tlsIdentitiesPost, "", &token)
if err != nil {
return nil, err
}

return &token, nil
}

// GetIdentityProviderGroupNames returns a list of identity provider group names.
func (r *ProtocolLXD) GetIdentityProviderGroupNames() ([]string, error) {
err := r.CheckExtension("access_management")
Expand Down
4 changes: 4 additions & 0 deletions doc/api-extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2470,3 +2470,7 @@ Adds the following internal metrics:
This introduces per-pool project disk limits, introducing a `limits.disk.pool.NAME`
configuration option to the project limits. When `limits.disk.pool.POOLNAME: 0`
for a project, the pool is excluded from `lxc storage list` in that project.

## `identity_management`

Adds functionality to create and delete TLS identities whose permissions can be managed via group membership.
Loading
Loading