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

Enforces login with auth permission #1654

Merged
merged 1 commit into from
Jun 5, 2024

Conversation

otaviojacobi
Copy link
Contributor

@otaviojacobi otaviojacobi commented Jun 4, 2024

We are moving towards more granular login permissions based on roles. The main advantage is that this allow for more control over different permissions, for example, users added by SAML won't be able to do auth.credentials_login (and auth.social_service_account_login still to be done in balena-api). More over, this also allow for more control, for example, in the future I could see orgs configuring their users to only allow specific login methods (altough this is a stretch, the work here creates the foundation for it to be possible).

@joshbwlng
Copy link
Contributor

@otaviojacobi Could you give some background on why we're adding auth.credentials_login, and also some tests should probably be added.

src/features/auth/login.ts Outdated Show resolved Hide resolved
@otaviojacobi otaviojacobi force-pushed the enforces-login-with-auth-permission branch from cdf177b to 664f24e Compare June 5, 2024 12:11
@otaviojacobi otaviojacobi force-pushed the enforces-login-with-auth-permission branch from 664f24e to 4e453b1 Compare June 5, 2024 12:58
@otaviojacobi otaviojacobi marked this pull request as ready for review June 5, 2024 12:59
@otaviojacobi otaviojacobi requested a review from a team June 5, 2024 12:59
@flowzone-app flowzone-app bot enabled auto-merge June 5, 2024 13:07
@flowzone-app flowzone-app bot merged commit 4d15b35 into master Jun 5, 2024
47 checks passed
@flowzone-app flowzone-app bot deleted the enforces-login-with-auth-permission branch June 5, 2024 15:18
@@ -28,6 +29,12 @@ export const login =
if (!matches) {
throw new BadRequestError('Current password incorrect.');
}

const userPermissions = await permissions.getUserPermissions(user.id);
Copy link
Member

Choose a reason for hiding this comment

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

I think that you should be able to replace this w/ a middleware.permissionRequired('auth.credentials_login', { statusCode: 400, message: 'User not allowed to login.' }), but

  1. we can't do it that way if we want to only make this check after validating the user's password.
  2. it's not a big deal
  3. we atm do not support that kind of a second argument

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.

4 participants