Skip to content

Commit 3de67bf

Browse files
committed
Disabling existing access tokens added
When DISABLE_ACCESS_TOKENS=true, existing access tokens should be disabled. Fixes: 2bde83b Related: #18488 (review) Author-Change-Id: IB#1115254
1 parent 7a5e483 commit 3de67bf

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

models/token.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ func GetAccessTokenBySHA(token string) (*AccessToken, error) {
9494
if token == "" {
9595
return nil, ErrAccessTokenEmpty{}
9696
}
97+
98+
// Existing tokens are invalid if access tokens feature is disabled.
99+
if setting.DisableAccessTokens {
100+
return nil, ErrAccessTokenNotExist{token}
101+
}
102+
97103
// A token is defined as being SHA1 sum these are 40 hexadecimal bytes long
98104
if len(token) != 40 {
99105
return nil, ErrAccessTokenNotExist{token}

0 commit comments

Comments
 (0)