MCPcopy Create free account
hub / github.com/rilldata/rill / IssueDeploymentAuthToken

Method IssueDeploymentAuthToken

admin/auth_token.go:137–157  ·  view source on GitHub ↗

IssueDeploymentAuthToken generates and persists a new auth token for a deployment.

(ctx context.Context, deploymentID string, ttl *time.Duration)

Source from the content-addressed store, hash-verified

135
136// IssueDeploymentAuthToken generates and persists a new auth token for a deployment.
137func (s *Service) IssueDeploymentAuthToken(ctx context.Context, deploymentID string, ttl *time.Duration) (AuthToken, error) {
138 tkn := authtoken.NewRandom(authtoken.TypeDeployment)
139
140 var expiresOn *time.Time
141 if ttl != nil {
142 t := time.Now().Add(*ttl)
143 expiresOn = &t
144 }
145
146 dat, err := s.DB.InsertDeploymentAuthToken(ctx, &database.InsertDeploymentAuthTokenOptions{
147 ID: tkn.ID.String(),
148 SecretHash: tkn.SecretHash(),
149 DeploymentID: deploymentID,
150 ExpiresOn: expiresOn,
151 })
152 if err != nil {
153 return nil, err
154 }
155
156 return &deploymentAuthToken{model: dat, token: tkn}, nil
157}
158
159// magicAuthToken implements AuthToken for magic tokens belonging to a project.
160type magicAuthToken struct {

Callers 1

StartDeploymentInnerMethod · 0.95

Calls 5

NewRandomFunction · 0.92
SecretHashMethod · 0.80
AddMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected