fleet/server
Lucas Manuel Rodriguez 57816592ba
Add read replica testing helpers and fix non-sso login bug (#4908)
not set on the INSERT.
- OUT: Only sets the ID on the passed session and returns it. (`CreatedAt`, `AccessedAt`, are not set.)

New version:

```go
func (ds *Datastore) NewSession(ctx context.Context, userID uint, sessionKey string) (*fleet.Session, error) {
	sqlStatement := `
		INSERT INTO sessions (
			user_id,
			` + "`key`" + `
		)
		VALUES(?,?)
	`
	result, err := ds.writer.ExecContext(ctx, sqlStatement, userID, sessionKey)
	if err != nil {
		return nil, ctxerr.Wrap(ctx, err, "inserting session")
	}

	id, _ := result.LastInsertId() // cannot fail with the mysql driver
	return ds.sessionByID(ctx, ds.writer, uint(id))
}
```

- IN: Define arguments that are truly used when creating a session.
- OUT: Load and return the fleet.Session struct with all values set (using the `ds.writer` to support read replicas correctly).

PS: The new `NewSession` version mimics what we already do with other entities, like policies (`Datastore.NewGlobalPolicy`).
2022-04-04 16:52:05 -07:00
..
authz Refactor authz skip for device auth, add org_logo_url for frontend (#4619) 2022-03-16 10:15:25 -04:00
bindata Allow users to be readded if they were ever removed (#1945) 2021-09-07 13:33:40 -03:00
config Add team failing policies webhook (#4633) 2022-03-21 13:16:47 -06:00
contexts Add public ip to hosts & derive geolocation when rendering host (#4652) 2022-03-21 12:29:52 -04:00
datastore Add read replica testing helpers and fix non-sso login bug (#4908) 2022-04-04 16:52:05 -07:00
errorstore Migrate team-related endpoints to new pattern (#3740) 2022-01-19 10:52:14 -05:00
fleet Add read replica testing helpers and fix non-sso login bug (#4908) 2022-04-04 16:52:05 -07:00
health Fix documentation typos (#1682) 2017-12-21 18:37:32 -08:00
launcher Upgrade osquery-go (#4728) 2022-03-23 12:15:37 -03:00
live_query Migrate team-related endpoints to new pattern (#3740) 2022-01-19 10:52:14 -05:00
logging make context type value header configurable (#4441) 2022-03-09 17:22:29 -05:00
mail update copyright year in core product transactional email templates (#3549) 2022-01-01 12:41:32 -06:00
mock Add read replica testing helpers and fix non-sso login bug (#4908) 2022-04-04 16:52:05 -07:00
ptr Add CentOS parsing+post-processing to reduce false positives in vulnerability processing (#4037) 2022-02-14 15:13:44 -03:00
pubsub Migrate team-related endpoints to new pattern (#3740) 2022-01-19 10:52:14 -05:00
service Add read replica testing helpers and fix non-sso login bug (#4908) 2022-04-04 16:52:05 -07:00
sso Merge pull request from GHSA-ch68-7cf4-35vr 2022-02-02 15:50:09 -08:00
test Add hosts_count field to "list software" endpoint (#3873) 2022-01-26 09:47:56 -05:00
vulnerabilities Fix update invite email conflict (#4751) 2022-03-28 09:38:57 -06:00
webhooks fix failing policies nil pointer dereference (#4802) 2022-03-24 15:56:56 -06:00
websocket Use new error handling approach in other packages (#2954) 2021-11-22 09:13:26 -05:00
utils.go Modify /server/utils to handle all 2xx codes as POST success (#3534) 2021-12-30 16:00:10 -06:00