github.com/gravitational/teleport/api@v0.0.0-20240507183017-3110591cbafc/types/jwt.go (about) 1 /* 2 Copyright 2021 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 types 18 19 import ( 20 "time" 21 22 "github.com/gravitational/trace" 23 24 "github.com/gravitational/teleport/api/types/wrappers" 25 ) 26 27 // GenerateAppTokenRequest are the parameters used to generate an application token. 28 type GenerateAppTokenRequest struct { 29 // Username is the Teleport identity. 30 Username string 31 32 // Roles are the roles assigned to the user within Teleport. 33 Roles []string 34 35 // Traits are the traits assigned to the user within Teleport. 36 Traits wrappers.Traits 37 38 // Expiry is time to live for the token. 39 Expires time.Time 40 41 // URI is the URI of the recipient application. 42 URI string 43 } 44 45 // Check validates the request. 46 func (p *GenerateAppTokenRequest) Check() error { 47 if p.Username == "" { 48 return trace.BadParameter("username missing") 49 } 50 if p.Expires.IsZero() { 51 return trace.BadParameter("expires missing") 52 } 53 if p.URI == "" { 54 return trace.BadParameter("uri missing") 55 } 56 return nil 57 } 58 59 // GenerateSnowflakeJWT are the parameters used to generate a Snowflake JWT. 60 type GenerateSnowflakeJWT struct { 61 // Username is the Teleport identity. 62 Username string 63 // Account is the Snowflake account name. 64 Account string 65 } 66 67 // Check validates the request. 68 func (p *GenerateSnowflakeJWT) Check() error { 69 if p.Username == "" { 70 return trace.BadParameter("username missing") 71 } 72 if p.Account == "" { 73 return trace.BadParameter("missing account") 74 } 75 return nil 76 }