mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 15:59:41 +02:00
* feat(api): relocate authorizations outside of JWT * fix(api): update user authorization after enabling the RBAC extension * feat(api): add PortainerEndpointList operation in the default portainer authorizations * feat(auth): retrieve authorization from API instead of JWT * refactor(auth): move permissions retrieval to function * refactor(api): document authorizations methods
29 lines
755 B
Go
29 lines
755 B
Go
package migrator
|
|
|
|
import portainer "github.com/portainer/portainer/api"
|
|
|
|
func (m *Migrator) updateUsersToDBVersion20() error {
|
|
legacyUsers, err := m.userService.Users()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
authorizationServiceParameters := &portainer.AuthorizationServiceParameters{
|
|
EndpointService: m.endpointService,
|
|
EndpointGroupService: m.endpointGroupService,
|
|
RoleService: m.roleService,
|
|
TeamMembershipService: m.teamMembershipService,
|
|
UserService: m.userService,
|
|
}
|
|
|
|
authorizationService := portainer.NewAuthorizationService(authorizationServiceParameters)
|
|
|
|
for _, user := range legacyUsers {
|
|
err := authorizationService.UpdateUserAuthorizations(user.ID)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|