Skip to content

Commit

Permalink
Add token generation
Browse files Browse the repository at this point in the history
Signed-off-by: Clément Blaise <[email protected]>
  • Loading branch information
clementblaise committed Jul 17, 2024
1 parent 72a5615 commit 2cca013
Show file tree
Hide file tree
Showing 7 changed files with 608 additions and 24 deletions.
21 changes: 21 additions & 0 deletions apis/projects/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,27 @@ type ProjectRole struct {
// Groups are a list of OIDC group claims bound to this role
// +optional
Groups []string `json:"groups,omitempty"`
// Tokens are a list of tokens to generate
// +optional
Tokens []ProjectToken `json:"tokens,omitempty"`
}

// ProjectToken holds the configuration for a Token
type ProjectToken struct {
// ID is an id for the token
ID string `json:"id"`
// Description is a description for the token
// +optional
Description *string `json:"description,omitempty"`
// Duration before the token will expire. Valid time units are `s`, `m`, `h` and `d` E.g. 12h, 7d. No expiration if not set.
// +optional
ExpiresIn *string `json:"expiresIn,omitempty"`
// Duration to control token regeneration based on token age. Valid time units are `s`, `m`, `h` and `d`.
// +optional
RenewAfter *string `json:"renewAfter,omitempty"`
// Duration to control token regeneration based on remaining token lifetime. Valid time units are `s`, `m`, `h` and `d`.
// +optional
RenewBefore *string `json:"renewBefore,omitempty"`
}

// JWTToken holds the issuedAt and expiresAt values of a token
Expand Down
42 changes: 42 additions & 0 deletions apis/projects/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions package/crds/projects.argocd.crossplane.io_projects.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,38 @@ spec:
items:
type: string
type: array
tokens:
description: Tokens are a list of tokens to generate
items:
description: ProjectToken holds the configuration for
a Token
properties:
description:
description: Description is a description for the
token
type: string
expiresIn:
description: Duration before the token will expire.
Valid time units are `s`, `m`, `h` and `d` E.g.
12h, 7d. No expiration if not set.
type: string
id:
description: ID is an id for the token
type: string
renewAfter:
description: Duration to control token regeneration
based on token age. Valid time units are `s`, `m`,
`h` and `d`.
type: string
renewBefore:
description: Duration to control token regeneration
based on remaining token lifetime. Valid time units
are `s`, `m`, `h` and `d`.
type: string
required:
- id
type: object
type: array
required:
- name
type: object
Expand Down
40 changes: 40 additions & 0 deletions pkg/clients/mock/projects/mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions pkg/clients/projects/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ type ProjectServiceClient interface {
Update(ctx context.Context, in *project.ProjectUpdateRequest, opts ...grpc.CallOption) (*v1alpha1.AppProject, error)
// Delete deletes a project
Delete(ctx context.Context, in *project.ProjectQuery, opts ...grpc.CallOption) (*project.EmptyResponse, error)
// CreateToken a new project token
CreateToken(ctx context.Context, in *project.ProjectTokenCreateRequest, opts ...grpc.CallOption) (*project.ProjectTokenResponse, error)
// DeleteToken a new project token
DeleteToken(ctx context.Context, in *project.ProjectTokenDeleteRequest, opts ...grpc.CallOption) (*project.EmptyResponse, error)
}

// NewProjectServiceClient creates a new API client from a set of config options, or fails fatally if the new client creation fails.
Expand Down
Loading

0 comments on commit 2cca013

Please sign in to comment.