This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Auth.currentCredentials().then( res => { | |
this.service.getDataFromAws(res).subscribe( | |
data => { | |
this.dbItem = data; | |
}, | |
error => { | |
this.error = "Unable to connect to the service."; | |
} | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.harshajayamanna.blog.service; | |
import com.harshajayamanna.blog.entity.BlogPost; | |
import com.harshajayamanna.blog.entity.Meta; | |
import javax.persistence.EntityManager; | |
import javax.persistence.PersistenceContext; | |
import javax.persistence.Query; | |
import javax.transaction.Transactional; | |
import java.io.Serializable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | |
<persistence version="2.2" | |
xmlns="http://xmlns.jcp.org/xml/ns/persistence" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence | |
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd"> | |
<persistence-unit name="blogpostunit" | |
transaction-type="JTA"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<application location="jakartaee8-hibernate-example.war" | |
contextRoot="/" > | |
<classloader commonLibraryRef="hibernate"/> | |
</application> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dataSource id="hibernatemysqldb" | |
jndiName="jdbc/recruittimesdb"> | |
<jdbcDriver libraryRef="MySQLLib" /> | |
<properties databaseName="test_db" | |
serverName="localhost" password="admin1234" user="root" | |
serverTimezone="UTC" portNumber="3306" /> | |
</dataSource> | |
<library id="MySQLLib"> | |
<file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component | |
public class UsernameSubClaimAdapter implements Converter<Map<String, Object>, Map<String, Object>> { | |
private final MappedJwtClaimSetConverter delegate = MappedJwtClaimSetConverter.withDefaults(Collections.emptyMap()); | |
@Override | |
public Map<String, Object> convert(Map<String, Object> claims) { | |
Map<String, Object> convertedClaims = this.delegate.convert(claims); | |
if (claims.containsKey("cognito:groups")) { | |
convertedClaims.put("authorities", claims.get("cognito:groups")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Bean | |
public JwtDecoder jwtDecoder() { | |
NimbusJwtDecoder jwtDecoder = (NimbusJwtDecoder) JwtDecoders.fromIssuerLocation(issuerUri); | |
OAuth2TokenValidator<Jwt> withClockSkew = new DelegatingOAuth2TokenValidator<>( | |
new JwtTimestampValidator(Duration.ofSeconds(60)), new JwtIssuerValidator(issuerUri)); | |
jwtDecoder.setJwtValidator(withClockSkew); | |
jwtDecoder.setClaimSetConverter(new UsernameSubClaimAdapter()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
protected void configure(HttpSecurity http) throws Exception { | |
http.cors(); | |
http.csrf().disable(); | |
http.authorizeRequests().antMatchers("/status").permitAll().anyRequest().authenticated().and() | |
.oauth2ResourceServer().jwt(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
spring.security.oauth2.resourceserver.jwt.issuer-uri=https://cognito-idp.ap-southeast-1.amazonaws.com/ap-southeast-xxxxxxxxx | |
spring.security.oauth2.resourceserver.jwt.jwk-set-uri=https://cognito-idp.ap-southeast-1.amazonaws.com/ap-southeast-xxxxxxxxx/.well-known/jwks.json |