Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nshmp-apps
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ghsc
National Seismic Hazard Model Project
nshmp-apps
Merge requests
!538
Internal Applications
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Internal Applications
ghsc/users/bclayton/nshmp/nshmp-apps:internal
into
main
Overview
0
Commits
10
Pipelines
0
Changes
1
Merged
Clayton, Brandon Scott
requested to merge
ghsc/users/bclayton/nshmp/nshmp-apps:internal
into
main
4 months ago
Overview
0
Commits
10
Pipelines
0
Changes
1
Expand
Move aws to internal application path.
Use authorizer to allow internal application
0
0
Merge request reports
Viewing commit
c0d58c10
Prev
Next
Show latest version
1 file
+
49
−
0
Side-by-side
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
c0d58c10
add authorizer service.
· c0d58c10
Clayton, Brandon Scott
authored
4 months ago
projects/nshmp-apps/src/app/internal/shared/services/auth.service.ts
0 → 100644
+
49
−
0
Options
import
{
HttpClient
}
from
'
@angular/common/http
'
;
import
{
Injectable
}
from
'
@angular/core
'
;
import
{
NshmpService
,
SpinnerService
}
from
'
@ghsc/nshmp-lib-ng/nshmp
'
;
import
{
environment
}
from
'
projects/nshmp-apps/src/environments/environment
'
;
import
{
catchError
,
map
}
from
'
rxjs
'
;
interface
AuthResponse
{
isAuthorized
:
boolean
;
}
/**
* Authorizer for USGS network.
*/
@
Injectable
({
providedIn
:
'
root
'
,
})
export
class
AuthService
{
private
service
=
environment
.
webServices
.
aws
;
private
url
=
`
${
this
.
service
.
url
}${
this
.
service
.
services
.
auth
}
`
;
constructor
(
private
http
:
HttpClient
,
private
spinnerService
:
SpinnerService
,
private
nshmpService
:
NshmpService
)
{}
isAuthorized
()
{
const
ref
=
this
.
spinnerService
.
show
(
'
Checking USGS network ...
'
);
return
this
.
http
.
get
<
AuthResponse
>
(
this
.
url
).
pipe
(
map
(
response
=>
{
console
.
log
(
response
);
ref
.
close
();
if
(
!
response
.
isAuthorized
)
{
this
.
nshmpService
.
throwError
$
(
new
Error
(
'
Must be on USGS network to access internal applications
'
)
);
}
return
response
.
isAuthorized
;
}),
catchError
((
error
:
Error
)
=>
{
ref
.
close
();
return
this
.
nshmpService
.
throwError
$
(
error
);
})
);
}
}
Loading