Skip to content
GitLab Next
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • GitLab GitLab
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 44,218
    • Issues 44,218
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 1,592
    • Merge requests 1,592
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GitLab.orgGitLab.org
  • GitLabGitLab
  • Issues
  • #21745
Closed
Open
Created Apr 04, 2018 by Aric Buerer@abuerer1Contributor

OAuth access token does not have an expiration

Summary

OAuth access tokens do not have an expiry.

Steps to reproduce

Create token according to GitLab as an OAuth Provider

curl -X POST -H "Content-Type: application/json" --data '{"grant_type":"password","username":"<username>","password":"<password>"}' https://gitlab.example.com/oauth/token

What is the current bug behavior?

According to the documentation, expires_in should be returned. However, when looking at the token info expires_in_seconds is set to null.

What is the expected correct behavior?

Should return expire_in value.

Relevant logs and/or screenshots

Token creation:

curl -k -X POST -H "Content-Type: application/json" --data "{\"grant_type\":\"password\",\"username\":\"<username>\",\"password\":\"<password>\"}" https://gitlab.example.com/oauth/token
{"access_token":"<access-token>","token_type":"bearer","refresh_token":"<refresh-token>","scope":"api","created_at":1522861703}

Token info:

curl -H "Authorization: Bearer <access-token>" \
     https://gitlab.example.com/oauth/token/info
{"resource_owner_id":1,"scopes":["api"],"expires_in_seconds":null,"application":{"uid":null},"created_at":1522861703}

Links

Customer ticket -> https://gitlab.zendesk.com/agent/tickets/93990 (internal)

Release Post MR --> gitlab-com/www-gitlab-com!89791 (merged)

Proposed Solution

  1. Add new checkbox to the OAuth application form "Expire Access Token" (therefore this config exists on a per-application basis)
  2. For any new application, this checkbox is enabled by default
  3. When checkbox is enabled, expire access tokens in 2 hours
  4. Update docs to recommend integrations refresh tokens at some interval (can we decide on the interval up front so integrations can build accordingly?)
Edited Sep 09, 2021 by Hannah Sutor
Assignee
Assign to
Time tracking