mirror of
https://github.com/harness/drone.git
synced 2025-05-12 15:10:09 +08:00
Merge branch 'jobatzil/misc/grants' of _OKE5H2PQKOUfzFFDuD4FA/default/CODE/gitness (#210)
This commit is contained in:
commit
09752c6aaa
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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"
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user