Skip to content

Commit 35d575e

Browse files
authored
Allow sign-in users without policy (#129)
1 parent 92a8aab commit 35d575e

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

restapi/user_login.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,15 @@ func getLoginResponse(lr *models.LoginRequest) (*models.LoginResponse, error) {
123123
log.Println("error login:", err)
124124
return nil, errInvalidCredentials
125125
}
126-
policy, err := adminClient.getPolicy(ctx, userInfo.PolicyName)
127-
if err != nil {
128-
log.Println("error login:", err)
129-
return nil, errInvalidCredentials
126+
policy, _ := adminClient.getPolicy(ctx, userInfo.PolicyName)
127+
// by default every user starts with an empty array of available actions
128+
// therefore we would have access only to pages that doesn't require any privilege
129+
// ie: service-account page
130+
actions := []string{}
131+
// if a policy is assigned to this user we parse the actions from there
132+
if policy != nil {
133+
actions = acl.GetActionsStringFromPolicy(policy)
130134
}
131-
132-
actions := acl.GetActionsStringFromPolicy(policy)
133-
134135
sessionID, err := login(credentials, actions)
135136
if err != nil {
136137
return nil, err

0 commit comments

Comments
 (0)