Users org - #26
Conversation
8100a43 to
0042b4e
Compare
da05fd7 to
e2f7d44
Compare
| "github.com/gophercloud/gophercloud/openstack/identity/v3/tokens" | ||
| "github.com/kbhonagiri16/visualization-client" | ||
| "github.com/shuaiming/mung/middlewares" | ||
| "github.com/spf13/viper" |
There was a problem hiding this comment.
I see later you are using it for reading information from config file.
Please read all your need on auth_proxy/main.go level and pass here as init arguments.
| username := viper.GetString("openstack.username") | ||
| password := viper.GetString("openstack.password") | ||
| domain := viper.GetString("openstack.domain_name") | ||
| project := viper.GetString("openstack.project_name") |
There was a problem hiding this comment.
As I said above. Just pass all these parameters as some options model
| ) | ||
|
|
||
| var openstackToken = "" | ||
| var expiresAt int64 |
There was a problem hiding this comment.
- It shouldn't be in module level, as far as it is connected to specific instance of token
- It will lead to concurrency issues just several go routings update the value
Please,
- Create structure for handling this specific problem (getting openstack token) with all methods assigned to it.
- Check https://golang.org/pkg/sync/ package and use it to make this code safe to be executed concurrently
|
|
||
| sess.Values[SessionUsername] = username | ||
|
|
||
| vclient, clientErr := client.NewVisualizationClient(visualizationEndpoint, http.Client{}, openstackToken) |
There was a problem hiding this comment.
Client should be created once during NewOpenStackAuthHandler
| return | ||
| } | ||
| // Get the user by its name if exists | ||
| userGet, err := vclient.GetUserName(username) |
There was a problem hiding this comment.
Let us move all this code below to separate method returning only GafanaUpdateCommand, error
| http.Redirect(rw, r, "/auth/openstack", http.StatusForbidden) | ||
| } | ||
| // Create User | ||
| _, err = vclient.CreateUser(user) |
There was a problem hiding this comment.
We shouldn't create any entities in visualization-api or Grafana here.
https://github.com/zaletniy/visualization-api/blob/auth_proxy/pkg/auth_proxy/visualization.go is the place for this.
The responsibility of OpenStackAuthHandler
- check user's credentials in openstack - login to keystone
- if passed. Create GafanaUpdateCommand and save in session
|
|
||
| log.Logger.Debugf("%s is setting as '%s'", SessionUsername, username) | ||
| // Check if credentials are correct | ||
| ok, err := oh.authenticate(username, password, grafanaEndpoint) |
There was a problem hiding this comment.
It is authentication to OpenStack Keystone, not Grafana
ca12277 to
72e2da9
Compare
|
@zaletniy done with suggested changes but have few CI issues will update them soon. |
fcecfec to
ed732d9
Compare
create user if not created, give roles in organization according to data in context Change-Id: 45485b1
Added openstack token and
create user if not created
create organization(s) if not created
give roles in organization according to data in context