lynndylanhurley / lynndylanhurley/devise_token_auth
validate_token changes/encrypts cookie
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 3.6k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
## Context
When we call the `validate_token` endpoint using Cookies, it overrides the cookie which contains important information like the access token, etc. I can't tell if it is either encrypting the token (when it was not encrypted upon signing up/logging in, or not.
I have created a minimum-replication Rails app, which can be found [here](https://github.com/mdodell/devise-token-auth). I have also showcased this issue in Postman, with example endpoints to run, as well as examples of what their responses are.
The main issue is when calling [this](https://www.postman.com/winter-star-976257/workspace/devise-token-auth-cookie-issue/example/6320160-2bf98239-6e06-4274-aba9-f4259159910b) endpoint with a cookie gained from signing or logging in, the cookie is then set to a new cookie, and encrypted/scrambled.
## Template Information
* **Version**: which version of this gem (and [ng-token-auth](https://github.com/lynndylanhurley/ng-token-auth), [jToker](https://github.com/lynndylanhurley/j-toker) or [Angular2-Token](https://github.com/neroniaky/angular2-token) if applicable) are you using?
> `gem 'devise_token_auth', '>= 1.2.0', git: "https://github.com/lynndylanhurley/devise_token_auth"` - this was needed to get it working with Rails 7
* **Request and response headers**: these can be found in the "Network" tab of your browser's web inspector.
I have examples saved on [this public Postman workspace](https://www.postman.com/winter-star-976257/workspace/devise-token-auth-cookie-issue/overview).
* **Environmental Info**: How is your application different from the [reference implementation](https://github.com/lynndylanhurley/devise_token_auth_demo)? This may include (but is not limited to) the following details:
I am using Cookies, so I have done the following. Secure will be set to true in a PROD environment, but it is needed as false in order to showcase this on Postman.
```
config.change_headers_on_each_request = true
config.token_cost = Rails.env.test? ? 4 : 10
config.cookie_enabled = true
config.cookie_name = "testing-dta"
config.cookie_attributes = {
http_only: true,
secure: false,
same_site: "None"
}
```
* **Routes**: are you using some crazy namespace, scope, or constraint?
> N/A
* **Gems**: are you using MongoDB, Grape, RailsApi, ActiveAdmin, etc.?
*
> Active Admin/Postgres
* **Custom Overrides**: what have you done in terms of [custom controller overrides](https://github.com/lynndylanhurley/devise_token_auth/#custom-controller-overrides)?
> N/A
* **Custom Frontend**: are you using [ng-token-auth](https://github.com/lynndylanhurley/ng-token-auth), [jToker](https://github.com/lynndylanhurley/j-toker), [Angular2-Token](https://github.com/neroniaky/angular2-token), or something else?
> I am using this in API only mode, to be used with a React SPA later on. However, this is a backend issue.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked minimum-replication Rails app and the Postman example for the validate_token endpoint, using the cookie settings shown in the issue. Compare the cookie returned after signing up or logging in with the cookie returned by validate_token, and trace where the endpoint changes it. Done means the intended cookie contents and encryption behavior are established and the reported overwrite is either fixed or documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rails, ruby
- Domain
- api, authentication, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100