Skip to content

Commit

Permalink
feat: CARITAS-286
Browse files Browse the repository at this point in the history
* add new authority for the new private endpoint, update its path and added the new authority to the SecurityConfig
  • Loading branch information
Leandro13Silva13 committed Oct 30, 2024
1 parent 7f44d8f commit 521206a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
7 changes: 4 additions & 3 deletions api/agencyservice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,13 @@ paths:
description: FORBIDDEN - no/invalid CSRF token
500:
description: INTERNAL SERVER ERROR - server encountered unexpected condition
/agencies/private:
/agencies/by-tenant:
get:
tags:
- agency-controller
summary: 'Returns a list of agencies from a specific tenant. If no agency is found No Content
is being returned. [Authorization: none]'
summary: 'Returns a list of agencies from a specific tenant (retrieved from the security context).
The security context is retrieved from the bearer token, so it is not passed as a request parameter.
If no agency is found No Content is being returned. [Authorization: none]'
operationId: getTenantAgencies
parameters:
- name: postcode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ public enum Authority {
TENANT_ADMIN("tenant-admin", AuthorityValue.TENANT_ADMIN),
RESTRICTED_AGENCY_ADMIN("restricted-agency-admin", AuthorityValue.RESTRICTED_AGENCY_ADMIN, AuthorityValue.SEARCH_AGENCIES),

RESTRICTED_CONSULTANT_ADMIN("restricted-consultant-admin", AuthorityValue.SEARCH_AGENCIES);
RESTRICTED_CONSULTANT_ADMIN("restricted-consultant-admin", AuthorityValue.SEARCH_AGENCIES),

ADVICE_SEEKER("user", AuthorityValue.SEARCH_AGENCIES_WITHIN_TENANT);

private final String roleName;
private final List<String> authorities;
Expand Down Expand Up @@ -55,6 +57,7 @@ private AuthorityValue() {}
public static final String SEARCH_AGENCIES = PREFIX + "SEARCH_AGENCIES";
public static final String TENANT_ADMIN = PREFIX + "TENANT_ADMIN";
public static final String RESTRICTED_AGENCY_ADMIN = PREFIX + "RESTRICTED_AGENCY_ADMIN";
public static final String SEARCH_AGENCIES_WITHIN_TENANT = PREFIX + "SEARCH_AGENCIES_WITHIN_TENANT";

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
.requestMatchers("/agencies").permitAll()
.requestMatchers(HttpMethod.GET, "/agencyadmin/agencies")
.hasAuthority(AuthorityValue.SEARCH_AGENCIES)
.requestMatchers("/agencies/by-tenant").hasAuthority(AuthorityValue.SEARCH_AGENCIES_WITHIN_TENANT)
.requestMatchers("/agencyadmin/agencies/tenant/*")
.access("hasAuthority('" + AuthorityValue.AGENCY_ADMIN
+ "') and hasAuthority('" + AuthorityValue.TENANT_ADMIN + "')")
Expand Down

0 comments on commit 521206a

Please sign in to comment.