Merge branch 'jobatzil/misc/grants' of _OKE5H2PQKOUfzFFDuD4FA/default/CODE/gitness (#210)

This commit is contained in:
Johannes Batzill 2023-07-18 23:55:23 +00:00 committed by Harness
commit 09752c6aaa
4 changed files with 5 additions and 22 deletions

View File

@ -36,7 +36,8 @@ func (c *Controller) CreateToken(ctx context.Context, session *auth.Session,
if err = check.TokenLifetime(in.Lifetime); err != nil {
return nil, err
}
if err = check.AccessGrant(in.Grants, false); err != nil {
// TODO: Added to unblock UI - Depending on product decision enforce grants, or remove Grants completely.
if err = check.AccessGrant(in.Grants, true); err != nil {
return nil, err
}

View File

@ -43,7 +43,8 @@ func (c *Controller) CreateAccessToken(ctx context.Context, session *auth.Sessio
if err = check.TokenLifetime(in.Lifetime); err != nil {
return nil, err
}
if err = check.AccessGrant(in.Grants, false); err != nil {
// TODO: Added to unblock UI - Depending on product decision enforce grants, or remove Grants completely.
if err = check.AccessGrant(in.Grants, true); err != nil {
return nil, err
}

View File

@ -15,8 +15,7 @@ import (
)
const (
userTokenLifeTime time.Duration = 24 * time.Hour // 1 day.
oathTokenLifeTime time.Duration = 30 * time.Minute // 30 min.
userTokenLifeTime time.Duration = 24 * time.Hour // 1 day.
)
func CreateUserSession(ctx context.Context, tokenStore store.TokenStore,
@ -64,21 +63,6 @@ func CreateSAT(ctx context.Context, tokenStore store.TokenStore,
)
}
func CreateOAuth(ctx context.Context, tokenStore store.TokenStore,
createdBy *types.Principal, createdFor *types.User,
name string, grants enum.AccessGrant) (*types.Token, string, error) {
return Create(
ctx,
tokenStore,
enum.TokenTypeOAuth2,
createdBy,
createdFor.ToPrincipal(),
name,
oathTokenLifeTime,
grants,
)
}
func Create(ctx context.Context, tokenStore store.TokenStore,
tokenType enum.TokenType, createdBy *types.Principal, createdFor *types.Principal,
uid string, lifetime time.Duration, grants enum.AccessGrant) (*types.Token, string, error) {

View File

@ -16,7 +16,4 @@ const (
// TokenTypeSAT is a service account access token.
TokenTypeSAT TokenType = "sat"
// TokenTypeOAuth2 is the token returned to an oauth client.
TokenTypeOAuth2 TokenType = "oauth2"
)