Skip to content

Commit 1f69fd5

Browse files
authored
emit user_origin for local login event (#52124)
* emit user_origin for local login event * ignore unspecified origin while allowing overriding with a defined origin value * abstract origin getter * test: emit unspecified origin value to test the initial value is preserved
1 parent ccfa399 commit 1f69fd5

File tree

14 files changed

+4163
-3633
lines changed

14 files changed

+4163
-3633
lines changed

api/proto/teleport/legacy/types/events/events.proto

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,24 @@ enum UserKind {
7979
USER_KIND_BOT = 2;
8080
}
8181

82+
// UserOrigin is the origin of a user account.
83+
// Keep the values in sync with UserOrigin enum defined in
84+
// prehogv1 and prehogv1alpha.
85+
enum UserOrigin {
86+
// Indicates a legacy cluster emitting events without a defined user origin.
87+
USER_ORIGIN_UNSPECIFIED = 0;
88+
// Indicates a local user.
89+
USER_ORIGIN_LOCAL = 1;
90+
// Indicates an SSO user originated from the SAML or OIDC connector.
91+
USER_ORIGIN_SSO = 2;
92+
// Indicates a user originated from the Okta integration.
93+
USER_ORIGIN_OKTA = 3;
94+
// Indicates a user originated from the SCIM integration.
95+
USER_ORIGIN_SCIM = 4;
96+
// Indicates a user originated from the EntraID integration.
97+
USER_ORIGIN_ENTRAID = 5;
98+
}
99+
82100
// UserMetadata is a common user event metadata
83101
message UserMetadata {
84102
// User is teleport user name
@@ -119,6 +137,9 @@ message UserMetadata {
119137
// BotInstanceID is the ID of the Bot Instance if this action is associated
120138
// with one.
121139
string BotInstanceID = 12 [(gogoproto.jsontag) = "bot_instance_id,omitempty"];
140+
141+
// UserOrigin specifies the origin of this user account.
142+
UserOrigin UserOrigin = 13 [(gogoproto.jsontag) = "user_origin,omitempty"];
122143
}
123144

124145
// Server is a server metadata

api/types/events/conv.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
Copyright 2025 Gravitational, Inc.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package events
18+
19+
import (
20+
"github.com/gravitational/teleport/api/types"
21+
"github.com/gravitational/teleport/api/types/common"
22+
)
23+
24+
// UserOriginFromUserType converts API UserType to UserOrigin.
25+
func UserOriginFromUserType(userType types.UserType) UserOrigin {
26+
switch userType {
27+
case types.UserTypeSSO:
28+
return UserOrigin_USER_ORIGIN_SSO
29+
case types.UserTypeLocal:
30+
return UserOrigin_USER_ORIGIN_LOCAL
31+
default:
32+
return UserOrigin_USER_ORIGIN_UNSPECIFIED
33+
}
34+
}
35+
36+
// UserOriginFromOriginLabel converts API origin label value to UserOrigin.
37+
func UserOriginFromOriginLabel(origin string) UserOrigin {
38+
switch origin {
39+
case common.OriginOkta:
40+
return UserOrigin_USER_ORIGIN_OKTA
41+
case common.OriginSCIM:
42+
return UserOrigin_USER_ORIGIN_SCIM
43+
case common.OriginEntraID:
44+
return UserOrigin_USER_ORIGIN_ENTRAID
45+
default:
46+
return UserOrigin_USER_ORIGIN_UNSPECIFIED
47+
}
48+
}

api/types/events/events.pb.go

Lines changed: 1228 additions & 1146 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gen/proto/go/prehog/v1/teleport.pb.go

Lines changed: 253 additions & 162 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)