adding support for 3rd party idp's including hello - only on cloud deployment.
This commit is contained in:
parent
5d9bfa267b
commit
9bdc323c01
|
@ -36,6 +36,8 @@ jobs:
|
|||
|
||||
- name: Copy files to the test website with the AWS CLI
|
||||
run: |
|
||||
rm -rf dist/index.html
|
||||
mv dist/index-cloud.html dist/index.html
|
||||
aws s3 sync dist s3://app-sandbox.fastenhealth.com --acl public-read
|
||||
|
||||
- uses: chrnorm/deployment-action@v2
|
||||
|
|
|
@ -93,6 +93,7 @@
|
|||
]
|
||||
},
|
||||
"cloud_sandbox": {
|
||||
"index": "src/index-cloud.html",
|
||||
"fileReplacements": [
|
||||
{
|
||||
"replace": "src/environments/environment.ts",
|
||||
|
|
|
@ -38,6 +38,16 @@
|
|||
<strong>Error</strong> {{errorMsg}}
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="pt-4 pb-3">
|
||||
<div class="hello-container">
|
||||
<button (click)="idpConnectHello($event)" class="hello-btn"></button>
|
||||
<button class="hello-about"></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div><!-- az-signin-header -->
|
||||
<div class="az-signin-footer">
|
||||
<p><a ngbTooltip="not yet implemented">Forgot password?</a></p>
|
||||
|
|
|
@ -4,6 +4,8 @@ import {FastenDbService} from '../../services/fasten-db.service';
|
|||
import {Router} from '@angular/router';
|
||||
import {ToastService} from '../../services/toast.service';
|
||||
import {ToastNotification, ToastType} from '../../models/fasten/toast';
|
||||
import {environment} from '../../../environments/environment';
|
||||
import {AuthService} from '../../services/auth.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-auth-signin',
|
||||
|
@ -14,8 +16,9 @@ export class AuthSigninComponent implements OnInit {
|
|||
submitted: boolean = false
|
||||
existingUser: User = new User()
|
||||
errorMsg: string = ""
|
||||
showExternalIdP: boolean = environment.is_cloud
|
||||
|
||||
constructor(private fastenDb: FastenDbService, private router: Router, private toastService: ToastService) { }
|
||||
constructor(private fastenDb: FastenDbService, private authService: AuthService, private router: Router, private toastService: ToastService) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
}
|
||||
|
@ -36,6 +39,10 @@ export class AuthSigninComponent implements OnInit {
|
|||
toastNotificaiton.message = this.errorMsg
|
||||
this.toastService.show(toastNotificaiton)
|
||||
})
|
||||
}
|
||||
|
||||
idpConnectHello($event){
|
||||
this.authService.Connect('hello')
|
||||
.then(console.log)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { AuthService } from './auth.service';
|
||||
|
||||
describe('AuthService', () => {
|
||||
let service: AuthService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(AuthService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -0,0 +1,35 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {FastenDbService} from './fasten-db.service';
|
||||
import {User} from '../../lib/models/fasten/user';
|
||||
import {environment} from '../../environments/environment';
|
||||
import {GetEndpointAbsolutePath} from '../../lib/utils/endpoint_absolute_path';
|
||||
import {ResponseWrapper} from '../models/response-wrapper';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class AuthService {
|
||||
|
||||
constructor(private _httpClient: HttpClient) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Signup (and Signin) both require an "online" user.
|
||||
* @param newUser
|
||||
* @constructor
|
||||
*/
|
||||
public async Connect(idpType: string) {
|
||||
console.log("Connecting to external Idp")
|
||||
|
||||
let fastenApiEndpointBase = GetEndpointAbsolutePath(globalThis.location,environment.fasten_api_endpoint_base)
|
||||
|
||||
let resp = await this._httpClient.get<ResponseWrapper>(`${fastenApiEndpointBase}/auth/connect/${idpType}`).toPromise()
|
||||
console.log(resp)
|
||||
|
||||
const authorizeUrl = new URL(resp.data)
|
||||
authorizeUrl.searchParams.append('redirect_uri', window.location.href);
|
||||
window.location.href = authorizeUrl.toString();
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
export const environment = {
|
||||
production: true,
|
||||
is_cloud: true,
|
||||
lighthouse_api_endpoint_base: 'https://lighthouse.fastenhealth.com/sandbox',
|
||||
|
||||
//used to specify the couchdb server that we're going to use (can be relative or absolute). Must not have trailing slash
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
export const environment = {
|
||||
production: true,
|
||||
is_cloud: false,
|
||||
|
||||
lighthouse_api_endpoint_base: 'https://lighthouse.fastenhealth.com/v1',
|
||||
|
||||
//used to specify the couchdb server that we're going to use (can be relative or absolute). Must not have trailing slash
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
export const environment = {
|
||||
production: true,
|
||||
is_cloud: false,
|
||||
|
||||
lighthouse_api_endpoint_base: 'https://lighthouse.fastenhealth.com/sandbox',
|
||||
|
||||
//used to specify the couchdb server that we're going to use (can be relative or absolute). Must not have trailing slash
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
export const environment = {
|
||||
production: false,
|
||||
|
||||
// is the application running in the cloud? (enables 3rd party IdP's and token based couchdb authentication)
|
||||
is_cloud: false,
|
||||
|
||||
//specify the lighthouse server that we're going to use to authenticate against all our source/providers. Must not have trailing slash
|
||||
lighthouse_api_endpoint_base: 'https://lighthouse.fastenhealth.com/sandbox',
|
||||
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1, shrink-to-fit=no"
|
||||
/>
|
||||
<link rel="apple-touch-icon" sizes="76x76" href="./assets/img/apple-icon.png"/>
|
||||
<link rel="icon" type="image/png" href="./assets/img/favicon.png" />
|
||||
<title>fastenhealth</title>
|
||||
<!-- Fonts and icons -->
|
||||
<link href="https://fonts.googleapis.com/css?family=Poppins:200,300,400,600,700,800" rel="stylesheet"/>
|
||||
<link href="https://use.fontawesome.com/releases/v5.0.6/css/all.css" rel="stylesheet"/>
|
||||
<link href="https://cdn.hello.coop/css/hello-btn.css" rel="stylesheet"/>
|
||||
<script src="https://cdn.hello.coop/js/hello-btn.js"></script>
|
||||
|
||||
<script>
|
||||
var baseHref = "/"
|
||||
|
||||
// if the pathname includes /web, everthing before `/web` (and including web) should be set as the base path.
|
||||
if(window.location.pathname.includes('/web')){
|
||||
baseHref = "/web/"
|
||||
// probably running locally, and *may* include a subpath
|
||||
var subPath = window.location.pathname.split('/web').slice(0, 1)[0]
|
||||
if(subPath != "/"){
|
||||
//subpath, so we need to update the absolutePath with the subpath before adding the relative path to the end
|
||||
baseHref = subPath + '/web/'
|
||||
}
|
||||
}
|
||||
|
||||
document.write(`<base href="${baseHref}"/>`); </script>
|
||||
</head>
|
||||
<body>
|
||||
<app-root></app-root>
|
||||
</body>
|
||||
</html>
|
|
@ -6,22 +6,13 @@
|
|||
name="viewport"
|
||||
content="width=device-width, initial-scale=1, shrink-to-fit=no"
|
||||
/>
|
||||
<link
|
||||
rel="apple-touch-icon"
|
||||
sizes="76x76"
|
||||
href="./assets/img/apple-icon.png"
|
||||
/>
|
||||
<link rel="apple-touch-icon" sizes="76x76" href="./assets/img/apple-icon.png"/>
|
||||
<link rel="icon" type="image/png" href="./assets/img/favicon.png" />
|
||||
<title>fastenhealth</title>
|
||||
<!-- Fonts and icons -->
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css?family=Poppins:200,300,400,600,700,800"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
<link
|
||||
href="https://use.fontawesome.com/releases/v5.0.6/css/all.css"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
<link href="https://fonts.googleapis.com/css?family=Poppins:200,300,400,600,700,800" rel="stylesheet"/>
|
||||
<link href="https://use.fontawesome.com/releases/v5.0.6/css/all.css" rel="stylesheet"/>
|
||||
|
||||
<script>
|
||||
var baseHref = "/"
|
||||
|
||||
|
|
Loading…
Reference in New Issue