@Test public void shouldAlwaysAllowAccessForWindowsPowerShell() { underTest = new AntiCsrfHelper(true, EMPTY); when(httpServletRequest.getHeader(HttpHeaders.USER_AGENT)) .thenReturn("Mozilla/5.0 (Windows NT; Windows NT 10.0; en-CA) WindowsPowerShell/5.1.17134.590") .thenReturn("Mozilla/5.0 (Windows NT; Windows NT 10.0; en-CA) PowerShell/6.2.55342.442"); assertThat(underTest.isAccessAllowed(httpServletRequest), is(true)); assertThat(underTest.isAccessAllowed(httpServletRequest), is(true)); }
public boolean isAccessAllowed(final HttpServletRequest httpRequest) { if (!enabled) { return true; } return isSafeHttpMethod(httpRequest) || isMultiPartFormDataPost(httpRequest) || isNotBrowserRequest(httpRequest) || isAntiCsrfTokenValid(httpRequest, Optional.ofNullable(httpRequest.getHeader(ANTI_CSRF_TOKEN_NAME))); }
AntiCsrfHelper extends ComponentSupport { public boolean isAccessAllowed(final HttpServletRequest httpRequest) { if (!enabled) { return true; } return isSafeHttpMethod(httpRequest) || isMultiPartFormDataPost(httpRequest) || isNotBrowserRequest(httpRequest) || isAntiCsrfTokenValid(httpRequest, Optional.ofNullable(httpRequest.getHeader(ANTI_CSRF_TOKEN_NAME))); } }
AntiCsrfHelper extends ComponentSupport { public boolean isAccessAllowed(final HttpServletRequest httpRequest) { if (!enabled) { return true; } return isSafeHttpMethod(httpRequest) || isMultiPartFormDataPost(httpRequest) || isNotBrowserRequest(httpRequest) || isAntiCsrfTokenValid(httpRequest, Optional.ofNullable(httpRequest.getHeader(ANTI_CSRF_TOKEN_NAME))); } @Inject  AntiCsrfHelper(
      @Named("${nexus.security.anticsrftoken.enabled:-true}") final boolean enabled,
      @Named("${nexus.security.anticsrftoken.whitelist}") @Nullable final String whitelist); }
AntiCsrfHelper extends ComponentSupport { public boolean isAccessAllowed(final HttpServletRequest httpRequest) { if (!enabled) { return true; } return isSafeHttpMethod(httpRequest) || isMultiPartFormDataPost(httpRequest) || isNotBrowserRequest(httpRequest) || isAntiCsrfTokenValid(httpRequest, Optional.ofNullable(httpRequest.getHeader(ANTI_CSRF_TOKEN_NAME))); } @Inject  AntiCsrfHelper(
      @Named("${nexus.security.anticsrftoken.enabled:-true}") final boolean enabled,
      @Named("${nexus.security.anticsrftoken.whitelist}") @Nullable final String whitelist); boolean isAccessAllowed(final HttpServletRequest httpRequest); void requireValidToken(final HttpServletRequest httpRequest, @Nullable final String token); boolean isEnabled(); }
AntiCsrfHelper extends ComponentSupport { public boolean isAccessAllowed(final HttpServletRequest httpRequest) { if (!enabled) { return true; } return isSafeHttpMethod(httpRequest) || isMultiPartFormDataPost(httpRequest) || isNotBrowserRequest(httpRequest) || isAntiCsrfTokenValid(httpRequest, Optional.ofNullable(httpRequest.getHeader(ANTI_CSRF_TOKEN_NAME))); } @Inject  AntiCsrfHelper(
      @Named("${nexus.security.anticsrftoken.enabled:-true}") final boolean enabled,
      @Named("${nexus.security.anticsrftoken.whitelist}") @Nullable final String whitelist); boolean isAccessAllowed(final HttpServletRequest httpRequest); void requireValidToken(final HttpServletRequest httpRequest, @Nullable final String token); boolean isEnabled(); static final String ENABLED; static final String ERROR_MESSAGE_TOKEN_MISMATCH; static final String ANTI_CSRF_TOKEN_NAME; }