Skip to content

Commit

Permalink
Allow sign-in users without policy (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alevsk authored May 19, 2020
1 parent 92a8aab commit 35d575e
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions restapi/user_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,15 @@ func getLoginResponse(lr *models.LoginRequest) (*models.LoginResponse, error) {
log.Println("error login:", err)
return nil, errInvalidCredentials
}
policy, err := adminClient.getPolicy(ctx, userInfo.PolicyName)
if err != nil {
log.Println("error login:", err)
return nil, errInvalidCredentials
policy, _ := adminClient.getPolicy(ctx, userInfo.PolicyName)
// by default every user starts with an empty array of available actions
// therefore we would have access only to pages that doesn't require any privilege
// ie: service-account page
actions := []string{}
// if a policy is assigned to this user we parse the actions from there
if policy != nil {
actions = acl.GetActionsStringFromPolicy(policy)
}

actions := acl.GetActionsStringFromPolicy(policy)

sessionID, err := login(credentials, actions)
if err != nil {
return nil, err
Expand Down

0 comments on commit 35d575e

Please sign in to comment.