Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yujianwangzivayy
MaxKey
提交
36ea37af
MaxKey
项目概览
yujianwangzivayy
/
MaxKey
与 Fork 源项目一致
Fork自
MaxKey单点登录官方(MaxKeyTop) / MaxKey
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
MaxKey
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
36ea37af
编写于
5月 15, 2022
作者:
M
MaxKey
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
jwt login support
上级
f1f41fe7
变更
20
隐藏空白更改
内联
并排
Showing
20 changed file
with
181 addition
and
68 deletion
+181
-68
maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/jwt/AuthJwtService.java
...re/src/main/java/org/maxkey/authn/jwt/AuthJwtService.java
+3
-2
maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/support/jwt/HttpJwtEntryPoint.java
.../java/org/maxkey/authn/support/jwt/HttpJwtEntryPoint.java
+27
-1
maxkey-web-frontend/maxkey-web-app/src/app/routes/passport/jwt-auth.component.ts
...key-web-app/src/app/routes/passport/jwt-auth.component.ts
+56
-0
maxkey-web-frontend/maxkey-web-app/src/app/routes/passport/passport-routing.module.ts
...eb-app/src/app/routes/passport/passport-routing.module.ts
+6
-5
maxkey-web-frontend/maxkey-web-app/src/app/service/authn.service.ts
...-frontend/maxkey-web-app/src/app/service/authn.service.ts
+12
-0
maxkey-web-frontend/maxkey-web-app/src/app/shared/consts.ts
maxkey-web-frontend/maxkey-web-app/src/app/shared/consts.ts
+1
-0
maxkey-web-frontend/maxkey-web-mgt-app/src/app/layout/passport/passport.component.html
...b-mgt-app/src/app/layout/passport/passport.component.html
+12
-5
maxkey-web-frontend/maxkey-web-mgt-app/src/app/layout/passport/passport.component.ts
...web-mgt-app/src/app/layout/passport/passport.component.ts
+17
-5
maxkey-web-frontend/maxkey-web-mgt-app/src/app/routes/apps/app-basic-details-editer/app-basic-details-editer.component.ts
...asic-details-editer/app-basic-details-editer.component.ts
+3
-4
maxkey-web-frontend/maxkey-web-mgt-app/src/app/routes/apps/app-cas-details-editer/app-cas-details-editer.component.ts
...pp-cas-details-editer/app-cas-details-editer.component.ts
+3
-4
maxkey-web-frontend/maxkey-web-mgt-app/src/app/routes/apps/app-extend-api-details-editer/app-extend-api-details-editer.component.ts
...details-editer/app-extend-api-details-editer.component.ts
+3
-4
maxkey-web-frontend/maxkey-web-mgt-app/src/app/routes/apps/app-form-based-details-editer/app-form-based-details-editer.component.ts
...details-editer/app-form-based-details-editer.component.ts
+3
-4
maxkey-web-frontend/maxkey-web-mgt-app/src/app/routes/apps/app-jwt-details-editer/app-jwt-details-editer.component.ts
...pp-jwt-details-editer/app-jwt-details-editer.component.ts
+3
-4
maxkey-web-frontend/maxkey-web-mgt-app/src/app/routes/apps/app-oauth20-details-editer/app-oauth20-details-editer.component.ts
...20-details-editer/app-oauth20-details-editer.component.ts
+3
-4
maxkey-web-frontend/maxkey-web-mgt-app/src/app/routes/apps/app-saml20-details-editer/app-saml20-details-editer.component.ts
...l20-details-editer/app-saml20-details-editer.component.ts
+3
-4
maxkey-web-frontend/maxkey-web-mgt-app/src/app/routes/apps/app-token-based-details-editer/app-token-based-details-editer.component.ts
...etails-editer/app-token-based-details-editer.component.ts
+3
-4
maxkey-web-frontend/maxkey-web-mgt-app/src/app/routes/passport/jwt-auth.component.ts
...web-mgt-app/src/app/routes/passport/jwt-auth.component.ts
+5
-5
maxkey-web-frontend/maxkey-web-mgt-app/src/app/routes/passport/login/login.component.ts
...-mgt-app/src/app/routes/passport/login/login.component.ts
+8
-12
maxkey-web-frontend/maxkey-web-mgt-app/src/app/service/authn.service.ts
...ntend/maxkey-web-mgt-app/src/app/service/authn.service.ts
+9
-1
maxkey-web-frontend/maxkey-web-mgt-app/src/app/shared/consts.ts
...-web-frontend/maxkey-web-mgt-app/src/app/shared/consts.ts
+1
-0
未找到文件。
maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/jwt/AuthJwtService.java
浏览文件 @
36ea37af
...
...
@@ -124,8 +124,9 @@ public class AuthJwtService {
JWTClaimsSet
claims
=
resolve
(
authToken
);
boolean
isExpiration
=
claims
.
getExpirationTime
().
after
(
DateTime
.
now
().
toDate
());
boolean
isVerify
=
hmac512Service
.
verify
(
authToken
);
_logger
.
trace
(
"JWT Verify {} , now {} , ExpirationTime {} , isExpiration : {}"
,
isVerify
,
DateTime
.
now
().
toDate
(),
claims
.
getExpirationTime
(),
isExpiration
);
_logger
.
debug
(
"JWT Validate {} , Verify {} , now {} , ExpirationTime {} , isExpiration : {}"
,
isVerify
&&
isExpiration
,
isVerify
,
DateTime
.
now
().
toDate
(),
claims
.
getExpirationTime
(),
isExpiration
);
return
isVerify
&&
isExpiration
;
}
}
catch
(
ParseException
e
)
{
...
...
maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/support/jwt/HttpJwtEntryPoint.java
浏览文件 @
36ea37af
...
...
@@ -54,7 +54,7 @@ public class HttpJwtEntryPoint {
JwtLoginService
jwtLoginService
;
@RequestMapping
(
value
={
"/jwt"
},
produces
=
{
MediaType
.
APPLICATION_JSON_VALUE
})
public
ResponseEntity
<?>
jwt
(
@RequestParam
(
value
=
WebConstants
.
JWT_TOKEN_PARAMETER
,
required
=
fals
e
)
String
jwt
)
{
public
ResponseEntity
<?>
jwt
(
@RequestParam
(
value
=
WebConstants
.
JWT_TOKEN_PARAMETER
,
required
=
tru
e
)
String
jwt
)
{
try
{
//for jwt Login
_logger
.
debug
(
"jwt : "
+
jwt
);
...
...
@@ -75,6 +75,32 @@ public class HttpJwtEntryPoint {
return
new
Message
<
AuthJwt
>(
Message
.
FAIL
).
buildResponse
();
}
/**
* trust same HS512
* @param jwt
* @return
*/
@RequestMapping
(
value
={
"/jwt/trust"
},
produces
=
{
MediaType
.
APPLICATION_JSON_VALUE
})
public
ResponseEntity
<?>
jwtTrust
(
@RequestParam
(
value
=
WebConstants
.
JWT_TOKEN_PARAMETER
,
required
=
true
)
String
jwt
)
{
try
{
//for jwt Login
_logger
.
debug
(
"jwt : "
+
jwt
);
if
(
authTokenService
.
validateJwtToken
(
jwt
))
{
String
username
=
authTokenService
.
resolve
(
jwt
).
getSubject
();
LoginCredential
loginCredential
=
new
LoginCredential
(
username
,
""
,
ConstsLoginType
.
JWT
);
Authentication
authentication
=
authenticationProvider
.
authenticate
(
loginCredential
,
true
);
_logger
.
debug
(
"JWT Logined in , username "
+
username
);
AuthJwt
authJwt
=
authTokenService
.
genAuthJwt
(
authentication
);
return
new
Message
<
AuthJwt
>(
authJwt
).
buildResponse
();
}
}
catch
(
Exception
e
)
{
_logger
.
error
(
"Exception "
,
e
);
}
return
new
Message
<
AuthJwt
>(
Message
.
FAIL
).
buildResponse
();
}
public
void
setApplicationConfig
(
ApplicationConfig
applicationConfig
)
{
...
...
maxkey-web-frontend/maxkey-web-app/src/app/routes/passport/jwt-auth.component.ts
0 → 100644
浏览文件 @
36ea37af
/*
* 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
{
AuthnService
}
from
'
../../service/authn.service
'
;
@
Component
({
selector
:
'
app-jwt-auth
'
,
template
:
``
})
export
class
JwtAuthComponent
implements
OnInit
{
jwt
=
''
;
constructor
(
private
authnService
:
AuthnService
,
@
Inject
(
ReuseTabService
)
private
reuseTabService
:
ReuseTabService
,
private
router
:
Router
,
private
settingsSrv
:
SettingsService
,
private
route
:
ActivatedRoute
)
{
}
ngOnInit
():
void
{
this
.
jwt
=
this
.
route
.
snapshot
.
queryParams
[
'
jwt
'
];
this
.
authnService
.
jwtAuth
({
jwt
:
this
.
jwt
}).
subscribe
(
res
=>
{
if
(
res
.
code
!==
0
)
{
this
.
router
.
navigateByUrl
(
'
/passport/login
'
);
}
else
{
// 清空路由复用信息
this
.
reuseTabService
.
clear
();
// 设置用户Token信息
this
.
authnService
.
auth
(
res
.
data
);
this
.
authnService
.
navigate
({});
}
});
}
}
maxkey-web-frontend/maxkey-web-app/src/app/routes/passport/passport-routing.module.ts
浏览文件 @
36ea37af
/*
* 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
'
;
...
...
@@ -21,6 +20,7 @@ import { RouterModule, Routes } from '@angular/router';
import
{
LayoutPassportComponent
}
from
'
../../layout/passport/passport.component
'
;
import
{
CallbackComponent
}
from
'
./callback.component
'
;
import
{
ForgotComponent
}
from
'
./forgot/forgot.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
'
;
...
...
@@ -60,7 +60,8 @@ const routes: Routes = [
]
},
// 单页不包裹Layout
{
path
:
'
passport/callback/:provider
'
,
component
:
CallbackComponent
}
{
path
:
'
passport/callback/:provider
'
,
component
:
CallbackComponent
},
{
path
:
'
passport/jwt/auth
'
,
component
:
JwtAuthComponent
}
];
@
NgModule
({
...
...
maxkey-web-frontend/maxkey-web-app/src/app/service/authn.service.ts
浏览文件 @
36ea37af
...
...
@@ -100,6 +100,18 @@ export class AuthnService {
this
.
tokenService
.
get
()?.
expired
;
}
jwtAuth
(
authParam
:
any
)
{
return
this
.
http
.
get
(
`/login/jwt/trust?_allow_anonymous=true`
,
authParam
);
}
setInst
(
inst
:
any
)
{
localStorage
.
setItem
(
CONSTS
.
INST
,
JSON
.
stringify
({
id
:
inst
.
id
,
name
:
inst
.
name
,
title
:
inst
.
frontTitle
,
logo
:
inst
.
logo
}));
}
getInst
()
{
return
JSON
.
parse
(
`
${
localStorage
.
getItem
(
CONSTS
.
INST
)}
`
);
}
setRoles
(
aclService
:
ACLService
|
null
):
string
[]
{
let
authorities
:
string
[]
=
JSON
.
parse
(
localStorage
.
getItem
(
CONSTS
.
TOKEN
)
||
''
)?.
authorities
||
[];
if
(
aclService
)
{
...
...
maxkey-web-frontend/maxkey-web-app/src/app/shared/consts.ts
浏览文件 @
36ea37af
...
...
@@ -15,6 +15,7 @@
*/
export
const
CONSTS
=
{
INST
:
'
inst
'
,
CONGRESS
:
'
congress
'
,
ONLINE_TICKET
:
'
online_ticket
'
,
REDIRECT_URI
:
'
redirect_uri
'
,
...
...
maxkey-web-frontend/maxkey-web-mgt-app/src/app/layout/passport/passport.component.html
浏览文件 @
36ea37af
<div
class=
"container"
>
<div
nz-row
style=
"border-bottom: 1px solid #e5e5e5; min-height: 60px; text-shadow: 0 1px 0 #fff"
>
<div
nz-col
nzMd=
"2"
></div>
<div
nz-col
nzMd=
"2"
style=
"text-align: right"
>
<img
style=
"margin-top: 6px"
class=
"logo"
src=
"./assets/logo.jpg"
/></div>
<div
nz-col
nzMd=
"2"
style=
"text-align: right"
>
<img
*ngIf=
"!isTitle"
style=
"margin-top: 6px"
class=
"logo"
src=
"./assets/logo.jpg"
/>
<img
*ngIf=
"isTitle"
style=
"margin-top: 6px"
class=
"logo"
src=
"{{ inst.logo }}"
/>
</div>
<div
nz-col
nzMd=
"10"
>
<div
class=
"title"
>
{{ 'mxk.login.title' | i18n }}{{ 'mxk.title' | i18n }}
</div>
<div
*ngIf=
"!isTitle"
class=
"title"
>
Max
<span
style=
"color: #ffd700"
>
Key
</span>
{{ 'mxk.title' | i18n }}
</div>
<div
*ngIf=
"isTitle"
class=
"title"
>
{{ inst.title }}
</div>
</div>
<div
nz-col
nzMd=
"6"
></div>
<div
nz-col
nzXs=
"0"
nzSm=
"0"
nzMd=
"2"
><header-i18n
showLangText=
"false"
class=
"langs"
></header-i18n></div>
<div
nz-col
nzXs=
"0"
nzSm=
"0"
nzMd=
"2"
>
<header-i18n
showLangText=
"false"
class=
"langs"
></header-i18n>
</div>
<div
nz-col
nzMd=
"2"
></div>
</div>
...
...
@@ -19,10 +25,11 @@
<div
style=
"margin-top: 20px"
>
MaxKey {{ version }}
<br
/>
Copyright
<i
nz-icon
nzType=
"copyright"
></i>
2022
<a
href=
"//www.maxkey.top"
target=
"_blank"
>
http://www.maxkey.top
</a><br
/>
<i
nz-icon
nzType=
"copyright"
></i>
2022
<a
href=
"//www.maxkey.top"
target=
"_blank"
>
http://www.maxkey.top
</a><br
/>
Licensed under the Apache License, Version 2.0
</div>
</global-footer>
</div>
</div>
<theme-btn></theme-btn>
<theme-btn></theme-btn>
\ No newline at end of file
maxkey-web-frontend/maxkey-web-mgt-app/src/app/layout/passport/passport.component.ts
浏览文件 @
36ea37af
/*
* 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
,
Inject
,
OnInit
}
from
'
@angular/core
'
;
import
{
DA_SERVICE_TOKEN
,
ITokenService
}
from
'
@delon/auth
'
;
import
{
AuthnService
}
from
'
src/app/service/authn.service
'
;
import
{
CONSTS
}
from
'
src/app/shared/consts
'
;
@
Component
({
...
...
@@ -26,6 +26,8 @@ import { CONSTS } from 'src/app/shared/consts';
})
export
class
LayoutPassportComponent
implements
OnInit
{
version
=
CONSTS
.
VERSION
;
isTitle
:
boolean
=
false
;
inst
:
any
;
links
=
[
{
title
:
'
帮助
'
,
...
...
@@ -37,9 +39,19 @@ export class LayoutPassportComponent implements OnInit {
}
];
constructor
(@
Inject
(
DA_SERVICE_TOKEN
)
private
tokenService
:
ITokenService
)
{
}
constructor
(@
Inject
(
DA_SERVICE_TOKEN
)
private
tokenService
:
ITokenService
,
private
authnService
:
AuthnService
)
{
}
ngOnInit
():
void
{
if
(
window
.
location
.
hostname
!=
'
localhost
'
&&
window
.
location
.
hostname
!=
'
sso.maxkey.top
'
&&
window
.
location
.
hostname
!=
'
mgt.maxkey.top
'
)
{
this
.
inst
=
this
.
authnService
.
getInst
();
if
(
this
.
inst
!=
null
)
{
this
.
isTitle
=
true
;
}
}
this
.
tokenService
.
clear
();
}
}
maxkey-web-frontend/maxkey-web-mgt-app/src/app/routes/apps/app-basic-details-editer/app-basic-details-editer.component.ts
浏览文件 @
36ea37af
/*
* 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
,
ChangeDetectorRef
,
ViewContainerRef
,
Input
,
OnInit
}
from
'
@angular/core
'
;
import
{
FormBuilder
,
FormGroup
,
Validators
}
from
'
@angular/forms
'
;
...
...
maxkey-web-frontend/maxkey-web-mgt-app/src/app/routes/apps/app-cas-details-editer/app-cas-details-editer.component.ts
浏览文件 @
36ea37af
/*
* 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
,
ChangeDetectorRef
,
ViewContainerRef
,
Input
,
OnInit
}
from
'
@angular/core
'
;
import
{
FormBuilder
,
FormGroup
,
Validators
}
from
'
@angular/forms
'
;
...
...
maxkey-web-frontend/maxkey-web-mgt-app/src/app/routes/apps/app-extend-api-details-editer/app-extend-api-details-editer.component.ts
浏览文件 @
36ea37af
/*
* 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
,
ChangeDetectorRef
,
ViewContainerRef
,
Input
,
OnInit
}
from
'
@angular/core
'
;
import
{
FormBuilder
,
FormGroup
,
Validators
}
from
'
@angular/forms
'
;
...
...
maxkey-web-frontend/maxkey-web-mgt-app/src/app/routes/apps/app-form-based-details-editer/app-form-based-details-editer.component.ts
浏览文件 @
36ea37af
/*
* 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
,
ChangeDetectorRef
,
ViewContainerRef
,
Input
,
OnInit
}
from
'
@angular/core
'
;
import
{
FormBuilder
,
FormGroup
,
Validators
}
from
'
@angular/forms
'
;
...
...
maxkey-web-frontend/maxkey-web-mgt-app/src/app/routes/apps/app-jwt-details-editer/app-jwt-details-editer.component.ts
浏览文件 @
36ea37af
/*
* 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
,
ChangeDetectorRef
,
ViewContainerRef
,
Input
,
OnInit
}
from
'
@angular/core
'
;
import
{
FormBuilder
,
FormGroup
,
Validators
}
from
'
@angular/forms
'
;
...
...
maxkey-web-frontend/maxkey-web-mgt-app/src/app/routes/apps/app-oauth20-details-editer/app-oauth20-details-editer.component.ts
浏览文件 @
36ea37af
/*
* 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
,
ChangeDetectorRef
,
ViewContainerRef
,
Input
,
OnInit
}
from
'
@angular/core
'
;
import
{
FormBuilder
,
FormGroup
,
Validators
}
from
'
@angular/forms
'
;
...
...
maxkey-web-frontend/maxkey-web-mgt-app/src/app/routes/apps/app-saml20-details-editer/app-saml20-details-editer.component.ts
浏览文件 @
36ea37af
/*
* 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
,
ChangeDetectorRef
,
ViewContainerRef
,
Input
,
OnInit
}
from
'
@angular/core
'
;
import
{
FormBuilder
,
FormGroup
,
Validators
}
from
'
@angular/forms
'
;
...
...
maxkey-web-frontend/maxkey-web-mgt-app/src/app/routes/apps/app-token-based-details-editer/app-token-based-details-editer.component.ts
浏览文件 @
36ea37af
/*
* 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
,
ChangeDetectorRef
,
ViewContainerRef
,
Input
,
OnInit
}
from
'
@angular/core
'
;
import
{
FormBuilder
,
FormGroup
,
Validators
}
from
'
@angular/forms
'
;
...
...
maxkey-web-frontend/maxkey-web-mgt-app/src/app/routes/passport/jwt-auth.component.ts
浏览文件 @
36ea37af
...
...
@@ -20,7 +20,7 @@ import { ReuseTabService } from '@delon/abc/reuse-tab';
import
{
DA_SERVICE_TOKEN
,
ITokenService
}
from
'
@delon/auth
'
;
import
{
SettingsService
}
from
'
@delon/theme
'
;
import
{
Auth
enticationService
}
from
'
../../service/authenticatio
n.service
'
;
import
{
Auth
nService
}
from
'
../../service/auth
n.service
'
;
@
Component
({
selector
:
'
app-jwt-auth
'
,
...
...
@@ -30,7 +30,7 @@ export class JwtAuthComponent implements OnInit {
jwt
=
''
;
constructor
(
private
auth
enticationService
:
Authenticatio
nService
,
private
auth
nService
:
Auth
nService
,
@
Inject
(
ReuseTabService
)
private
reuseTabService
:
ReuseTabService
,
private
router
:
Router
,
...
...
@@ -41,15 +41,15 @@ export class JwtAuthComponent implements OnInit {
ngOnInit
():
void
{
this
.
jwt
=
this
.
route
.
snapshot
.
queryParams
[
'
jwt
'
];
this
.
auth
enticatio
nService
.
jwtAuth
({
jwt
:
this
.
jwt
}).
subscribe
(
res
=>
{
this
.
authnService
.
jwtAuth
({
jwt
:
this
.
jwt
}).
subscribe
(
res
=>
{
if
(
res
.
code
!==
0
)
{
this
.
router
.
navigateByUrl
(
'
/passport/login
'
);
}
else
{
// 清空路由复用信息
this
.
reuseTabService
.
clear
();
// 设置用户Token信息
this
.
auth
enticatio
nService
.
auth
(
res
.
data
);
this
.
auth
enticatio
nService
.
navigate
({});
this
.
authnService
.
auth
(
res
.
data
);
this
.
authnService
.
navigate
({});
}
});
}
...
...
maxkey-web-frontend/maxkey-web-mgt-app/src/app/routes/passport/login/login.component.ts
浏览文件 @
36ea37af
...
...
@@ -25,7 +25,7 @@ import { environment } from '@env/environment';
import
{
NzTabChangeEvent
}
from
'
ng-zorro-antd/tabs
'
;
import
{
finalize
}
from
'
rxjs/operators
'
;
import
{
Auth
enticationService
}
from
'
../../../service/authenticatio
n.service
'
;
import
{
Auth
nService
}
from
'
../../../service/auth
n.service
'
;
import
{
ImageCaptchaService
}
from
'
../../../service/image-captcha.service
'
;
@
Component
({
...
...
@@ -37,16 +37,11 @@ import { ImageCaptchaService } from '../../../service/image-captcha.service';
export
class
UserLoginComponent
implements
OnInit
,
OnDestroy
{
constructor
(
fb
:
FormBuilder
,
private
router
:
Router
,
private
settingsService
:
SettingsService
,
@
Optional
()
@
Inject
(
ReuseTabService
)
private
reuseTabService
:
ReuseTabService
,
@
Inject
(
DA_SERVICE_TOKEN
)
private
tokenService
:
ITokenService
,
private
startupSrv
:
StartupService
,
private
authenticationService
:
AuthenticationService
,
private
authnService
:
AuthnService
,
private
imageCaptchaService
:
ImageCaptchaService
,
private
http
:
_HttpClient
,
private
cdr
:
ChangeDetectorRef
)
{
this
.
form
=
fb
.
group
({
...
...
@@ -84,8 +79,8 @@ export class UserLoginComponent implements OnInit, OnDestroy {
ngOnInit
():
void
{
//init socials,state
this
.
auth
enticatio
nService
.
clear
();
this
.
auth
enticatio
nService
this
.
authnService
.
clear
();
this
.
authnService
.
get
({})
.
pipe
(
finalize
(()
=>
{
...
...
@@ -100,6 +95,7 @@ export class UserLoginComponent implements OnInit, OnDestroy {
}
else
{
// 清空路由复用信息
console
.
log
(
res
.
data
);
this
.
authnService
.
setInst
(
res
.
data
.
inst
);
this
.
state
=
res
.
data
.
state
;
//init image captcha
this
.
imageCaptchaService
.
captcha
({
state
:
this
.
state
}).
subscribe
(
res
=>
{
...
...
@@ -149,7 +145,7 @@ export class UserLoginComponent implements OnInit, OnDestroy {
// 然一般来说登录请求不需要校验,因此可以在请求URL加上:`/login?_allow_anonymous=true` 表示不触发用户 Token 校验
this
.
loading
=
true
;
this
.
cdr
.
detectChanges
();
this
.
auth
enticatio
nService
this
.
authnService
.
login
({
authType
:
'
normal
'
,
state
:
this
.
state
,
...
...
@@ -174,8 +170,8 @@ export class UserLoginComponent implements OnInit, OnDestroy {
// 清空路由复用信息
this
.
reuseTabService
.
clear
();
// 设置用户Token信息
this
.
auth
enticatio
nService
.
auth
(
res
.
data
);
this
.
auth
enticatio
nService
.
navigate
({});
this
.
authnService
.
auth
(
res
.
data
);
this
.
authnService
.
navigate
({});
}
this
.
cdr
.
detectChanges
();
});
...
...
maxkey-web-frontend/maxkey-web-mgt-app/src/app/service/auth
enticatio
n.service.ts
→
maxkey-web-frontend/maxkey-web-mgt-app/src/app/service/authn.service.ts
浏览文件 @
36ea37af
...
...
@@ -28,7 +28,7 @@ import { hostname } from 'os';
@
Injectable
({
providedIn
:
'
root
'
})
export
class
Auth
enticatio
nService
{
export
class
AuthnService
{
redirect_uri
:
string
=
''
;
constructor
(
...
...
@@ -94,6 +94,14 @@ export class AuthenticationService {
this
.
tokenService
.
get
()?.
expired
;
}
setInst
(
inst
:
any
)
{
localStorage
.
setItem
(
CONSTS
.
INST
,
JSON
.
stringify
({
id
:
inst
.
id
,
name
:
inst
.
name
,
title
:
inst
.
consoleTitle
,
logo
:
inst
.
logo
}));
}
getInst
()
{
return
JSON
.
parse
(
`
${
localStorage
.
getItem
(
CONSTS
.
INST
)}
`
);
}
navigate
(
authJwt
:
any
)
{
// 重新获取 StartupService 内容,我们始终认为应用信息一般都会受当前用户授权范围而影响
this
.
startupService
.
load
().
subscribe
(()
=>
{
...
...
maxkey-web-frontend/maxkey-web-mgt-app/src/app/shared/consts.ts
浏览文件 @
36ea37af
...
...
@@ -16,6 +16,7 @@
export
const
CONSTS
=
{
CONGRESS
:
'
congress
'
,
INST
:
'
inst
'
,
REDIRECT_URI
:
'
redirect_uri
'
,
REMEMBER
:
'
remember
'
,
VERSION
:
'
v3.5.0 GA
'
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录