Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
7f24cf5
Added auth information resource with persisting teleport version
vapopov Mar 5, 2025
3afa085
Check the set of the auth info to compare with min/max versions in cl…
vapopov Mar 11, 2025
42b8f57
Store only one entity for the cluster version
vapopov Mar 24, 2025
e64be05
Merge remote-tracking branch 'origin/master' into vapopov/major-versi…
vapopov Apr 7, 2025
ed65c85
Add CRUD endpoints
vapopov Apr 16, 2025
9215b65
Add validation for version, sub kind, kind, name
vapopov Apr 16, 2025
f17930d
Rename to authinfo.go
vapopov Apr 16, 2025
ca2e9cf
Merge remote-tracking branch 'origin/master' into vapopov/major-versi…
vapopov Apr 16, 2025
259321d
Assigning error after creating new resource
vapopov Apr 16, 2025
319ef14
Move retry logic to version check helper
vapopov Apr 18, 2025
38d3292
Call create/update depends on if resource is created already
vapopov Apr 19, 2025
9b40b98
Restrict major version downgrade
vapopov Apr 22, 2025
168f991
Make `--skip-version-check` available for major upgrade check
vapopov Apr 23, 2025
bf3a7c7
Fix linter warnings
vapopov Apr 23, 2025
ab729e2
Add logs and make skip more safe in case of broke item in backend
vapopov May 1, 2025
3fea4c4
Merge remote-tracking branch 'origin/master' into vapopov/major-versi…
vapopov May 1, 2025
140da4d
Remove deleting version item from process database, stateBackend does…
vapopov May 1, 2025
8956cef
Rename AuthInfo to BackendInfo
vapopov May 2, 2025
3aa4da5
Make skip-version-check to upsert the version in backend
vapopov May 2, 2025
7a1e70f
Update lib/auth/version.go
vapopov May 5, 2025
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
245 changes: 245 additions & 0 deletions api/gen/proto/go/teleport/authinfo/v1/authinfo.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions api/proto/teleport/authinfo/v1/authinfo.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright 2025 Gravitational, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package teleport.authinfo.v1;

import "teleport/header/v1/metadata.proto";

option go_package = "github.com/gravitational/teleport/api/gen/proto/go/teleport/authinfo/v1;authinfo";
Comment thread
vapopov marked this conversation as resolved.
Outdated

// AuthInfo holds meta-information for specific server.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, auth info is now meta information about the whole backend, not a specific server. Could you document that it's a singleton?

The comment should also explains who creates the resource, who reads it, and what issue it is solving.

message AuthInfo {
string kind = 1;
string sub_kind = 2;
string version = 3;
teleport.header.v1.Metadata metadata = 4;

AuthInfoSpec spec = 5;
}

// AuthInfoSpec encodes the parameters auth server meta-information.
message AuthInfoSpec {
// teleport_version advertises the version of the auth server.
Comment thread
vapopov marked this conversation as resolved.
Outdated
string teleport_version = 1;
}
57 changes: 57 additions & 0 deletions api/types/authinfo/info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
Copyright 2025 Gravitational, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package authinfo

import (
"github.com/gravitational/teleport/api/gen/proto/go/teleport/authinfo/v1"
headerv1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/header/v1"
"github.com/gravitational/teleport/api/types"
"github.com/gravitational/trace"
)

// NewAuthInfo creates a new auth info resource.
func NewAuthInfo(spec *authinfo.AuthInfoSpec) (*authinfo.AuthInfo, error) {
info := &authinfo.AuthInfo{
Kind: types.KindAuthInfo,
Version: types.V1,
Metadata: &headerv1.Metadata{
Name: types.MetaNameAuthInfo,
},
Spec: spec,
}
if err := ValidateAuthInfo(info); err != nil {
return nil, trace.Wrap(err)
}

return info, nil
}

// ValidateAuthInfo checks that required parameters are set
// for the specified AuthInfo.
func ValidateAuthInfo(c *authinfo.AuthInfo) error {
if c == nil {
return trace.BadParameter("AuthInfo is nil")
}
if c.Metadata == nil {
return trace.BadParameter("Metadata is nil")
}
if c.Spec == nil {
return trace.BadParameter("Spec is nil")
}
Comment thread
vapopov marked this conversation as resolved.
Outdated

Comment thread
vapopov marked this conversation as resolved.
Outdated
return nil
}
6 changes: 6 additions & 0 deletions api/types/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,12 @@ const (
// KindServerInfo contains info that should be applied to joining Nodes.
KindServerInfo = "server_info"

// KindAuthInfo contains auth server info.
KindAuthInfo = "auth_info"

// MetaNameAuthInfo name auth server info entity.
MetaNameAuthInfo = "auth-info"

// SubKindCloudInfo is a ServerInfo that was created by the Discovery
// service to match with a single discovered instance.
SubKindCloudInfo = "cloud_info"
Expand Down
8 changes: 8 additions & 0 deletions lib/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,12 @@ func NewServer(cfg *InitConfig, opts ...ServerOption) (*Server, error) {
Backend: cfg.Backend,
}
}
if cfg.AuthInfo == nil {
cfg.AuthInfo, err = local.NewAuthInfoService(cfg.Backend)
if err != nil {
return nil, trace.Wrap(err, "creating AuthInfo service")
}
}

if cfg.Logger == nil {
cfg.Logger = slog.With(teleport.ComponentKey, teleport.ComponentAuth)
Expand Down Expand Up @@ -530,6 +536,7 @@ func NewServer(cfg *InitConfig, opts ...ServerOption) (*Server, error) {
StableUNIXUsersInternal: cfg.StableUNIXUsers,
WorkloadIdentityX509Revocations: cfg.WorkloadIdentityX509Revocations,
WorkloadIdentityX509Overrides: cfg.WorkloadIdentityX509Overrides,
AuthInfoService: cfg.AuthInfo,
}

as := Server{
Expand Down Expand Up @@ -764,6 +771,7 @@ type Services struct {
services.StableUNIXUsersInternal
services.WorkloadIdentityX509Revocations
services.WorkloadIdentityX509Overrides
services.AuthInfoService
}

// GetWebSession returns existing web session described by req.
Expand Down
Loading