This commit is contained in:
MaxKey
2022-05-05 17:13:16 +08:00
parent daad22a00e
commit 48600c4af8
27 changed files with 241 additions and 188 deletions

View File

@@ -38,7 +38,7 @@ import { LayoutDefaultOptions } from '../../theme/layout-default';
<layout-default [options]="options" [asideUser]="asideUserTpl" [content]="contentTpl" [customError]="null">
<layout-default-header-item direction="left">
<a href="#">
<img src="../assets/logo.jpg" alt="logo" style="height: 50px;height: 50px;float: left;" />
<img src="./assets/logo.jpg" alt="logo" style="height: 50px;height: 50px;float: left;" />
<div class="alain-default__header-title"> Max<span style="color: #FFD700;">Key</span>{{ 'mxk.title' | i18n }} </div>
</a>
</layout-default-header-item>

View File

@@ -1,19 +1,18 @@
/*
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Environment } from '@delon/theme';
@@ -21,8 +20,8 @@ export const environment = {
production: true,
useHash: true,
api: {
baseUrl: './',
baseUrl: '/sign',
refreshTokenEnabled: true,
refreshTokenType: 'auth-refresh'
refreshTokenType: 're-request'
}
} as Environment;

View File

@@ -27,7 +27,7 @@ export const environment = {
production: false,
useHash: true,
api: {
baseUrl: 'http://sso.maxkey.top:8080/maxkey',
baseUrl: 'http://sso.maxkey.top:9527/sign',
refreshTokenEnabled: true,
refreshTokenType: 're-request'
},

View File

@@ -0,0 +1,26 @@
FROM node:16.14.2
LABEL authors="MaxKey <maxkeysupport@163.com>"
WORKDIR /usr/src/app
COPY package.json package.json
RUN npm config set registry https://registry.npm.taobao.org \
&& npm i
COPY ./src ./src
RUN npm install -g @angular/cli
RUN ng build --prod
FROM nginx
COPY ./nginx.conf /etc/nginx/conf.d/
RUN rm -rf /usr/share/nginx/html/*
COPY dist /usr/share/nginx/html
#CMD ["nginx", "-g", "daemon off;"]

View File

@@ -0,0 +1,17 @@
#MaxKey mgmt server
server {
listen 9524;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}

View File

@@ -1,19 +1,18 @@
/*
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
HttpErrorResponse,

View File

@@ -35,7 +35,7 @@ import { LayoutDefaultOptions } from '../../theme/layout-default';
<layout-default [options]="options" [asideUser]="asideUserTpl" [content]="contentTpl" [customError]="null">
<layout-default-header-item direction="left">
<a href="#">
<img src="../assets/logo.jpg" alt="logo" style="height: 50px;height: 50px;float: left;" />
<img src="./assets/logo.jpg" alt="logo" style="height: 50px;height: 50px;float: left;" />
<div
class="alain-default__nav-item_title"
style="letter-spacing: 2px;

View File

@@ -1,19 +1,18 @@
/*
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
@@ -28,7 +27,7 @@ import { SettingsService } from '@delon/theme';
export class CallbackComponent implements OnInit {
type = '';
constructor(private socialService: SocialService, private settingsSrv: SettingsService, private route: ActivatedRoute) {}
constructor(private socialService: SocialService, private settingsSrv: SettingsService, private route: ActivatedRoute) { }
ngOnInit(): void {
this.type = this.route.snapshot.params['type'];

View File

@@ -0,0 +1,56 @@
/*
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Component, OnInit, Inject } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { ReuseTabService } from '@delon/abc/reuse-tab';
import { DA_SERVICE_TOKEN, ITokenService } from '@delon/auth';
import { SettingsService } from '@delon/theme';
import { AuthenticationService } from '../../service/authentication.service';
@Component({
selector: 'app-jwt-auth',
template: ``
})
export class JwtAuthComponent implements OnInit {
jwt = '';
constructor(
private authenticationService: AuthenticationService,
@Inject(ReuseTabService)
private reuseTabService: ReuseTabService,
private router: Router,
private settingsSrv: SettingsService,
private route: ActivatedRoute
) { }
ngOnInit(): void {
this.jwt = this.route.snapshot.queryParams['jwt'];
this.authenticationService.jwtAuth({ jwt: this.jwt }).subscribe(res => {
if (res.code !== 0) {
this.router.navigateByUrl('/passport/login');
} else {
// 清空路由复用信息
this.reuseTabService.clear();
// 设置用户Token信息
this.authenticationService.auth(res.data);
this.authenticationService.navigate({});
}
});
}
}

View File

@@ -1,19 +1,18 @@
/*
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit, Inject, OnDestroy, Optional } from '@angular/core';
import { AbstractControl, FormBuilder, FormGroup, Validators } from '@angular/forms';

View File

@@ -1,25 +1,25 @@
/*
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { LayoutPassportComponent } from '../../layout/passport/passport.component';
import { CallbackComponent } from './callback.component';
import { JwtAuthComponent } from './jwt-auth.component';
import { UserLockComponent } from './lock/lock.component';
import { UserLoginComponent } from './login/login.component';
import { UserRegisterResultComponent } from './register-result/register-result.component';
@@ -54,11 +54,11 @@ const routes: Routes = [
]
},
// 单页不包裹Layout
{ path: 'passport/callback/:type', component: CallbackComponent }
{ path: 'passport/jwt/auth', component: JwtAuthComponent }
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class PassportRoutingModule {}
export class PassportRoutingModule { }

View File

@@ -1,19 +1,18 @@
/*
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { NgModule } from '@angular/core';
import { SharedModule } from '@shared';
@@ -31,4 +30,4 @@ const COMPONENTS = [UserLoginComponent, UserRegisterResultComponent, UserRegiste
imports: [SharedModule, PassportRoutingModule],
declarations: [...COMPONENTS]
})
export class PassportModule {}
export class PassportModule { }

View File

@@ -1,19 +1,18 @@
/*
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Injectable, Inject } from '@angular/core';
import { Router } from '@angular/router';
@@ -62,6 +61,10 @@ export class AuthenticationService {
return this.http.post('/login/congress?_allow_anonymous=true', authParam);
}
jwtAuth(authParam: any) {
return this.http.get(`/login/jwt?_allow_anonymous=true`, authParam);
}
clear() {
this.tokenService.clear();
}

View File

@@ -1,19 +1,18 @@
/*
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Environment } from '@delon/theme';
@@ -21,8 +20,8 @@ export const environment = {
production: true,
useHash: true,
api: {
baseUrl: './',
baseUrl: '/maxkey-mgt-api',
refreshTokenEnabled: true,
refreshTokenType: 'auth-refresh'
refreshTokenType: 're-request'
}
} as Environment;

View File

@@ -1,19 +1,18 @@
/*
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// This file can be replaced during build by using the `fileReplacements` array.
// `ng build ---prod` replaces `environment.ts` with `environment.prod.ts`.
@@ -28,7 +27,7 @@ export const environment = {
production: false,
useHash: true,
api: {
baseUrl: 'http://sso.maxkey.top:9527/maxkey-mgt/',
baseUrl: 'http://sso.maxkey.top:9526/maxkey-mgt-api/',
refreshTokenEnabled: true,
refreshTokenType: 're-request'
},