Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to obtain expiration time of refresh tokens #801

Open
3 of 5 tasks
mitar opened this issue Mar 8, 2024 · 1 comment
Open
3 of 5 tasks

Unable to obtain expiration time of refresh tokens #801

mitar opened this issue Mar 8, 2024 · 1 comment
Labels
feat New feature or request.

Comments

@mitar
Copy link
Contributor

mitar commented Mar 8, 2024

Preflight checklist

Ory Network Project

No response

Describe your problem

There seems to be no way to obtain expiration time of refresh tokens. Refresh tokens are opaque (and not JWT) and introspection endpoint returns the associated access token claims and not refresh tokens claims.

Describe your ideal solution

I think introspection endpoint should return refresh token claims for the refresh token, not the access token claims. Ping identity does so and returns:

    {
      "active": true
      "exp": 1556823764
    }

    Note: If the refresh token is configured to never expire, the "exp" attribute will not be returned.

Workarounds or alternatives

None I could find.

Version

latest master

Additional Context

No response

@mitar mitar added the feat New feature or request. label Mar 8, 2024
@mitar
Copy link
Contributor Author

mitar commented Mar 9, 2024

I added to my introspect endpoint handler:

	if ir.GetTokenUse() == "refresh_token" {
		w.Header().Set("Content-Type", "application/json;charset=UTF-8")
		w.Header().Set("Cache-Control", "no-store")
		w.Header().Set("Pragma", "no-cache")

		if !ir.IsActive() {
			_ = json.NewEncoder(w).Encode(&struct {
				Active bool `json:"active"`
			}{Active: false})
			return
		}

		response := map[string]interface{}{
			"active": true,
		}

		if !ir.GetAccessRequester().GetSession().GetExpiresAt(fosite.RefreshToken).IsZero() {
			response["exp"] = ir.GetAccessRequester().GetSession().GetExpiresAt(fosite.RefreshToken).Unix()
		}

		_ = json.NewEncoder(w).Encode(response)
		return
	}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat New feature or request.
Projects
None yet
Development

No branches or pull requests

1 participant