forked from gravitational/teleport
-
Notifications
You must be signed in to change notification settings - Fork 0
/
roles.go
55 lines (48 loc) · 1.48 KB
/
roles.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package teleport
import (
"fmt"
"strings"
"github.com/gravitational/trace"
)
// Role identifies the role of SSH server connection
type Role string
// Set sets the value of the role from string, used to integrate with CLI tools
func (r *Role) Set(v string) error {
val := Role(strings.Title(v))
if err := val.Check(); err != nil {
return trace.Wrap(err)
}
*r = val
return nil
}
// String returns debug-friendly representation of this role
func (r *Role) String() string {
return fmt.Sprintf("%v", strings.ToUpper(string(*r)))
}
// Check checks if this a a valid role value, returns nil
// if it's ok, false otherwise
func (r *Role) Check() error {
switch *r {
case RoleAuth, RoleUser, RoleWeb, RoleNode, RoleAdmin, RoleProvisionToken, RoleSignup, RoleProxy:
return nil
}
return trace.BadParameter("role %v is not supported", *r)
}
const (
// RoleAuth is for teleport auth server (authority, authentication and authorization)
RoleAuth Role = "Auth"
// RoleUser is a role for teleport SSH user
RoleUser Role = "User"
// RoleWeb is for web access users
RoleWeb Role = "Web"
// RoleNode is a role for SSH node in the cluster
RoleNode Role = "Node"
// RoleProxy is a role for SSH proxy in the cluster
RoleProxy Role = "Proxy"
// RoleAdmin is admin role
RoleAdmin Role = "Admin"
// RoleProvisionToken is a role for nodes authenticated using provisioning tokens
RoleProvisionToken Role = "ProvisionToken"
// RoleSignup is for first time signing up users
RoleSignup Role = "Signup"
)