Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api, cli, ui): auth consumer token expiration and last authentication #5822

Merged
merged 14 commits into from
Jun 16, 2021

Conversation

fsamin
Copy link
Member

@fsamin fsamin commented May 21, 2021

No description provided.

@fsamin fsamin changed the title feat(api, ui): auth consumer token expiration and last authentication feat(api, cli, ui): auth consumer token expiration and last authentication May 21, 2021
fsamin added 7 commits May 21, 2021 18:03
Signed-off-by: francois  samin <[email protected]>
Signed-off-by: francois  samin <[email protected]>
Signed-off-by: francois  samin <[email protected]>
Signed-off-by: francois  samin <[email protected]>
Signed-off-by: francois  samin <[email protected]>
Signed-off-by: francois  samin <[email protected]>
@fsamin fsamin force-pushed the feat/api/auth_token_expiration branch from ee1d0de to 639834c Compare May 21, 2021 16:06
fsamin added 2 commits May 24, 2021 12:09
Signed-off-by: francois  samin <[email protected]>
Signed-off-by: francois  samin <[email protected]>
@@ -86,6 +87,9 @@ var authConsumerNewCmd = cli.Command{
Name: "scopes",
Type: cli.FlagSlice,
Usage: "Define the list of scopes for the consumer",
}, {
Name: "duration",
Usage: "Validity period of the token generated for the consumer",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Usage: "Validity period of the token generated for the consumer",
Usage: "Validity period of the token generated for the consumer (in days)",

req.NewDuration = api.Config.Auth.TokenDefaultDuration
}
var overlapDuration time.Duration
if req.OverlapDuration != "" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should check that overlap duration is less than duration ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}
var overlapDuration time.Duration
if req.OverlapDuration != "" {
overlapDuration, err = time.ParseDuration(req.OverlapDuration)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not both overlap and validity duration in same format (string duration vs count of hours) ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because overlap should be in minutes or hours, and validity should be a matter of days

@@ -24,7 +24,8 @@ func NewConsumerWorker(ctx context.Context, db gorpmapper.SqlExecutorWithTx, nam
sdk.AuthConsumerScopeRunExecution,
sdk.AuthConsumerScopeService,
),
IssuedAt: time.Now(),
//IssuedAt: time.Now(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To remove ?

@@ -46,7 +47,8 @@ func NewConsumerExternal(ctx context.Context, db gorpmapper.SqlExecutorWithTx, u
"username": userInfo.Username,
"email": userInfo.Email,
},
IssuedAt: time.Now(),
//IssuedAt: time.Now(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To remove ?

@@ -127,6 +128,7 @@ func InsertConsumer(ctx context.Context, db gorpmapper.SqlExecutorWithTx, ac *sd

// UpdateConsumer in database.
func UpdateConsumer(ctx context.Context, db gorpmapper.SqlExecutorWithTx, ac *sdk.AuthConsumer) error {
ac.ValidityPeriods.Sort()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be nice to sort also on get.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

func checkSigninConsumerTokenIssuedAt(ctx context.Context, payload signinBuiltinConsumerToken, v sdk.AuthConsumerValidityPeriod) (string, error) {
var eqIAT = payload.IAT == v.IssuedAt.Unix()
var hasRevoke = v.Duration > 0
var beforeRevoke = time.Now().Before(v.IssuedAt.Add(v.Duration))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe only one afterRevoke value should be clearer.

}
return authentication.SignJWS(payload, 0) // 0 means no expiration time
return authentication.SignJWS(payload, latestValidityPeriod.Duration)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add issued at value as parameter instead of using time.Now inside SignJWS func

@@ -150,7 +150,7 @@ func initBuiltinConsumersFromStartupConfig(ctx context.Context, tx gorpmapper.Sq
Data: map[string]string{},
GroupIDs: []int64{group.SharedInfraGroup.ID},
ScopeDetails: scopes,
IssuedAt: time.Unix(startupConfig.IAT, 0),
ValidityPeriods: sdk.NewAuthConsumerValidityPeriod(time.Unix(startupConfig.IAT, 0), 0),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set a value for services consumers validity period that can be greater than other consumers. Maybe we should update doc for services setup where 'consumer new' command is used.

Signed-off-by: francois  samin <[email protected]>
@ovh-cds
Copy link
Collaborator

ovh-cds commented May 31, 2021

CDS Report build-all-cds#16086.0 ✘

  • Build
    • Build and Package All ✔
    • Build Debpacker ✔
    • Build OS-Ansible-Inventory ✔
    • Build SMTPMock ✔
    • Lint UI Translate ✔
    • Test CLI ✔
    • Test Engine ✘
    • Test SDK ✔
    • Test SDK Rust ✔
    • Test UI ✔

Signed-off-by: francois  samin <[email protected]>
@ovh-cds
Copy link
Collaborator

ovh-cds commented Jun 7, 2021

CDS Report build-all-cds#16108.0 ✘

  • Build
    • Build and Package All ✔
    • Build Debpacker ✔
    • Build OS-Ansible-Inventory ✔
    • Build SMTPMock ✔
    • Lint UI Translate ✔
    • Test CLI ✔
    • Test Engine ✔
    • Test SDK ✔
    • Test SDK Rust ✔
    • Test UI ✔
  • Package
    • Docker ✘

@ovh-cds
Copy link
Collaborator

ovh-cds commented Jun 8, 2021

CDS Report build-all-cds#16108.1 ✘

  • Build
    • Build and Package All ✔
    • Build Debpacker ✔
    • Build OS-Ansible-Inventory ✔
    • Build SMTPMock ✔
    • Lint UI Translate ✔
    • Test CLI ✔
    • Test Engine ✔
    • Test SDK ✔
    • Test SDK Rust ✔
    • Test UI ✔
  • Package
    • Docker ✔
  • Integration
    • Docker Compose Tests ✔
    • Standalone Tests ✘

@fsamin fsamin requested review from yesnault and richardlt June 9, 2021 15:52
@ovh-cds
Copy link
Collaborator

ovh-cds commented Jun 9, 2021

CDS Report build-all-cds#16108.2 ✘

  • Build
    • Build and Package All ✔
    • Build Debpacker ✔
    • Build OS-Ansible-Inventory ✔
    • Build SMTPMock ✔
    • Lint UI Translate ✔
    • Test CLI ✔
    • Test Engine ✔
    • Test SDK ✔
    • Test SDK Rust ✔
    • Test UI ✔
  • Package
    • Docker ✘

@ovh-cds
Copy link
Collaborator

ovh-cds commented Jun 10, 2021

CDS Report build-all-cds#16108.3 ✘

  • Build
    • Build and Package All ✔
    • Build Debpacker ✔
    • Build OS-Ansible-Inventory ✔
    • Build SMTPMock ✔
    • Lint UI Translate ✔
    • Test CLI ✔
    • Test Engine ✔
    • Test SDK ✔
    • Test SDK Rust ✔
    • Test UI ✔
  • Package
    • Docker ✘

yesnault
yesnault previously approved these changes Jun 14, 2021
richardlt
richardlt previously approved these changes Jun 14, 2021
@fsamin fsamin dismissed stale reviews from richardlt and yesnault via 27287c4 June 14, 2021 09:31
@ovh-cds
Copy link
Collaborator

ovh-cds commented Jun 14, 2021

CDS Report build-all-cds#16141.0 ✘

  • Build
    • Build and Package All ✔
    • Build Debpacker ✔
    • Build OS-Ansible-Inventory ✔
    • Build SMTPMock ✔
    • Lint UI Translate ✔
    • Test CLI ✔
    • Test Engine ✔
    • Test SDK ✔
    • Test SDK Rust ✔
    • Test UI ✔
  • Package
    • Docker ✔
  • Integration
    • Docker Compose Tests ✔
    • Standalone Tests ✘

@sonarqubecloud
Copy link

@ovh ovh deleted a comment from ovh-cds Jun 15, 2021
@ovh ovh deleted a comment from ovh-cds Jun 15, 2021
@ovh ovh deleted a comment from ovh-cds Jun 15, 2021
@ovh ovh deleted a comment from ovh-cds Jun 15, 2021
@ovh ovh deleted a comment from ovh-cds Jun 15, 2021
@ovh ovh deleted a comment from ovh-cds Jun 15, 2021
@sguiheux sguiheux merged commit 2581044 into master Jun 16, 2021
@fsamin fsamin deleted the feat/api/auth_token_expiration branch June 25, 2021 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants