Skip to lesson

Validating the token on each request

Issuing tokens is only half the job: the API must check the token on every request without asking the database who is calling. Spring Security does that with a few lines of configuration.

oauth2ResourceServer(jwt) and BearerTokenAuthenticationFilter

A resource server is an API that accepts access tokens. On every request it reads the token from the Authorization: Bearer header, checks the signature and the expiry, and turns the claims into a signed-in user.

The last lesson issued tokens, but the API still asked for HTTP Basic, so clients kept the password anyway. The SecurityConfig below switches the API to bearer tokens.

Example 1 · src/main/java/com/shoplite/common/security/SecurityConfig.java

Runs in: the shoplite-api Spring Boot project

SecurityConfig.javaJava
package com.shoplite.common.security;
import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;import org.springframework.http.HttpMethod;import org.springframework.security.authentication.AuthenticationManager;import org.springframework.security.authentication.ProviderManager;import org.springframework.security.authentication.dao.DaoAuthenticationProvider;import org.springframework.security.config.annotation.web.builders.HttpSecurity;import org.springframework.security.config.http.SessionCreationPolicy;import org.springframework.security.core.userdetails.UserDetailsService;import org.springframework.security.crypto.factory.PasswordEncoderFactories;import org.springframework.security.crypto.password.PasswordEncoder;import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationConverter;import org.springframework.security.oauth2.server.resource.authentication.JwtGrantedAuthoritiesConverter;import org.springframework.security.web.SecurityFilterChain;
/** * Every security rule of ShopLite lives in this one class. * Rules are checked from top to bottom; the first rule that matches a request decides. */@Configurationpublic class SecurityConfig {
    /** springdoc's JSON and Swagger UI pages (switched off in the prod profile). */    private static final String[] API_DOCS = { "/v3/api-docs/**", "/swagger-ui/**", "/swagger-ui.html" };
    @Bean    SecurityFilterChain securityFilterChain(HttpSecurity http, SecurityProblems problems) throws Exception {        http            .authorizeHttpRequests(auth -> auth                .requestMatchers(HttpMethod.GET, "/api/v1/products/**", "/api/v1/categories/**").permitAll()                .requestMatchers(HttpMethod.POST, "/api/v1/auth/register", "/api/v1/auth/login").permitAll()                .requestMatchers(HttpMethod.GET, "/api").permitAll()                .requestMatchers("/actuator/health/**").permitAll()                .requestMatchers(API_DOCS).permitAll()                // Spring Boot forwards errors to /error; it must stay open or real errors turn into 401                .requestMatchers("/error").permitAll()                // Reading any customer by id is for staff only (customers use /api/v1/me)                .requestMatchers("/api/v1/customers/**").hasRole("ADMIN")                .anyRequest().authenticated())            .oauth2ResourceServer(oauth -> oauth                .jwt(jwt -> jwt.jwtAuthenticationConverter(rolesFromToken()))                .authenticationEntryPoint(problems.unauthorized())                .accessDeniedHandler(problems.forbidden()))            .exceptionHandling(errors -> errors                .authenticationEntryPoint(problems.unauthorized())                .accessDeniedHandler(problems.forbidden()))            // CSRF is off: the token travels in a header, never in a cookie            .csrf(csrf -> csrf.disable())            .sessionManagement(session -> session                .sessionCreationPolicy(SessionCreationPolicy.STATELESS));        return http.build();    }
    /** The token's "roles" claim (["CUSTOMER"]) becomes the authorities ROLE_CUSTOMER, ... */    private static JwtAuthenticationConverter rolesFromToken() {        JwtGrantedAuthoritiesConverter roles = new JwtGrantedAuthoritiesConverter();        roles.setAuthoritiesClaimName("roles");        roles.setAuthorityPrefix("ROLE_");        JwtAuthenticationConverter converter = new JwtAuthenticationConverter();        converter.setJwtGrantedAuthoritiesConverter(roles);        return converter;    }
    /**     * Checks an e-mail and password for the login endpoint: loads the user through the     * UserDetailsService and compares the password with the PasswordEncoder.     */    @Bean    AuthenticationManager authenticationManager(UserDetailsService users, PasswordEncoder passwordEncoder) {        DaoAuthenticationProvider provider = new DaoAuthenticationProvider(users);        provider.setPasswordEncoder(passwordEncoder);        return new ProviderManager(provider);    }
    /**     * Hashes new passwords with BCrypt and stores them as "{bcrypt}$2a$10$...".     * The {id} prefix lets ShopLite move to a stronger algorithm later without breaking old hashes.     */    @Bean    PasswordEncoder passwordEncoder() {        return PasswordEncoderFactories.createDelegatingPasswordEncoder();    }}
Sample output
Startup log with logging.level.org.springframework.security=DEBUG:
... DEBUG ... o.s.s.web.DefaultSecurityFilterChain     : Will secure any request with filters: DisableEncodeUrlFilter, WebAsyncManagerIntegrationFilter, SecurityContextHolderFilter, HeaderWriterFilter, LogoutFilter, OAuth2ProtectedResourceMetadataFilter, BearerTokenAuthenticationFilter, RequestCacheAwareFilter, SecurityContextHolderAwareRequestFilter, AnonymousAuthenticationFilter, SessionManagementFilter, ExceptionTranslationFilter, AuthorizationFilter

What this code does

  • oauth2ResourceServer(...jwt(...)) replaces httpBasic: BearerTokenAuthenticationFilter is in the chain, BasicAuthenticationFilter is gone.
  • The entry point and access-denied handler are set twice on purpose: on the resource server for token failures, and in exceptionHandling for requests with no token at all.
  • Rules still run top to bottom: the public endpoints, then /api/v1/customers/** for ADMIN, then everything else needs any valid token.

Example 2 · src/main/java/com/shoplite/common/security/SecurityProblems.java

Runs in: the shoplite-api Spring Boot project

SecurityProblems.javaJava
package com.shoplite.common.security;
import java.io.IOException;import java.util.LinkedHashMap;import java.util.Map;
import org.springframework.http.MediaType;import org.springframework.http.ProblemDetail;import org.springframework.security.oauth2.core.OAuth2AuthenticationException;import org.springframework.security.oauth2.server.resource.web.BearerTokenAuthenticationEntryPoint;import org.springframework.security.oauth2.server.resource.web.access.BearerTokenAccessDeniedHandler;import org.springframework.security.web.AuthenticationEntryPoint;import org.springframework.security.web.access.AccessDeniedHandler;import org.springframework.stereotype.Component;
import com.shoplite.common.ProblemKind;
import jakarta.servlet.http.HttpServletRequest;import jakarta.servlet.http.HttpServletResponse;import tools.jackson.databind.json.JsonMapper;
/** * 401 and 403 answered by the security filters, before any controller runs. @RestControllerAdvice * never sees them, so this class writes the same problem JSON as the global handler. */@Componentpublic class SecurityProblems {
    private final BearerTokenAuthenticationEntryPoint bearerEntryPoint = new BearerTokenAuthenticationEntryPoint();    private final BearerTokenAccessDeniedHandler bearerDeniedHandler = new BearerTokenAccessDeniedHandler();    private final JsonMapper json;
    SecurityProblems(JsonMapper json) {        this.json = json;    }
    /** No token, or a token that failed the checks (bad signature, expired, wrong issuer). */    AuthenticationEntryPoint unauthorized() {        return (request, response, exception) -> {            bearerEntryPoint.commence(request, response, exception);   // status 401 + WWW-Authenticate: Bearer ...            String detail = exception instanceof OAuth2AuthenticationException                    ? "The access token is invalid or has expired. Sign in again."                    : "Sign in to use this endpoint.";            write(request, response, ProblemKind.UNAUTHORIZED.problem(detail));        };    }
    /** A valid token, but its roles do not allow this request. */    AccessDeniedHandler forbidden() {        return (request, response, exception) -> {            bearerDeniedHandler.handle(request, response, exception);  // status 403 + WWW-Authenticate            write(request, response, ProblemKind.FORBIDDEN.problem("You do not have permission to do this."));        };    }
    private void write(HttpServletRequest request, HttpServletResponse response, ProblemDetail problem)            throws IOException {        Map<String, Object> body = new LinkedHashMap<>();        body.put("type", problem.getType().toString());        body.put("title", problem.getTitle());        body.put("status", problem.getStatus());        body.put("detail", problem.getDetail());        body.put("instance", request.getRequestURI());        response.setContentType(MediaType.APPLICATION_PROBLEM_JSON_VALUE);        response.getOutputStream().write(json.writeValueAsBytes(body));    }}
Note
Used by SecurityConfig; the 401 and 403 bodies it writes are in Examples 3, 4 and 5.

What this code does

  • BearerTokenAuthenticationEntryPoint.commence sets status 401 and the WWW-Authenticate: Bearer ... header; then the class adds the problem body.
  • An OAuth2AuthenticationException means a token was sent but failed the checks; anything else means no token was sent. The detail sentence differs, the type stays unauthorized.
  • The body is built in the contract's field order (type, title, status, detail, instance) with Boot's Jackson 3 JsonMapper.

Example 3 · src/main/java/com/shoplite/user/MeController.java, called with and without a token

Runs in: the shoplite-api Spring Boot project

Java
package com.shoplite.user;
import org.springframework.security.core.annotation.AuthenticationPrincipal;import org.springframework.security.oauth2.jwt.Jwt;import org.springframework.web.bind.annotation.GetMapping;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RestController;
/** The signed-in user's own data. The id comes from the token, never from the URL. */@RestController@RequestMapping("/api/v1/me")class MeController {
    private final UserService userService;
    MeController(UserService userService) {        this.userService = userService;    }
    @GetMapping    UserResponse me(@AuthenticationPrincipal Jwt jwt) {        return userService.me(Integer.valueOf(jwt.getSubject()));    }}
/* Terminal:TOKEN=$(curl -s -X POST localhost:8080/api/v1/auth/login -H "Content-Type: application/json" \        -d '{"email":"asha.rao@example.com","password":"asha-dev-password"}' | jq -r .accessToken)
curl -i localhost:8080/api/v1/me -H "Authorization: Bearer $TOKEN"curl -i localhost:8080/api/v1/mecurl -i -u asha.rao@example.com:asha-dev-password localhost:8080/api/v1/me*/
Sample output
HTTP/1.1 200
Content-Type: application/json

{"id":2,"email":"asha.rao@example.com","fullName":"Asha Rao","customerId":1,"roles":["CUSTOMER"]}

HTTP/1.1 401
WWW-Authenticate: Bearer resource_metadata="http://localhost:8080/.well-known/oauth-protected-resource"
Content-Type: application/problem+json

{"type":"https://shoplite.example/problems/unauthorized","title":"Unauthorized","status":401,"detail":"Sign in to use this endpoint.","instance":"/api/v1/me"}

HTTP/1.1 401
WWW-Authenticate: Bearer resource_metadata="http://localhost:8080/.well-known/oauth-protected-resource"
Content-Type: application/problem+json

{"type":"https://shoplite.example/problems/unauthorized","title":"Unauthorized","status":401,"detail":"Sign in to use this endpoint.","instance":"/api/v1/me"}

What this code does

  • @AuthenticationPrincipal Jwt jwt gives the checked token; jwt.getSubject() is the user id "2" that TokenService wrote. The client never sends its own id.
  • No token: 401 with the plain Bearer challenge and "Sign in to use this endpoint."
  • The e-mail and password with -u no longer work: HTTP Basic is switched off, and the API answers as if nothing was sent.

oauth2ResourceServer(oauth -> oauth.jwt(...)) adds the BearerTokenAuthenticationFilter. For each request it looks for Authorization: Bearer <token>, asks the JwtDecoder bean to check the token, and on success puts a JwtAuthenticationToken into the SecurityContext. A request with no token passes through as anonymous, and AuthorizationFilter then decides as usual. Now that httpBasic is gone from SecurityConfig, a -u email:password request gets 401 like any request without a token.

Errors in the filters never reach @RestControllerAdvice, because no controller runs. SecurityProblems gives the chain an AuthenticationEntryPoint (401) and an AccessDeniedHandler (403) that first let Spring's bearer versions set the WWW-Authenticate header, then write the same problem JSON as the rest of the API.

Spring Security 7 also adds OAuth2ProtectedResourceMetadataFilter: it serves /.well-known/oauth-protected-resource and the resource_metadata part of the WWW-Authenticate header, so OAuth clients can discover how to get a token.

The JwtDecoder bean: same key, fixed algorithm

JwtDecoder is the Spring Security interface that checks a token and returns a Jwt with its claims, or throws a JwtException.

The decoder must trust only tokens signed with ShopLite's own key. The JwtConfig below builds one from the same key as the encoder, with the algorithm fixed.

Example 4 · src/main/java/com/shoplite/auth/JwtConfig.java

Runs in: the shoplite-api Spring Boot project

Java
package com.shoplite.auth;
import javax.crypto.SecretKey;
import org.springframework.boot.context.properties.EnableConfigurationProperties;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;import org.springframework.security.oauth2.core.DelegatingOAuth2TokenValidator;import org.springframework.security.oauth2.core.OAuth2TokenValidator;import org.springframework.security.oauth2.jose.jws.MacAlgorithm;import org.springframework.security.oauth2.jwt.Jwt;import org.springframework.security.oauth2.jwt.JwtDecoder;import org.springframework.security.oauth2.jwt.JwtEncoder;import org.springframework.security.oauth2.jwt.JwtIssuerValidator;import org.springframework.security.oauth2.jwt.JwtTimestampValidator;import org.springframework.security.oauth2.jwt.NimbusJwtDecoder;import org.springframework.security.oauth2.jwt.NimbusJwtEncoder;
/** The two halves of the token system: the encoder signs at login, the decoder checks every request. */@Configuration@EnableConfigurationProperties(JwtProperties.class)class JwtConfig {
    @Bean    JwtEncoder jwtEncoder(JwtProperties properties) {        return NimbusJwtEncoder.withSecretKey(properties.signingKey())                .algorithm(MacAlgorithm.HS256)                .build();    }
    @Bean    JwtDecoder jwtDecoder(JwtProperties properties) {        SecretKey key = properties.signingKey();        NimbusJwtDecoder decoder = NimbusJwtDecoder.withSecretKey(key)                .macAlgorithm(MacAlgorithm.HS256)          // the only algorithm we accept; "none" never passes                .build();        OAuth2TokenValidator<Jwt> rules = new DelegatingOAuth2TokenValidator<>(                new JwtTimestampValidator(properties.clockSkew()),   // exp (and nbf), with a small allowance                new JwtIssuerValidator(properties.issuer()));        // iss must be our own API        decoder.setJwtValidator(rules);        return decoder;    }}
Sample output
# Asha's token with the payload edited to "roles":["ADMIN"] (old signature kept)
$ curl -i http://localhost:8080/api/v1/me -H "Authorization: Bearer eyJraWQiOi...ROLES-EDITED...F-prM"
HTTP/1.1 401
WWW-Authenticate: Bearer error="invalid_token", error_description="An error occurred while attempting to decode the Jwt: Signed JWT rejected: Invalid signature", error_uri="https://tools.ietf.org/html/rfc6750#section-3.1", resource_metadata="http://localhost:8080/.well-known/oauth-protected-resource"
Content-Type: application/problem+json

{"type":"https://shoplite.example/problems/unauthorized","title":"Unauthorized","status":401,"detail":"The access token is invalid or has expired. Sign in again.","instance":"/api/v1/me"}

# An unsigned token: header {"alg":"none"}, payload with "roles":["ADMIN"], empty signature
$ curl -i http://localhost:8080/api/v1/customers/1 -H "Authorization: Bearer eyJhbGciOiJub25lIn0.eyJpc3MiOiJzaG9wbGl0ZS1hcGkiLCJzdWIiOiIxIiwiZXhwIjoxODkyMTM4Mzg5LCJyb2xlcyI6WyJBRE1JTiJdfQ."
HTTP/1.1 401
WWW-Authenticate: Bearer error="invalid_token", error_description="Unsupported algorithm of none", error_uri="https://tools.ietf.org/html/rfc6750#section-3.1", resource_metadata="http://localhost:8080/.well-known/oauth-protected-resource"
Content-Type: application/problem+json

{"type":"https://shoplite.example/problems/unauthorized","title":"Unauthorized","status":401,"detail":"The access token is invalid or has expired. Sign in again.","instance":"/api/v1/customers/1"}

What this code does

  • The encoder and the decoder share properties.signingKey(): tokens made at login pass, tokens signed with anything else fail.
  • Changing one claim breaks the signature: "Signed JWT rejected: Invalid signature".
  • The alg: none token is stopped by the fixed algorithm, "Unsupported algorithm of none", before its ADMIN role is ever read.

NimbusJwtDecoder is built with macAlgorithm(MacAlgorithm.HS256). That one call is the defence from the JWT structure lesson: the server decides the algorithm, so a token that says none, HS512 or RS256 is rejected before any claim is trusted. After the signature, the decoder runs validators: the default checks exp and nbf, and ShopLite sets its own list (expiry with a 30-second allowance, and the issuer).

When the resource server finds a JwtDecoder bean it uses it. Without one, and without spring.security.oauth2.resourceserver.jwt.* properties, the app fails at startup, because the filter has nothing to check tokens with.

From the roles claim to authorities

JwtAuthenticationConverter turns a checked Jwt into a Spring Security Authentication. With a JwtGrantedAuthoritiesConverter it reads the roles claim and adds the ROLE_ prefix, so ["CUSTOMER"] becomes ROLE_CUSTOMER.

By default the resource server reads authorities from the scope claim, but ShopLite's tokens carry roles. Without a converter, hasRole("ADMIN") never matches.

Example 5 · The roles claim at work: 403 for a customer, 200 for the admin

Runs in: the shoplite-api Spring Boot project

Terminal
curl -i http://localhost:8080/api/v1/customers/1 -H "Authorization: Bearer $TOKEN"        # Asha, CUSTOMERcurl -i http://localhost:8080/api/v1/customers/1 -H "Authorization: Bearer $ADMIN_TOKEN"  # admin, ADMIN
Sample output
HTTP/1.1 403
WWW-Authenticate: Bearer error="insufficient_scope", error_description="The request requires higher privileges than provided by the access token.", error_uri="https://tools.ietf.org/html/rfc6750#section-3.1"
Content-Type: application/problem+json

{"type":"https://shoplite.example/problems/forbidden","title":"Forbidden","status":403,"detail":"You do not have permission to do this.","instance":"/api/v1/customers/1"}

HTTP/1.1 200
Content-Type: application/json

{"id":1,"fullName":"Asha Rao","email":"asha.rao@example.com","phone":"9876543201","createdAt":"2026-05-04T10:15:00+05:30"}

DEBUG log for the two requests (shortened):
... .s.r.w.a.BearerTokenAuthenticationFilter : Set SecurityContextHolder to JwtAuthenticationToken [Principal=...JwtAuthenticatedPrincipal@6e970f7e, Credentials=[PROTECTED], Authenticated=true, ..., Granted Authorities=[ROLE_CUSTOMER, FactorGrantedAuthority [authority=FACTOR_BEARER, issuedAt=2026-10-16T07:58:14.927675600Z]]]
... .s.r.w.a.BearerTokenAuthenticationFilter : Set SecurityContextHolder to JwtAuthenticationToken [Principal=...JwtAuthenticatedPrincipal@a68456b7, Credentials=[PROTECTED], Authenticated=true, ..., Granted Authorities=[FactorGrantedAuthority [authority=FACTOR_BEARER, issuedAt=2026-10-16T07:58:15.605034300Z], ROLE_ADMIN]]

What this code does

  • Asha's token has roles: ["CUSTOMER"], so her authorities are ROLE_CUSTOMER and FACTOR_BEARER, and hasRole("ADMIN") says no: 403 with insufficient_scope.
  • The admin token gives ROLE_ADMIN, and the same URL answers 200.
  • The 403 is a problem body from SecurityProblems.forbidden(), not Spring's default empty page.

An authority is a permission string such as ROLE_ADMIN that access rules check. The default reads the scope or scp claim with the prefix SCOPE_, because that is what OAuth login servers send. With the converter, hasRole("ADMIN") works on tokens exactly as it did with database users.

ShopLite adds its first role rule here: reading any customer by id is for staff only, and customers use GET /api/v1/me, whose id comes from the token's sub, never from the URL. A customer token gets 403 forbidden; the admin token gets 200. Spring Security 7 also gives every bearer sign-in the authority FACTOR_BEARER, which records how the user proved who they are.

Fix the error

Make the admin role work

Read the error, then pick the line that fixes it.

Round 1 of 2

The admin token has roles ["ADMIN"], yet GET /api/v1/customers/1 answers 403. Fix line 2.

http.oauth2ResourceServer(oauth -> oauth
.jwt(Customizer.withDefaults()));

Error

HTTP/1.1 403
WWW-Authenticate: Bearer error="insufficient_scope"

Stateless sessions and CSRF off, with the reason in the code

With a token on every request, the server has no use for a session. The code below turns sessions and CSRF protection off, with the reason written beside it.

Java
// The API reads the token from the Authorization header, never from a cookie,// so a forged cross-site request cannot carry it: CSRF protection is not needed..csrf(csrf -> csrf.disable())// No HttpSession and no JSESSIONID cookie: every request proves itself with its token.sessionManagement(session -> session    .sessionCreationPolicy(SessionCreationPolicy.STATELESS));

SessionCreationPolicy.STATELESS tells Spring Security never to create an HttpSession and never to read the context from one. Each request carries its own token, so there is no JSESSIONID cookie and any server behind a load balancer can answer any request.

CSRF protection is switched off for this API, and the comment in the code says why: a forged cross-site request rides on credentials the browser sends by itself (cookies), but the browser never adds an Authorization header by itself. If a later version moves the token into a cookie, CSRF protection must come back; the Where clients store tokens lesson returns to this.

Why not a hand-written OncePerRequestFilter

Many tutorials write their own OncePerRequestFilter: read the header, parse the token, build an Authentication. The sketch below shows that shape so you can recognise it in old projects.

Example 6 · A hand-written token filter (do not copy)

Runs in: a sketch for comparison, not part of ShopLite

Java
// A SKETCH for comparison only. ShopLite does NOT use this class: oauth2ResourceServer(jwt) does all of it.class HandWrittenJwtFilter extends OncePerRequestFilter {
    private final JwtDecoder decoder;
    HandWrittenJwtFilter(JwtDecoder decoder) {        this.decoder = decoder;    }
    @Override    protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain)            throws ServletException, IOException {        String header = request.getHeader("Authorization");        if (header == null || !header.startsWith("Bearer ")) {     // case? spaces? two headers?            chain.doFilter(request, response);            return;        }        try {            Jwt jwt = decoder.decode(header.substring(7));            List<GrantedAuthority> authorities = jwt.getClaimAsStringList("roles").stream()                    .map(role -> (GrantedAuthority) new SimpleGrantedAuthority("ROLE_" + role)).toList();            SecurityContext context = SecurityContextHolder.createEmptyContext();            context.setAuthentication(new JwtAuthenticationToken(jwt, authorities));            SecurityContextHolder.setContext(context);        } catch (JwtException e) {            response.sendError(401);            return;        }        chain.doFilter(request, response);        // and the context must be cleared after the request, or the next request on this thread is "signed in"    }}
What it misses
What the built-in BearerTokenAuthenticationFilter already does that this sketch gets wrong or leaves out:
- reads the header case-insensitively, rejects two Authorization headers and an empty token
- ignores ?access_token=... in the URL unless you switch it on
- builds the WWW-Authenticate: Bearer error="invalid_token" header (RFC 6750)
- hands failures to your AuthenticationEntryPoint, so the 401 body matches the API
- uses the SecurityContextHolderStrategy and clears the context after the request
- adds the FACTOR_BEARER authority and the request details, and publishes authentication events

What this code does

  • This is the shape found in many older tutorials; each comment marks a decision that the built-in filter already makes for you.
  • Even with a correct JwtDecoder, the filter still has to get headers, errors, context cleanup and events right on its own.
  • ShopLite keeps oauth2ResourceServer(jwt): less code, standard behaviour, and the same filter Spring Security tests.

A hand-written filter works on the happy path, which is why it is so common. The trouble is everything else: what the 401 looks like, the WWW-Authenticate header, two headers, an empty token, a token in the URL, clearing the context, and which algorithm is accepted. The built-in filter has answers for all of these, written once and tested by the Spring Security team.

ShopLite's own code for token checks is one decoder bean and one converter. Being able to explain in an interview why you did not write the filter yourself is worth more than the filter.

Next step

Check your understanding

12 quick questions