Conversation
…ver segment identifies
|
My only concern is the top step in the pipeline, the Starting from the bottom highlighted payload: {
"anonymousId": "f9275b47-dbb6-4bba-b3f8-db5f871dbefc",
"category": null,
"context": {
"page": {
"path": "/login",
"referrer": "http://huboard.rails/",
"search": "",
"title": "Huboard",
"url": "http://huboard.rails/login"
},
"userAgent": "blahblahblah",
"library": {
"name": "analytics.js",
"version": "2.11.1"
},
"ip": "68.146.230.217"
},
"integrations": {},
"messageId": "ajs-bf209c1cc0373d8215d9fcc459a4fb23",
"name": null,
"properties": {
"anonymousId": "5bc579b368d3ec787c1355a561d533ac",
"path": "/login",
"referrer": "http://huboard.rails/",
"search": "",
"title": "Huboard",
"url": "http://huboard.rails/login"
},
"receivedAt": "2016-03-28T18:33:58.514Z",
"sentAt": "2016-03-28T18:33:58.487Z",
"timestamp": "2016-03-28T18:33:58.513Z",
"type": "page",
"userId": "1130665",
"originalTimestamp": "2016-03-28T18:33:58.486Z"
}{
"userId": "Anonymous",
"anonymousId": "5bc579b368d3ec787c1355a561d533ac",
"name": "/login/private",
"category": null,
"properties": {
"url": "/login/private"
},
"integrations": {},
"context": {
"library": {
"name": "analytics-ruby",
"version": "2.0.13"
}
},
"timestamp": "2016-03-28T18:33:59.818Z",
"type": "page",
"messageId": "b30b5b83-5820-4012-8d75-c54eb9f7316d",
"writeKey": "redacted",
"sentAt": "2016-03-28T18:34:34.448Z",
"receivedAt": "2016-03-28T18:34:34.851Z",
"originalTimestamp": "2016-03-28T11:33:59.415-07:00"
}{
"userId": "1130665",
"anonymousId": "9a3d0d56f08f65401416196a5dff89cc",
"name": "/login/private/authorized",
"category": null,
"properties": {
"url": "/login/private/authorized"
},
"integrations": {},
"context": {
"library": {
"name": "analytics-ruby",
"version": "2.0.13"
}
},
"timestamp": "2016-03-28T18:34:07.068Z",
"type": "page",
"messageId": "0b5af0e8-1096-4b48-8fed-5e2aa8e3cf83",
"writeKey": "redacted",
"sentAt": "2016-03-28T18:34:34.723Z",
"receivedAt": "2016-03-28T18:34:35.146Z",
"originalTimestamp": "2016-03-28T11:34:06.645-07:00"
} |
app/views/shared/_analytics.html.erb
Outdated
| <% else %> | ||
| window.analytics.page(); | ||
| window.analytics.identify({ anonymousId: '<%= session.id %>' }); | ||
| window.analytics.page({ anonymousId: '<%= session.id %>' }); |
There was a problem hiding this comment.
Should we also set anonymousId when logged_in??
|
So, oddly enough Warden sees fit to instruct rack to reset the session id after every login. I have tried getting around this using callbacks: Warden::Manager.after_set_user do |user,auth,opts|
auth.env["rack.session.options"][:renew] = false
endThat didn't work, switching |
…orced session id renewal on login
config/initializers/warden.rb
Outdated
| if opts[:store] != false && opts[:event] != :fetch | ||
| options = env[ENV_SESSION_OPTIONS] | ||
| session_serializer.store(user, scope) | ||
| end |
There was a problem hiding this comment.
For our future reference, set_user is copy/pasta from https://github.com/hassox/warden/blob/cb09b959bcac82a087ff0f2938273e6924d845d8/lib/warden/proxy.rb#L172-L176 except:
if opts[:store] != false && opts[:event] != :fetch
options = env[ENV_SESSION_OPTIONS]
- options[:renew] = true if options
session_serializer.store(user, scope)
endI know we're considering a switch to OmniAuth (#157), but I wonder if we should submit a patch to Warden along the lines of:
```diff
if opts[:store] != false && opts[:event] != :fetch
options = env[ENV_SESSION_OPTIONS]
- options[:renew] = true if options
+ options[:renew] = true if options && !opts[:renew]
session_serializer.store(user, scope)
end|
So the session reset seems to be attack mitigation technique, which we probably don't want to lose just in the name of analytics.
Two options:
The latter seems more durable in the presence of ad blockers. |
…tion attacks, sets a guid per session as anon id via rack middleware
|
@dahlbyk , I opted for option number 2 - your right, session reset was designed to prevent session fixation attacks. |
This seems to be working as expected. My only doubt now is that I appear to have seen my |
You are correct, when we upgrade auth scope this is happening:
The question is should we fix this now, or as part of our improved login flow? |
…non_id' of github.com:huboard/huboard-web into discorick/correlates_client_and_server_analytics_with_anon_id
|
While we wait for @rauhryan to refresh his memory, can you check on resetting
I would expect the session to be reset altogether ( |
|
It looks like Segment is caching the traits client-side, so even though the session is lost I don't see any inherent risk here as we are only storing publicly available GitHub data. |
It's just a correctness thing. Analytics.js does provide |
I've kicked the tires quite a bit on this...not seeing anything unexpected through various login/logout cycles starting from public and private and then upgrading or downgrading. Merging. |
|
I remember the reason for adding the explicit logout was to force an OAuth change request to add the ability to "downgrade" HuBoard's access But it sounds like GitHub has changed the default behavior of their OAuth flow |


Closes #253 #162