<p>So that turns out to be quite a complicated question ;-)</p>
<p>So firstly <code>current_token</code> will be set whenever the rack filter saw a request with a valid OAuth signature, but it might only be a request token that hasn't been authorised yet - that could be checked with <code>.is_a?(AccessToken)</code> if we wanted.</p>
<p>Secondly if it is an access token and <code>setup_user_auth</code> has been run then <code>current_user</code> will be set to the token's user by the <code>Authenticator.new(self, [:token]).allow?</code> call - strictly that would probably be the best way to validate the token before using to check capabilities but it is a bit nasty in that it wants a controller and will try and send a response if the token is invalid so we probably can't/don't want to use that.</p>
<p>So in principle there is no security issue so long as we check the token is an access token but on the other hand if <code>setup_user_auth</code> hasn't been called then <code>current_user</code> won't be set and although things might be allowed they might not actually work ;-)</p>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/commit/71b21ec47371c7210dfcb234f7bfa0adf00efad1#commitcomment-31026007">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABWnLVNYbLzSupVd5DoMyzW2MigpC1uzks5uoFYHgaJpZM4X3mIu">mute the thread</a>.<img src="https://github.com/notifications/beacon/ABWnLdB0CGhaKfVZ6U_b-pA-PpW0piN4ks5uoFYHgaJpZM4X3mIu.gif" height="1" width="1" alt="" /></p>
<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/openstreetmap/openstreetmap-website","title":"openstreetmap/openstreetmap-website","subtitle":"GitHub repository","main_image_url":"https://assets-cdn.github.com/images/email/message_cards/header.png","avatar_image_url":"https://assets-cdn.github.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/openstreetmap/openstreetmap-website"}},"updates":{"snippets":[{"icon":"PERSON","message":"@tomhughes on 71b21ec: So that turns out to be quite a complicated question ;-)\r\n\r\nSo firstly `current_token` will be set whenever the rack filter saw a request with a valid OAuth signature, but it might only be a request token that hasn't been authorised yet - that could be checked with `.is_a?(AccessToken)` if we wanted.\r\n\r\nSecondly if it is an access token and `setup_user_auth` has been run then `current_user` will be set to the token's user by the `Authenticator.new(self, [:token]).allow?` call - strictly that would probably be the best way to validate the token before using to check capabilities but it is a bit nasty in that it wants a controller and will try and send a response if the token is invalid so we probably can't/don't want to use that.\r\n\r\nSo in principle there is no security issue so long as we check the token is an access token but on the other hand if `setup_user_auth` hasn't been called then `current_user` won't be set and although things might be allowed they might not actually work ;-)"}],"action":{"name":"View Commit","url":"https://github.com/openstreetmap/openstreetmap-website/commit/71b21ec47371c7210dfcb234f7bfa0adf00efad1#commitcomment-31026007"}}}</script>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/commit/71b21ec47371c7210dfcb234f7bfa0adf00efad1#commitcomment-31026007",
"url": "https://github.com/openstreetmap/openstreetmap-website/commit/71b21ec47371c7210dfcb234f7bfa0adf00efad1#commitcomment-31026007",
"name": "View Commit"
},
"description": "View this Commit on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>