Skip to content

Commit

Permalink
EMBCESSMOD-184: various fixes (bcgov#855)
Browse files Browse the repository at this point in the history
* Changed ess.developera2 to be non admin

* Added org id and user id to claim transformation

* simple version info
  • Loading branch information
ytqsl authored and rafaelponcedeleon committed Jan 14, 2020
1 parent 72bbb33 commit af1a833
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 16 deletions.
9 changes: 7 additions & 2 deletions embc-app/Authentication/KeyCloakClaimTransformer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,11 @@ public async Task<ClaimsPrincipal> TransformAsync(ClaimsPrincipal principal)
if (type.Equals("bceid", StringComparison.InvariantCultureIgnoreCase)) transformedClaims.Add(new Claim(SiteMinderClaimTypes.USER_TYPE, "business"));
if (type.Equals("idir", StringComparison.InvariantCultureIgnoreCase)) transformedClaims.Add(new Claim(SiteMinderClaimTypes.USER_TYPE, "internal"));
}
transformedClaims.Add(new Claim(EssClaimTypes.ORG_ID, ""));
transformedClaims.Add(new Claim(EssClaimTypes.USER_ID, ""));

if (isAdmin)
{
transformedClaims.AddRange(ProvincialAdminRoles.Select(r => new Claim(ClaimTypes.Role, r))); //provincial admin roles
transformedClaims.Add(new Claim(EssClaimTypes.USER_ID, userGuid));
}
else
{
Expand All @@ -57,6 +56,12 @@ public async Task<ClaimsPrincipal> TransformAsync(ClaimsPrincipal principal)
: user.IsPrimaryContact ?? false ? LocalAuthorityRoles : VolunteerRoles; //volunteer/volunteer admin roles

transformedClaims.AddRange(roles.Select(r => new Claim(ClaimTypes.Role, r)));

if (user != null)
{
transformedClaims.Add(new Claim(EssClaimTypes.ORG_ID, user.Organization.Id));
transformedClaims.Add(new Claim(EssClaimTypes.USER_ID, user.Id));
}
}

return new ClaimsPrincipal(new ClaimsIdentity(transformedClaims, principal.Identity.AuthenticationType));
Expand Down
19 changes: 13 additions & 6 deletions embc-app/ClientApp/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,30 @@ import { UniqueKeyService } from './core/services/unique-key.service';
import { Router } from '@angular/router';
import { Store } from '@ngrx/store';
import { AppState } from './store';
import { Config } from './core/models';

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {

isIE = false;

private config: Config;

constructor(
private lookups: ControlledListService,
public authService: AuthService,
public uniqueKeyService: UniqueKeyService,
// private router: Router,
// private store: Store<AppState>, // ngrx app state

) { }
private store: Store<AppState> // ngrx app state
) {
// get config
this.store.select(s => s.lookups.config.config).subscribe((config: Config) => {
this.config = config;
});
}

ngOnInit() {
this.isIE = detectIE10orLower();
Expand All @@ -49,7 +55,9 @@ export class AppComponent implements OnInit {
}

get versionInfo(): any {
return null;
return this.config
? `${this.config.sourceReference}_${this.config.sourceCommit}_${this.config.fileCreationTime}`
: ''
}

// get currentUser(): User {
Expand Down Expand Up @@ -88,5 +96,4 @@ export class AppComponent implements OnInit {
// ...add more
).subscribe();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<a class="nav-link" href="https://www2.gov.bc.ca/gov/content/home/copyright" target="_blank" title="Goes to BC Gov Copyright Page">Copyright</a>
</li>
</ul>
<a *ngIf="versionInfo && versionInfo.fileVersion" (click)="showVersionInfo()" class="nav-link version-info">{{versionInfo.fileVersion}}</a>
<a *ngIf="versionInfo" class="nav-link">{{versionInfo}}</a>
</div>
</nav>
</footer>
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,4 @@ export class FooterComponent implements OnInit {

ngOnInit() {
}

showVersionInfo() {
// TODO: Implement
}
}
1 change: 1 addition & 0 deletions embc-app/Controllers/UsersController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public UsersController(IConfiguration configuration, IHttpContextAccessor httpCo
public virtual IActionResult UsersCurrentGet()
{
var principal = HttpContext.User;
//TODO: refactor client and server property names to match claim names in order to simplify the code readability
ViewModels.User user = new ViewModels.User()
{
appRoles = principal.FindAll(ClaimTypes.Role).Select(c => c.Value).ToArray(),
Expand Down
6 changes: 3 additions & 3 deletions embc-app/Seeder/SeedData/Volunteers.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
"email": "adm2@ebmc",
"BceidAccountUserName": "ess.developerA2",
"Active": true,
"isAdministrator": true,
"isPrimaryContact": true,
"isAdministrator": false,
"isPrimaryContact": false,
"canAccessRestrictedFiles": false,
"organization": {
"BCeIDBusinessGuid": "15F6FD8BC6C6401DB319311853FC518E"
Expand All @@ -59,4 +59,4 @@
"firstName": "developerA2",
"lastName": "ess"
}
]
]

0 comments on commit af1a833

Please sign in to comment.