Skip to content

Commit

Permalink
fix check prop it.pierfani.firebaseappcheck.enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
pierfani committed Oct 3, 2024
1 parent 93cfc22 commit 2aaf65b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Per utilizzare questa libreria nel tuo progetto, aggiungi le seguenti configuraz
<dependency>
<groupId>it.pierfani</groupId>
<artifactId>firebase-appcheck-spring-boot-starter</artifactId>
<version>1.0.2</version>
<version>1.0.3</version>
</dependency>
```

Expand Down Expand Up @@ -110,7 +110,7 @@ To use this library in your project, add the following configurations to your `p
<dependency>
<groupId>it.pierfani</groupId>
<artifactId>firebase-appcheck-spring-boot-starter</artifactId>
<version>1.0.2</version>
<version>1.0.3</version>
</dependency>
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
Expand All @@ -24,6 +23,7 @@
import com.auth0.jwt.interfaces.JWTVerifier;

import jakarta.servlet.http.HttpServletRequest;

@Aspect
@Component
public class FirebaseAppCheckAspect {
Expand All @@ -36,6 +36,9 @@ public class FirebaseAppCheckAspect {
@Value("${it.pierfani.firebaseappcheck.jwks-url}")
private String firebaseJwksUrlString;

@Value("${it.pierfani.firebaseappcheck.enabled}")
private boolean firebaseAppCheckEnabled;

private JwkProvider provider;

private void initializeProvider() throws MalformedURLException {
Expand All @@ -49,8 +52,11 @@ private void initializeProvider() throws MalformedURLException {
}

@Around("@annotation(it.pierfani.firebaseappcheck.FirebaseAppCheck)")
@ConditionalOnExpression("${it.pierfani.firebaseappcheck.enabled}")
public Object checkFirebaseAppCheck(ProceedingJoinPoint joinPoint) throws Throwable {
if (!firebaseAppCheckEnabled) {
return joinPoint.proceed();
}

HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes())
.getRequest();
String appCheckToken = request.getHeader(FIREBASE_APP_CHECK_HEADER);
Expand Down

0 comments on commit 2aaf65b

Please sign in to comment.