Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
safeway-pricing-pod
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ramu Dosapati
safeway-pricing-pod
Commits
4834a615
Commit
4834a615
authored
Nov 28, 2022
by
gkhan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
security code added
parent
43153221
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
53 additions
and
0 deletions
+53
-0
build.gradle
build.gradle
+3
-0
SecurityConfig.java
...va/com/safeway/pricing/safeway/config/SecurityConfig.java
+23
-0
PricingController.java
...safeway/pricing/safeway/controller/PricingController.java
+9
-0
application.properties
src/main/resources/application.properties
+1
-0
application.yml
src/main/resources/application.yml
+17
-0
No files found.
build.gradle
View file @
4834a615
...
@@ -36,6 +36,9 @@ dependencies {
...
@@ -36,6 +36,9 @@ dependencies {
compileOnly
group:
'org.json'
,
name:
'json'
,
version:
'20180813'
compileOnly
group:
'org.json'
,
name:
'json'
,
version:
'20180813'
implementation
'org.springframework.boot:spring-boot-starter-actuator'
implementation
'org.springframework.boot:spring-boot-starter-actuator'
implementation
'de.codecentric:spring-boot-admin-starter-client'
implementation
'de.codecentric:spring-boot-admin-starter-client'
implementation
'org.springframework.boot:spring-boot-starter-security'
implementation
'org.springframework.boot:spring-boot-starter-oauth2-client'
compileOnly
'org.springframework.boot:spring-boot-starter-tomcat'
}
}
dependencyManagement
{
dependencyManagement
{
...
...
src/main/java/com/safeway/pricing/safeway/config/SecurityConfig.java
0 → 100644
View file @
4834a615
package
com
.
safeway
.
pricing
.
safeway
.
config
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.security.config.annotation.web.builders.HttpSecurity
;
import
org.springframework.security.config.annotation.web.configuration.EnableWebSecurity
;
import
org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter
;
@Configuration
@EnableWebSecurity
public
class
SecurityConfig
extends
WebSecurityConfigurerAdapter
{
@Override
protected
void
configure
(
HttpSecurity
http
)
throws
Exception
{
http
.
authorizeRequests
()
.
antMatchers
(
"/oauth2/**"
,
"/login/**"
).
permitAll
()
.
anyRequest
().
authenticated
()
.
and
()
.
oauth2Login
()
.
defaultSuccessUrl
(
"/group1"
);
}
}
src/main/java/com/safeway/pricing/safeway/controller/PricingController.java
View file @
4834a615
...
@@ -12,6 +12,8 @@ import com.safeway.pricing.safeway.service.PricingService;
...
@@ -12,6 +12,8 @@ import com.safeway.pricing.safeway.service.PricingService;
import
com.safeway.pricing.safeway.util.AppUtil
;
import
com.safeway.pricing.safeway.util.AppUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.MediaType
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.security.core.annotation.AuthenticationPrincipal
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
reactor.core.publisher.Flux
;
import
reactor.core.publisher.Flux
;
import
reactor.core.publisher.Mono
;
import
reactor.core.publisher.Mono
;
...
@@ -67,6 +69,13 @@ public class PricingController {
...
@@ -67,6 +69,13 @@ public class PricingController {
public
Flux
<
SaleDetailsDTO
>
allSaleDetails
()
{
public
Flux
<
SaleDetailsDTO
>
allSaleDetails
()
{
return
this
.
pricingService
.
getSalesDetails
();
return
this
.
pricingService
.
getSalesDetails
();
}
}
@GetMapping
(
"/group1"
)
@PreAuthorize
(
"hasRole('ROLE_group1')"
)
public
String
getDetails
(
@AuthenticationPrincipal
(
expression
=
"claims['name']"
)
String
name
)
{
return
"Hellow User "
+
name
;
}
}
}
src/main/resources/application.properties
View file @
4834a615
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
#Springboot Application
#Springboot Application
spring.application.name
=
spring-boot-management
spring.application.name
=
spring-boot-management
spring.main.allow-bean-definition-overriding
=
true
server.port
=
8789
server.port
=
8789
spring.mvc.pathmatch.matching-strategy
=
ANT_PATH_MATCHER
spring.mvc.pathmatch.matching-strategy
=
ANT_PATH_MATCHER
client.host
=
http://localhost:8789
client.host
=
http://localhost:8789
...
...
src/main/resources/application.yml
View file @
4834a615
spring
:
security
:
oauth2
:
client
:
provider
:
azure-ad
:
authorization-uri
:
https://login.microsoftonline.com/common/oauth2/v2.0/authorize
token-uri
:
https://login.microsoftonline.com/common/oauth2/v2.0/token
jwk-set-uri
:
https://login.microsoftonline.com/common/discovery/v2.0/keys
registration
:
azure-client
:
provider
:
azure-ad
client-id
:
f4507396-c51a-4348-bb9f-9bcf56795357
client-secret
:
Q-Y8Q~K~Ocg-K-gxR9AjX9dAXYkEIH7BnQYuRcNs
authorization-grant-type
:
authorization_code
redirect-uri
:
'
{baseUrl}/login/oauth2/code/{registrationId}'
scope
:
openid,profile
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment