mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 08:55:44 +01:00
create a more flexible interface for the creation of access tokens
Provide a AccessTokenBuilderFactory to simplify the creation of access tokens and a default implementation which is based on JWT. Added also an AccessTokenCookieIssuer to unify the creation of access token cookies. Removed old BearerTokenGenerator.
This commit is contained in:
@@ -33,7 +33,6 @@ package sonia.scm.web;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import sonia.scm.plugin.Extension;
|
||||
import sonia.scm.security.BearerAuthenticationToken;
|
||||
|
||||
@@ -41,6 +40,7 @@ import sonia.scm.security.BearerAuthenticationToken;
|
||||
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import sonia.scm.util.HttpUtil;
|
||||
|
||||
/**
|
||||
* Creates an {@link BearerAuthenticationToken} from the {@link #COOKIE_NAME}
|
||||
@@ -53,12 +53,6 @@ import javax.servlet.http.HttpServletRequest;
|
||||
public class CookieBearerWebTokenGenerator implements WebTokenGenerator
|
||||
{
|
||||
|
||||
/** cookie name */
|
||||
@VisibleForTesting
|
||||
static final String COOKIE_NAME = "X-Bearer-Token";
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Creates an {@link BearerAuthenticationToken} from the {@link #COOKIE_NAME}
|
||||
* cookie.
|
||||
@@ -77,7 +71,7 @@ public class CookieBearerWebTokenGenerator implements WebTokenGenerator
|
||||
{
|
||||
for (Cookie cookie : cookies)
|
||||
{
|
||||
if (COOKIE_NAME.equals(cookie.getName()))
|
||||
if (HttpUtil.COOKIE_BEARER_AUTHENTICATION.equals(cookie.getName()))
|
||||
{
|
||||
token = new BearerAuthenticationToken(cookie.getValue());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user