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

emit user_origin for local login event #52124

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 21 additions & 0 deletions api/proto/teleport/legacy/types/events/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,24 @@ enum UserKind {
USER_KIND_BOT = 2;
}

// UserOrigin is the origin of a user account.
// Keep the values in sync with UserOrigin enum defined in
// prehogv1 and prehogv1alpha.
enum UserOrigin {
// Indicates a legacy cluster emitting events without a defined user origin.
USER_ORIGIN_UNSPECIFIED = 0;
// Indicates a local user.
USER_ORIGIN_LOCAL = 1;
// Indicates an SSO user originated from the SAML or OIDC connector.
USER_ORIGIN_SSO = 2;
// Indicates a user originated from the Okta integration.
USER_ORIGIN_OKTA = 3;
// Indicates a user originated from the SCIM integration.
USER_ORIGIN_SCIM = 4;
// Indicates a user originated from the EntraID integration.
USER_ORIGIN_ENTRAID = 5;
}

// UserMetadata is a common user event metadata
message UserMetadata {
// User is teleport user name
Expand Down Expand Up @@ -119,6 +137,9 @@ message UserMetadata {
// BotInstanceID is the ID of the Bot Instance if this action is associated
// with one.
string BotInstanceID = 12 [(gogoproto.jsontag) = "bot_instance_id,omitempty"];

// UserOrigin specifies the origin of this user account.
UserOrigin UserOrigin = 13 [(gogoproto.jsontag) = "user_origin,omitempty"];
}

// Server is a server metadata
Expand Down
48 changes: 48 additions & 0 deletions api/types/events/conv.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
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 events

import (
"github.com/gravitational/teleport/api/types"
"github.com/gravitational/teleport/api/types/common"
)

// UserOriginFromUserType converts API UserType to UserOrigin.
func UserOriginFromUserType(userType types.UserType) UserOrigin {
switch userType {
case types.UserTypeSSO:
return UserOrigin_USER_ORIGIN_SSO
case types.UserTypeLocal:
return UserOrigin_USER_ORIGIN_LOCAL
default:
return UserOrigin_USER_ORIGIN_UNSPECIFIED
}
}

// UserOriginFromOriginLabel converts API origin label value to UserOrigin.
func UserOriginFromOriginLabel(origin string) UserOrigin {
switch origin {
case common.OriginOkta:
return UserOrigin_USER_ORIGIN_OKTA
case common.OriginSCIM:
return UserOrigin_USER_ORIGIN_SCIM
case common.OriginEntraID:
return UserOrigin_USER_ORIGIN_ENTRAID
default:
return UserOrigin_USER_ORIGIN_UNSPECIFIED
}
}
2,260 changes: 1,171 additions & 1,089 deletions api/types/events/events.pb.go

Large diffs are not rendered by default.

415 changes: 253 additions & 162 deletions gen/proto/go/prehog/v1/teleport.pb.go

Large diffs are not rendered by default.

Loading
Loading