Skip to content

Commit e75c2e2

Browse files
authored
Merge pull request #18 from auth0/add-publish-script
Added Publish Script
2 parents 20234af + 5d1cc54 commit e75c2e2

9 files changed

Lines changed: 166 additions & 141 deletions

File tree

auth0-api-java/build.gradle

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,37 @@ plugins {
22
id 'java-library'
33
}
44

5-
group = 'com.auth0'
6-
version = '1.0.0-SNAPSHOT'
7-
8-
java {
9-
sourceCompatibility = JavaVersion.VERSION_1_8
10-
targetCompatibility = JavaVersion.VERSION_1_8
5+
ext {
6+
POM_ARTIFACT_ID = 'auth0-api-java'
7+
POM_NAME = 'auth0-api-java'
8+
POM_DESCRIPTION = 'Auth0 Java API Library'
9+
POM_PACKAGING = 'jar'
1110
}
1211

12+
// Disable javadoc for this module (Java 8 target, internal API)
1313
tasks.withType(Javadoc) {
1414
enabled = false
1515
}
1616

17+
apply from: rootProject.file('gradle/versioning.gradle')
18+
19+
group = GROUP
20+
version = getVersionFromFile()
21+
22+
java {
23+
sourceCompatibility = JavaVersion.VERSION_1_8
24+
targetCompatibility = JavaVersion.VERSION_1_8
25+
}
26+
1727
dependencies {
1828
// Core dependencies
1929
implementation 'com.fasterxml.jackson.core:jackson-databind:2.15.2'
2030
implementation 'org.apache.httpcomponents:httpclient:4.5.14'
21-
31+
2232
// JWT validation dependencies
2333
implementation 'com.auth0:java-jwt:4.5.1'
2434
implementation 'com.auth0:jwks-rsa:0.23.0'
25-
35+
2636
// Test dependencies
2737
testImplementation 'junit:junit:4.13.2'
2838
testImplementation 'org.hamcrest:hamcrest:2.2'
@@ -41,5 +51,6 @@ test {
4151
}
4252
}
4353

44-
// This module is internal - no publishing configuration needed
45-
// It will be bundled into auth0-springboot-api as a transitive dependency
54+
logger.lifecycle("Using version ${version} for ${name} group ${group}")
55+
56+
apply from: rootProject.file('gradle/maven-publish.gradle')
Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.auth0.playground;
22

3+
import org.springframework.http.ResponseEntity;
34
import org.springframework.security.core.Authentication;
45
import org.springframework.web.bind.annotation.GetMapping;
56
import org.springframework.web.bind.annotation.RequestMapping;
@@ -11,13 +12,20 @@
1112
public class ProfileController {
1213

1314
@GetMapping("/protected")
14-
public String protectedEndpoint(Authentication authentication) {
15-
System.out.println("🔐 Received request for protected resource: "+ authentication.getPrincipal().toString());
16-
return "Hello " + authentication.getName() + ", access granted!";
15+
public ResponseEntity<Map<String, Object>> protectedEndpoint(Authentication authentication) {
16+
String userId = authentication.getName(); // Returns the 'sub' claim
17+
18+
return ResponseEntity.ok(Map.of(
19+
"message", "Access granted!",
20+
"user", userId,
21+
"authenticated", true
22+
));
1723
}
1824

1925
@GetMapping("/public")
20-
public Map<String, Object> pub() {
21-
return Map.of("message", "Public endpoint — no token required");
26+
public ResponseEntity<Map<String, Object>> publicEndpoint() {
27+
return ResponseEntity.ok(Map.of(
28+
"message", "Public endpoint - no token required"
29+
));
2230
}
2331
}

auth0-springboot-api-playground/src/main/java/com/auth0/playground/SecurityConfig.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
import com.auth0.spring.boot.Auth0AuthenticationFilter;
44
import org.springframework.context.annotation.Bean;
55
import org.springframework.context.annotation.Configuration;
6+
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
67
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
78
import org.springframework.security.config.http.SessionCreationPolicy;
89
import org.springframework.security.web.SecurityFilterChain;
910
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
1011

1112
@Configuration
13+
@EnableMethodSecurity
1214
public class SecurityConfig {
1315
@Bean
1416
SecurityFilterChain apiSecurity(

0 commit comments

Comments
 (0)