Skip to content

Commit b6c91e9

Browse files
authored
Merge pull request #645 from bcgov/yj
chore: create aps user returns id
2 parents 9f5820e + 914f594 commit b6c91e9

File tree

4 files changed

+66
-9
lines changed

4 files changed

+66
-9
lines changed

gateway/strdata.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,61 @@ services:
109109
config:
110110
header: GW-JWT
111111
include_credential_type: false
112+
- name: strdata-uat
113+
host: uat.strdata.gov.bc.ca
114+
tags: [ns.strdata]
115+
port: 443
116+
protocol: https
117+
retries: 0
118+
routes:
119+
- name: strdata-uat
120+
tags: [ns.strdata]
121+
hosts:
122+
- strdata-uat.api.gov.bc.ca
123+
methods:
124+
- GET
125+
paths: [/api/organizations/strrequirements]
126+
strip_path: false
127+
https_redirect_status_code: 426
128+
path_handling: v0
129+
request_buffering: true
130+
response_buffering: true
131+
plugins:
132+
- name: jwt-keycloak
133+
tags: [ns.strdata]
134+
enabled: true
135+
config:
136+
allowed_iss: [https://test.loginproxy.gov.bc.ca/auth/realms/apigw]
137+
allowed_aud: gateway-strdata
138+
run_on_preflight: true
139+
iss_key_grace_period: 10
140+
maximum_expiration: 0
141+
algorithm: RS256
142+
claims_to_verify:
143+
- exp
144+
uri_param_names:
145+
- jwt
146+
cookie_names: []
147+
scope:
148+
roles:
149+
realm_roles:
150+
client_roles:
151+
anonymous:
152+
consumer_match: true
153+
consumer_match_claim: azp
154+
consumer_match_claim_custom_id: true
155+
consumer_match_ignore_not_found: false
156+
- name: request-transformer
157+
tags: [ns.strdata]
158+
enabled: true
159+
config:
160+
http_method:
161+
- name: kong-upstream-jwt
162+
enabled: true
163+
tags: [ns.strdata]
164+
config:
165+
header: GW-JWT
166+
include_credential_type: false
112167
- name: strdata-prod
113168
host: strdata.gov.bc.ca
114169
tags: [ns.strdata]

server/StrDss.Api/Controllers/UsersController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,14 +155,14 @@ public async Task<ActionResult> GetBceidUserInfo()
155155
[HttpPost("aps", Name = "CreateApsUser")]
156156
public async Task<ActionResult> CreateApsUser(ApsUserCreateDto dto)
157157
{
158-
var errors = await _userService.CreateApsUserAsync(dto);
158+
var (errors, userId) = await _userService.CreateApsUserAsync(dto);
159159

160160
if (errors.Count > 0)
161161
{
162162
return ValidationUtils.GetValidationErrorResult(errors, ControllerContext);
163163
}
164164

165-
return Ok();
165+
return Ok(userId);
166166
}
167167
}
168168
}

server/StrDss.Data/Repositories/UserRepository.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public interface IUserRepository
2525
Task<List<DropdownStrDto>> GetAccessRequestStatuses();
2626
Task AcceptTermsConditions();
2727
Task UpdateUserNamesAsync(long userId, string firstName, string lastName);
28-
Task CreateApsUserAsync(ApsUserCreateDto dto);
28+
Task<DssUserIdentity> CreateApsUserAsync(ApsUserCreateDto dto);
2929
Task<bool> ApsUserExists(string clientId);
3030
}
3131
public class UserRepository : RepositoryBase<DssUserIdentity>, IUserRepository
@@ -235,7 +235,7 @@ public async Task UpdateUserNamesAsync(long userId, string firstName, string las
235235
entity.GivenNm = firstName;
236236
}
237237

238-
public async Task CreateApsUserAsync(ApsUserCreateDto dto)
238+
public async Task<DssUserIdentity> CreateApsUserAsync(ApsUserCreateDto dto)
239239
{
240240
dto.FamilyNm = dto.DisplayNm;
241241

@@ -252,6 +252,8 @@ public async Task CreateApsUserAsync(ApsUserCreateDto dto)
252252
}
253253

254254
await _dbContext.AddAsync(userEntity);
255+
256+
return userEntity;
255257
}
256258

257259
public async Task<bool> ApsUserExists(string clientId)

server/StrDss.Service/UserService.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public interface IUserService
2727
Task<UserDto?> GetUserByIdAsync(long userId);
2828
Task<Dictionary<string, List<string>>> UpdateUserAsync(UserUpdateDto dto);
2929
Task<BceidAccount?> GetBceidUserInfo();
30-
Task<Dictionary<string, List<string>>> CreateApsUserAsync(ApsUserCreateDto dto);
30+
Task<(Dictionary<string, List<string>>, long)> CreateApsUserAsync(ApsUserCreateDto dto);
3131
Task<(UserDto? user, List<string> permissions)> GetUserByDisplayNameAsync(string displayName);
3232
}
3333
public class UserService : ServiceBase, IUserService
@@ -529,7 +529,7 @@ private async Task ValidateOrgAndRoles(IOrgRoles dto, Dictionary<string, List<st
529529
return null;
530530
}
531531

532-
public async Task<Dictionary<string, List<string>>> CreateApsUserAsync(ApsUserCreateDto dto)
532+
public async Task<(Dictionary<string, List<string>>, long)> CreateApsUserAsync(ApsUserCreateDto dto)
533533
{
534534
var errors = new Dictionary<string, List<string>>();
535535

@@ -545,13 +545,13 @@ public async Task<Dictionary<string, List<string>>> CreateApsUserAsync(ApsUserCr
545545
errors.AddItem("client_id", $"The client ID {dto.DisplayNm} already exists.");
546546
}
547547

548-
if (errors.Any()) return errors;
548+
if (errors.Any()) return (errors, 0);
549549

550-
await _userRepo.CreateApsUserAsync(dto);
550+
var entity = await _userRepo.CreateApsUserAsync(dto);
551551

552552
_unitOfWork.Commit();
553553

554-
return errors;
554+
return (errors, entity.UserIdentityId);
555555
}
556556
}
557557
}

0 commit comments

Comments
 (0)