Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
e5a28a57
Commit
e5a28a57
authored
Feb 20, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
df972386
094d7408
Changes
8
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
84 additions
and
200 deletions
+84
-200
app/models/personal_access_token.rb
app/models/personal_access_token.rb
+4
-1
changelogs/unreleased/53411-remove_personal_access_tokens_token.yml
.../unreleased/53411-remove_personal_access_tokens_token.yml
+5
-0
db/post_migrate/20181101091005_steal_digest_column.rb
db/post_migrate/20181101091005_steal_digest_column.rb
+17
-0
db/post_migrate/20181101091124_remove_token_from_personal_access_tokens.rb
...0181101091124_remove_token_from_personal_access_tokens.rb
+11
-0
db/schema.rb
db/schema.rb
+0
-2
spec/factories/personal_access_tokens.rb
spec/factories/personal_access_tokens.rb
+3
-2
spec/lib/gitlab/background_migration/digest_column_spec.rb
spec/lib/gitlab/background_migration/digest_column_spec.rb
+2
-2
spec/models/concerns/token_authenticatable_spec.rb
spec/models/concerns/token_authenticatable_spec.rb
+42
-193
No files found.
app/models/personal_access_token.rb
View file @
e5a28a57
...
...
@@ -2,8 +2,11 @@
class
PersonalAccessToken
<
ActiveRecord
::
Base
include
Expirable
include
IgnorableColumn
include
TokenAuthenticatable
add_authentication_token_field
:token
,
digest:
true
,
fallback:
true
add_authentication_token_field
:token
,
digest:
true
ignore_column
:token
REDIS_EXPIRY_TIME
=
3
.
minutes
...
...
changelogs/unreleased/53411-remove_personal_access_tokens_token.yml
0 → 100644
View file @
e5a28a57
---
title
:
Remove undigested token column from personal_access_tokens table from the database
merge_request
:
22743
author
:
type
:
changed
db/post_migrate/20181101091005_steal_digest_column.rb
0 → 100644
View file @
e5a28a57
# frozen_string_literal: true
class
StealDigestColumn
<
ActiveRecord
::
Migration
[
5.0
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
def
up
Gitlab
::
BackgroundMigration
.
steal
(
'DigestColumn'
)
end
def
down
# raise ActiveRecord::IrreversibleMigration
end
end
db/post_migrate/20181101091124_remove_token_from_personal_access_tokens.rb
0 → 100644
View file @
e5a28a57
# frozen_string_literal: true
class
RemoveTokenFromPersonalAccessTokens
<
ActiveRecord
::
Migration
[
5.0
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
def
change
remove_column
:personal_access_tokens
,
:token
,
:string
end
end
db/schema.rb
View file @
e5a28a57
...
...
@@ -2133,7 +2133,6 @@ ActiveRecord::Schema.define(version: 20190204115450) do
create_table
"personal_access_tokens"
,
force: :cascade
do
|
t
|
t
.
integer
"user_id"
,
null:
false
t
.
string
"token"
t
.
string
"name"
,
null:
false
t
.
boolean
"revoked"
,
default:
false
t
.
date
"expires_at"
...
...
@@ -2142,7 +2141,6 @@ ActiveRecord::Schema.define(version: 20190204115450) do
t
.
string
"scopes"
,
default:
"--- []
\n
"
,
null:
false
t
.
boolean
"impersonation"
,
default:
false
,
null:
false
t
.
string
"token_digest"
t
.
index
[
"token"
],
name:
"index_personal_access_tokens_on_token"
,
unique:
true
,
using: :btree
t
.
index
[
"token_digest"
],
name:
"index_personal_access_tokens_on_token_digest"
,
unique:
true
,
using: :btree
t
.
index
[
"user_id"
],
name:
"index_personal_access_tokens_on_user_id"
,
using: :btree
end
...
...
spec/factories/personal_access_tokens.rb
View file @
e5a28a57
FactoryBot
.
define
do
factory
:personal_access_token
do
user
token
{
SecureRandom
.
hex
(
50
)
}
sequence
(
:name
)
{
|
n
|
"PAT
#{
n
}
"
}
revoked
false
expires_at
{
5
.
days
.
from_now
}
scopes
[
'api'
]
impersonation
false
after
(
:build
)
{
|
personal_access_token
|
personal_access_token
.
ensure_token
}
trait
:impersonation
do
impersonation
true
end
...
...
@@ -21,7 +22,7 @@ FactoryBot.define do
end
trait
:invalid
do
token
nil
token
_digest
nil
end
end
end
spec/lib/gitlab/background_migration/digest_column_spec.rb
View file @
e5a28a57
...
...
@@ -22,7 +22,7 @@ describe Gitlab::BackgroundMigration::DigestColumn, :migration, schema: 20180913
it
'erases token'
do
expect
{
subject
.
perform
(
PersonalAccessToken
,
:token
,
:token_digest
,
1
,
2
)
}.
to
(
change
{
PersonalAccessToken
.
find
(
1
).
token
}.
from
(
'token-01'
).
to
(
nil
))
change
{
PersonalAccessToken
.
find
(
1
).
read_attribute
(
:token
)
}.
from
(
'token-01'
).
to
(
nil
))
end
end
...
...
@@ -39,7 +39,7 @@ describe Gitlab::BackgroundMigration::DigestColumn, :migration, schema: 20180913
it
'leaves token empty'
do
expect
{
subject
.
perform
(
PersonalAccessToken
,
:token
,
:token_digest
,
1
,
2
)
}.
not_to
(
change
{
PersonalAccessToken
.
find
(
1
).
token
}.
from
(
nil
))
change
{
PersonalAccessToken
.
find
(
1
).
read_attribute
(
:token
)
}.
from
(
nil
))
end
end
end
...
...
spec/models/concerns/token_authenticatable_spec.rb
View file @
e5a28a57
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment