[Feature] Add SSO login by Casdoor (#8706)
This commit is contained in:
parent
0a02522420
commit
77e58ce245
|
|
@ -1,6 +1,6 @@
|
|||
# Authentication Type
|
||||
|
||||
* So far we support two authentication types, Apache DolphinScheduler password and LDAP.
|
||||
* So far we support three authentication types, Apache DolphinScheduler password, LDAP and Casdoor SSO.
|
||||
|
||||
## Change Authentication Type
|
||||
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
```yaml
|
||||
security:
|
||||
authentication:
|
||||
# Authentication types (supported types: PASSWORD,LDAP)
|
||||
# Authentication types (supported types: PASSWORD,LDAP,CASDOOR_SSO)
|
||||
type: PASSWORD
|
||||
# IF you set type `LDAP`, below config will be effective
|
||||
ldap:
|
||||
|
|
@ -40,3 +40,57 @@ You can follow guide below:
|
|||
- Change userId && userPwd to your information in the `ldapLogin` method.
|
||||
- Change the expected email to the return value you expect in the `ldapLogin` method.
|
||||
- Run`ldapLogin`method and determine whether the LDAP login result is expected.
|
||||
|
||||
## Casdoor SSO
|
||||
|
||||
[Casdoor](https://casdoor.org/) is a UI-first Identity Access Management (IAM) / Single-Sign-On (SSO) platform based on OAuth 2.0, OIDC, SAML and CAS. You can add SSO capability to Dolphinscheduler through Casdoor by following these steps:
|
||||
|
||||
### Step1. Deploy Casdoor
|
||||
|
||||
Firstly, the Casdoor should be deployed.
|
||||
|
||||
You can refer to the Casdoor official documentation for the [Server Installation](https://casdoor.org/docs/basic/server-installation).
|
||||
|
||||
After a successful deployment, you need to ensure:
|
||||
|
||||
* The Casdoor server is successfully running on http://localhost:8000.
|
||||
* Open your favorite browser and visit http://localhost:7001, you will see the login page of Casdoor.
|
||||
* Input admin and 123 to test login functionality is working fine.
|
||||
|
||||
Then you can quickly implement a Casdoor based login page in your own app with the following steps.
|
||||
|
||||
### Step2. Configure Casdoor Application
|
||||
|
||||
1. Create or use an existing Casdoor application.
|
||||
2. Add Your redirect url (You can see more details about how to get redirect url in the next section)
|
||||

|
||||
3. Add provider you want and supplement other settings.
|
||||
|
||||
Not surprisingly, you can get two values on the application settings page: `Client ID` and `Client secret` like the picture above. We will use them in next step.
|
||||
|
||||
Open your favorite browser and visit: **http://`CASDOOR_HOSTNAME`/.well-known/openid-configuration**, you will see the OIDC configure of Casdoor.
|
||||
|
||||
### Step3. Configure Dolphinscheduler
|
||||
|
||||
> dolphinscheduler-api/src/main/resources/application.yaml
|
||||
|
||||
```yaml
|
||||
security:
|
||||
authentication:
|
||||
# Authentication types (supported types: PASSWORD,LDAP,CASDOOR_SSO)
|
||||
type: CASDOOR_SSO
|
||||
casdoor:
|
||||
# Your Casdoor server url
|
||||
endpoint:
|
||||
client-id:
|
||||
client-secret:
|
||||
# The certificate may be multi-line, you can use `|-` for ease
|
||||
certificate:
|
||||
# Your organization name added in Casdoor
|
||||
organization-name:
|
||||
# Your application name added in Casdoor
|
||||
application-name:
|
||||
# Doplhinscheduler login url
|
||||
redirect-url: http://localhost:5173/login
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# 认证方式
|
||||
|
||||
* 目前我们支持两种认证方式,Apache DolphinScheduler自身账号密码登录和LDAP。
|
||||
* 目前我们支持三种认证方式,Apache DolphinScheduler自身账号密码登录,LDAP和通过Casdoor实现的SSO登录。
|
||||
|
||||
## 修改认证方式
|
||||
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
```yaml
|
||||
security:
|
||||
authentication:
|
||||
# Authentication types (supported types: PASSWORD,LDAP)
|
||||
# Authentication types (supported types: PASSWORD,LDAP,CASDOOR_SSO)
|
||||
type: PASSWORD
|
||||
# IF you set type `LDAP`, below config will be effective
|
||||
ldap:
|
||||
|
|
@ -40,3 +40,53 @@ security:
|
|||
- 修改`ldapLogin`方法中的userId和userPwd为你的账号密码;
|
||||
- 修改`ldapLogin`方法中的expected email为正常登陆的返回值;
|
||||
- 执行`ldapLogin`方法,判断LDAP登陆结果是否为预期;
|
||||
|
||||
## 通过 Casdoor 实现 SSO 登录
|
||||
|
||||
Casdoor 是基于 OAuth 2.0、OIDC、SAML 和 CAS 的面向 UI 的身份访问管理(IAM)/单点登录(SSO)平台。您可以通过以下步骤通过 Casdoor 为 Dolphinscheduler 添加 SSO 功能:
|
||||
|
||||
### 步骤1. 部署 Casdoor
|
||||
|
||||
首先,需要部署 Casdoor。 您可以参考 Casdoor 官方文档进行[安装](https://casdoor.org/docs/basic/server-installation)。 成功部署后,您需要确保:
|
||||
|
||||
* Casdoor 服务器在 http://localhost:8000 上成功运行。
|
||||
* 打开您喜欢的浏览器并访问 http://localhost:7001,您将看到 Casdoor 的登录页面。
|
||||
* 输入 admin 和 123,测试登录功能是否正常工作。
|
||||
|
||||
然后,您可以通过以下步骤在自己的应用程序中快速实现基于 Casdoor 的登录页面。
|
||||
|
||||
### 步骤2. 配置 Casdoor
|
||||
|
||||
1. 创建或使用现有的 Casdoor 应用程序。
|
||||
2. 添加您的重定向 URL(您可以在下一节中了解更多关于如何获取重定向 URL 的详细信息)
|
||||

|
||||
3. 添加您想要的提供程序并补充其他设置。
|
||||
|
||||
不出所料,您可以在应用程序设置页面上获得两个值:`Client ID` 和 `Client secret`,如上图所示。我们将在下一步中使用它们。
|
||||
|
||||
打开您喜欢的浏览器并访问:**http://`CASDOOR_HOSTNAME`/.well-known/openid-configuration**,您将看到 Casdoor 的 OIDC 配置。
|
||||
|
||||
### 步骤3. 配置 Dolphinscheduler
|
||||
|
||||
> dolphinscheduler-api/src/main/resources/application.yaml
|
||||
|
||||
```yaml
|
||||
security:
|
||||
authentication:
|
||||
# Authentication types (supported types: PASSWORD,LDAP,CASDOOR_SSO)
|
||||
type: CASDOOR_SSO
|
||||
casdoor:
|
||||
# Your Casdoor server url
|
||||
endpoint:
|
||||
client-id:
|
||||
client-secret:
|
||||
# The certificate may be multi-line, you can use `|-` for ease
|
||||
certificate:
|
||||
# Your organization name added in Casdoor
|
||||
organization-name:
|
||||
# Your application name added in Casdoor
|
||||
application-name:
|
||||
# Doplhinscheduler login url
|
||||
redirect-url: http://localhost:5173/login
|
||||
```
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 52 KiB |
|
|
@ -194,6 +194,11 @@
|
|||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.casbin</groupId>
|
||||
<artifactId>casdoor-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springdoc</groupId>
|
||||
<artifactId>springdoc-openapi-ui</artifactId>
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ import org.springframework.web.servlet.i18n.CookieLocaleResolver;
|
|||
public class AppConfiguration implements WebMvcConfigurer {
|
||||
|
||||
public static final String LOGIN_INTERCEPTOR_PATH_PATTERN = "/**/*";
|
||||
public static final String LOGIN_PATH_PATTERN = "/login";
|
||||
public static final String LOGIN_PATH_PATTERN = "/login/**";
|
||||
public static final String REGISTER_PATH_PATTERN = "/users/register";
|
||||
public static final String PATH_PATTERN = "/**";
|
||||
public static final String LOCALE_LANGUAGE_COOKIE = "language";
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
package org.apache.dolphinscheduler.api.controller;
|
||||
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.IP_IS_EMPTY;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.NOT_SUPPORT_SSO;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.SIGN_OUT_ERROR;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.USER_LOGIN_FAILURE;
|
||||
|
||||
|
|
@ -25,6 +26,7 @@ import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
|
|||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.exceptions.ApiException;
|
||||
import org.apache.dolphinscheduler.api.security.Authenticator;
|
||||
import org.apache.dolphinscheduler.api.security.impl.AbstractSsoAuthenticator;
|
||||
import org.apache.dolphinscheduler.api.service.SessionService;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.constants.Constants;
|
||||
|
|
@ -34,12 +36,15 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.apache.http.HttpStatus;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
|
@ -116,6 +121,26 @@ public class LoginController extends BaseController {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* sso login
|
||||
*
|
||||
* @return sso server url
|
||||
*/
|
||||
@Operation(summary = "sso login", description = "SSO_LOGIN_NOTES")
|
||||
@GetMapping(value = "/login/sso")
|
||||
@ApiException(NOT_SUPPORT_SSO)
|
||||
public Result ssoLogin(HttpServletRequest request) {
|
||||
if (authenticator instanceof AbstractSsoAuthenticator) {
|
||||
String randomState = UUID.randomUUID().toString();
|
||||
HttpSession session = request.getSession();
|
||||
if (session.getAttribute(Constants.SSO_LOGIN_USER_STATE) == null) {
|
||||
session.setAttribute(Constants.SSO_LOGIN_USER_STATE, randomState);
|
||||
}
|
||||
return Result.success(((AbstractSsoAuthenticator) authenticator).getSignInUrl(randomState));
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* sign out
|
||||
*
|
||||
|
|
|
|||
|
|
@ -268,6 +268,8 @@ public enum Status {
|
|||
LIST_AZURE_DATA_FACTORY_ERROR(10208, "list azure data factory error", "查询AZURE数据工厂列表错误"),
|
||||
LIST_AZURE_RESOURCE_GROUP_ERROR(10209, "list azure resource group error", "查询AZURE资源组列表错误"),
|
||||
LIST_AZURE_DATA_FACTORY_PIPELINE_ERROR(10210, "list azure data factory pipeline error", "查询AZURE数据工厂pipeline列表错误"),
|
||||
NOT_SUPPORT_SSO(10211, "Not support SSO login.", "不支持SSO登录"),
|
||||
STATE_CODE_ERROR(10212, "state inconsistency or state and code not pair", "状态码前后不一致或状态码和code不匹配"),
|
||||
|
||||
UDF_FUNCTION_NOT_EXIST(20001, "UDF function not found", "UDF函数不存在"),
|
||||
UDF_FUNCTION_EXISTS(20002, "UDF function already exists", "UDF函数已存在"),
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ public enum AuthenticationType {
|
|||
|
||||
PASSWORD(0, "verify via user name and password"),
|
||||
LDAP(1, "verify via LDAP server"),
|
||||
;
|
||||
CASDOOR_SSO(2, "verify via casdoor sso provider");
|
||||
|
||||
AuthenticationType(int code, String desc) {
|
||||
this.code = code;
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package org.apache.dolphinscheduler.api.security;
|
|||
|
||||
import org.apache.dolphinscheduler.api.security.impl.ldap.LdapAuthenticator;
|
||||
import org.apache.dolphinscheduler.api.security.impl.pwd.PasswordAuthenticator;
|
||||
import org.apache.dolphinscheduler.api.security.impl.sso.CasdoorAuthenticator;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
|
|
@ -66,6 +67,9 @@ public class SecurityConfig {
|
|||
case LDAP:
|
||||
authenticator = new LdapAuthenticator();
|
||||
break;
|
||||
case CASDOOR_SSO:
|
||||
authenticator = new CasdoorAuthenticator();
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Unexpected value: " + authenticationType);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
package org.apache.dolphinscheduler.api.security.impl;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.security.AuthenticationType;
|
||||
import org.apache.dolphinscheduler.api.security.Authenticator;
|
||||
import org.apache.dolphinscheduler.api.security.SecurityConfig;
|
||||
import org.apache.dolphinscheduler.api.service.SessionService;
|
||||
|
|
@ -30,6 +31,7 @@ import org.apache.dolphinscheduler.dao.entity.User;
|
|||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
|
|
@ -64,9 +66,15 @@ public abstract class AbstractAuthenticator implements Authenticator {
|
|||
Result<Map<String, String>> result = new Result<>();
|
||||
User user = login(userId, password, extra);
|
||||
if (user == null) {
|
||||
log.error("Username or password entered incorrectly.");
|
||||
result.setCode(Status.USER_NAME_PASSWD_ERROR.getCode());
|
||||
result.setMsg(Status.USER_NAME_PASSWD_ERROR.getMsg());
|
||||
if (Objects.equals(securityConfig.getType(), AuthenticationType.CASDOOR_SSO.name())) {
|
||||
log.error("State or code entered incorrectly.");
|
||||
result.setCode(Status.STATE_CODE_ERROR.getCode());
|
||||
result.setMsg(Status.STATE_CODE_ERROR.getMsg());
|
||||
} else {
|
||||
log.error("Username or password entered incorrectly.");
|
||||
result.setCode(Status.USER_NAME_PASSWD_ERROR.getCode());
|
||||
result.setMsg(Status.USER_NAME_PASSWD_ERROR.getMsg());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You 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.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.security.impl;
|
||||
|
||||
public abstract class AbstractSsoAuthenticator extends AbstractAuthenticator {
|
||||
|
||||
public abstract String getSignInUrl(String state);
|
||||
}
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You 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.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.security.impl.sso;
|
||||
|
||||
import org.apache.dolphinscheduler.api.security.impl.AbstractSsoAuthenticator;
|
||||
import org.apache.dolphinscheduler.api.service.UsersService;
|
||||
import org.apache.dolphinscheduler.common.constants.Constants;
|
||||
import org.apache.dolphinscheduler.common.enums.UserType;
|
||||
import org.apache.dolphinscheduler.dao.entity.User;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.casbin.casdoor.entity.CasdoorUser;
|
||||
import org.casbin.casdoor.service.CasdoorAuthService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
public class CasdoorAuthenticator extends AbstractSsoAuthenticator {
|
||||
|
||||
@Autowired
|
||||
private UsersService usersService;
|
||||
@Autowired
|
||||
private CasdoorAuthService casdoorAuthService;
|
||||
@Value("${casdoor.redirect-url}")
|
||||
private String redirectUrl;
|
||||
|
||||
@Override
|
||||
public User login(String state, String code, String extra) {
|
||||
ServletRequestAttributes servletRequestAttributes =
|
||||
(ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
if (servletRequestAttributes == null) {
|
||||
return null;
|
||||
}
|
||||
HttpServletRequest request = servletRequestAttributes.getRequest();
|
||||
String originalState = (String) request.getSession().getAttribute(Constants.SSO_LOGIN_USER_STATE);
|
||||
// Invalid state
|
||||
request.getSession().setAttribute(Constants.SSO_LOGIN_USER_STATE, null);
|
||||
// Check state to protect from CSRF attack
|
||||
if (originalState == null || !MessageDigest.isEqual(originalState.getBytes(), state.getBytes())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String token = casdoorAuthService.getOAuthToken(code, state);
|
||||
CasdoorUser casdoorUser = casdoorAuthService.parseJwtToken(token);
|
||||
User user = null;
|
||||
if (casdoorUser.getName() != null) {
|
||||
// check if user exist
|
||||
user = usersService.getUserByUserName(casdoorUser.getName());
|
||||
if (user == null) {
|
||||
user = usersService.createUser(UserType.GENERAL_USER, casdoorUser.getName(), casdoorUser.getEmail());
|
||||
}
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSignInUrl(String state) {
|
||||
return casdoorAuthService.getSigninUrl(redirectUrl, state);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -224,7 +224,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
|
|||
}
|
||||
|
||||
/***
|
||||
* create User for ldap login
|
||||
* create User for ldap and sso login
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ python-gateway:
|
|||
|
||||
security:
|
||||
authentication:
|
||||
# Authentication types (supported types: PASSWORD,LDAP)
|
||||
# Authentication types (supported types: PASSWORD,LDAP,CASDOOR_SSO)
|
||||
type: PASSWORD
|
||||
# IF you set type `LDAP`, below config will be effective
|
||||
ldap:
|
||||
|
|
|
|||
|
|
@ -199,6 +199,7 @@ UPDATE_PROCESS_INSTANCE_NOTES=update process instance
|
|||
QUERY_PROCESS_INSTANCE_LIST_NOTES=query process instance list
|
||||
VERIFY_PROCESS_DEFINITION_NAME_NOTES=verify process definition name
|
||||
LOGIN_NOTES=user login
|
||||
SSO_LOGIN_NOTES=user sso login
|
||||
UPDATE_PROCESS_DEFINITION_NOTES=update process definition
|
||||
PROCESS_DEFINITION_ID=process definition id
|
||||
PROCESS_DEFINITION_IDS=process definition ids
|
||||
|
|
|
|||
|
|
@ -208,6 +208,7 @@ UPDATE_PROCESS_INSTANCE_NOTES=update process instance
|
|||
QUERY_PROCESS_INSTANCE_LIST_NOTES=query process instance list
|
||||
VERIFY_PROCESS_DEFINITION_NAME_NOTES=verify process definition name
|
||||
LOGIN_NOTES=user login
|
||||
SSO_LOGIN_NOTES=user sso login
|
||||
UPDATE_PROCESS_DEFINITION_NOTES=update process definition
|
||||
PROCESS_DEFINITION_ID=process definition id
|
||||
PROCESS_DEFINITION_IDS=process definition ids
|
||||
|
|
|
|||
|
|
@ -197,6 +197,7 @@ UPDATE_PROCESS_INSTANCE_NOTES=更新流程实例
|
|||
QUERY_PROCESS_INSTANCE_LIST_NOTES=查询流程实例列表
|
||||
VERIFY_PROCESS_DEFINITION_NAME_NOTES=验证流程定义名字
|
||||
LOGIN_NOTES=用户登录
|
||||
SSO_LOGIN_TAG=单点登录
|
||||
UPDATE_PROCESS_DEFINITION_NOTES=更新流程定义
|
||||
PROCESS_DEFINITION_ID=流程定义ID
|
||||
RELEASE_PROCESS_DEFINITION_NOTES=发布流程定义
|
||||
|
|
|
|||
|
|
@ -0,0 +1,145 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You 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.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.security.impl.sso;
|
||||
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import org.apache.dolphinscheduler.api.controller.AbstractControllerTest;
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.service.SessionService;
|
||||
import org.apache.dolphinscheduler.api.service.UsersService;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.constants.Constants;
|
||||
import org.apache.dolphinscheduler.common.enums.Flag;
|
||||
import org.apache.dolphinscheduler.common.enums.UserType;
|
||||
import org.apache.dolphinscheduler.dao.entity.Session;
|
||||
import org.apache.dolphinscheduler.dao.entity.User;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.casbin.casdoor.entity.CasdoorUser;
|
||||
import org.casbin.casdoor.service.CasdoorAuthService;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
@TestPropertySource(properties = {
|
||||
"security.authentication.type=CASDOOR_SSO",
|
||||
"casdoor.endpoint=http://localhost:8000",
|
||||
"casdoor.client-id=client-id",
|
||||
"casdoor.client-secret=client-secret",
|
||||
"casdoor.certificate=public-key",
|
||||
"casdoor.organization-name=built-in",
|
||||
"casdoor.application-name=app-built-in",
|
||||
"casdoor.redirect-url=http://localhost:8888/view/login/index.html"
|
||||
})
|
||||
public class CasdoorAuthenticatorTest extends AbstractControllerTest {
|
||||
|
||||
@Autowired
|
||||
protected AutowireCapableBeanFactory beanFactory;
|
||||
@MockBean(name = "sessionServiceImpl")
|
||||
private SessionService sessionService;
|
||||
@MockBean(name = "usersServiceImpl")
|
||||
private UsersService usersService;
|
||||
@MockBean(name = "casdoorAuthService")
|
||||
private CasdoorAuthService casdoorAuthService;
|
||||
|
||||
private CasdoorAuthenticator casdoorAuthenticator;
|
||||
|
||||
// test param
|
||||
private User mockUser;
|
||||
private Session mockSession;
|
||||
private CasdoorUser mockCasdoorUser;
|
||||
|
||||
private String casdoorUsername = "test";
|
||||
private String casdoorEmail = "test@example.com";
|
||||
private String code = "code";
|
||||
private String state = "random_state";
|
||||
private String token = "token";
|
||||
private String ip = "127.0.0.1";
|
||||
private UserType userType = UserType.GENERAL_USER;
|
||||
|
||||
@Override
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
casdoorAuthenticator = new CasdoorAuthenticator();
|
||||
beanFactory.autowireBean(casdoorAuthenticator);
|
||||
|
||||
mockUser = new User();
|
||||
mockUser.setId(1);
|
||||
mockUser.setUserName(casdoorUsername);
|
||||
mockUser.setEmail(casdoorEmail);
|
||||
mockUser.setUserType(userType);
|
||||
mockUser.setState(Flag.YES.getCode());
|
||||
|
||||
mockSession = new Session();
|
||||
mockSession.setId(UUID.randomUUID().toString());
|
||||
mockSession.setIp(ip);
|
||||
mockSession.setUserId(1);
|
||||
mockSession.setLastLoginTime(new Date());
|
||||
|
||||
mockCasdoorUser = new CasdoorUser();
|
||||
mockCasdoorUser.setName(casdoorUsername);
|
||||
mockCasdoorUser.setEmail(casdoorEmail);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAuthenticate() {
|
||||
when(usersService.getUserByUserName(casdoorUsername)).thenReturn(mockUser);
|
||||
when(sessionService.createSession(mockUser, ip)).thenReturn(mockSession.getId());
|
||||
|
||||
when(casdoorAuthService.getOAuthToken(code, state)).thenReturn(token);
|
||||
when(casdoorAuthService.parseJwtToken(token)).thenReturn(mockCasdoorUser);
|
||||
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
Objects.requireNonNull(request.getSession()).setAttribute(Constants.SSO_LOGIN_USER_STATE, state);
|
||||
RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request));
|
||||
Result result = casdoorAuthenticator.authenticate(state, code, ip);
|
||||
Assertions.assertEquals(Status.SUCCESS.getCode(), (int) result.getCode());
|
||||
Assertions.assertNull(request.getSession().getAttribute(Constants.SSO_LOGIN_USER_STATE));
|
||||
|
||||
Objects.requireNonNull(request.getSession()).setAttribute(Constants.SSO_LOGIN_USER_STATE, state);
|
||||
RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request));
|
||||
result = casdoorAuthenticator.authenticate("fake_state", code, ip);
|
||||
Assertions.assertEquals(Status.STATE_CODE_ERROR.getCode(), (int) result.getCode());
|
||||
|
||||
Objects.requireNonNull(request.getSession()).setAttribute(Constants.SSO_LOGIN_USER_STATE, state);
|
||||
RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request));
|
||||
when(sessionService.createSession(mockUser, ip)).thenReturn(null);
|
||||
result = casdoorAuthenticator.authenticate(state, code, ip);
|
||||
Assertions.assertEquals(Status.LOGIN_SESSION_FAILED.getCode(), (int) result.getCode());
|
||||
|
||||
Objects.requireNonNull(request.getSession()).setAttribute(Constants.SSO_LOGIN_USER_STATE, state);
|
||||
RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request));
|
||||
when(sessionService.createSession(mockUser, ip)).thenReturn(mockSession.getId());
|
||||
when(usersService.getUserByUserName(casdoorUsername)).thenReturn(null);
|
||||
when(usersService.createUser(userType, casdoorUsername, casdoorEmail)).thenReturn(null);
|
||||
result = casdoorAuthenticator.authenticate(state, code, ip);
|
||||
Assertions.assertEquals(Status.STATE_CODE_ERROR.getCode(), (int) result.getCode());
|
||||
}
|
||||
}
|
||||
|
|
@ -110,6 +110,7 @@
|
|||
<google-cloud-storage.version>2.18.0</google-cloud-storage.version>
|
||||
<sshd.version>2.8.0</sshd.version>
|
||||
<fabric8.client.version>6.0.0</fabric8.client.version>
|
||||
<casdoor.version>1.6.0</casdoor.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
|
|
@ -859,6 +860,11 @@
|
|||
<artifactId>kubernetes-client</artifactId>
|
||||
<version>${fabric8.client.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.casbin</groupId>
|
||||
<artifactId>casdoor-spring-boot-starter</artifactId>
|
||||
<version>${casdoor.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<profiles>
|
||||
|
|
|
|||
|
|
@ -532,6 +532,11 @@ public final class Constants {
|
|||
*/
|
||||
public static final String LOGIN_USER_KEY_TAB_PATH = "login.user.keytab.path";
|
||||
|
||||
/**
|
||||
* sso.login.user.state
|
||||
*/
|
||||
public static final String SSO_LOGIN_USER_STATE = "sso.login.user.state";
|
||||
|
||||
public static final String WORKFLOW_INSTANCE_ID_MDC_KEY = "workflowInstanceId";
|
||||
public static final String TASK_INSTANCE_ID_MDC_KEY = "taskInstanceId";
|
||||
|
||||
|
|
|
|||
|
|
@ -551,6 +551,10 @@ The text of each license is also included at licenses/LICENSE-[project].txt.
|
|||
proto-google-iam-v1 1.9.0: https://mvnrepository.com/artifact/com.google.api.grpc/proto-google-iam-v1/1.9.0, Apache 2.0
|
||||
sshd-sftp https://mvnrepository.com/artifact/org.apache.sshd/sshd-sftp/2.8.0 Apache 2.0
|
||||
sshd-scp https://mvnrepository.com/artifact/org.apache.sshd/sshd-scp/2.8.0 Aapache 2.0
|
||||
casdoor-java-sdk 1.11.0 https://mvnrepository.com/artifact/org.casbin/casdoor-java-sdk/1.11.0 Apache 2.0
|
||||
casdoor-spring-boot-starter 1.6.0 https://mvnrepository.com/artifact/org.casbin/casdoor-spring-boot-starter/1.6.0 Apache 2.0
|
||||
org.apache.oltu.oauth2.client 1.0.2 https://mvnrepository.com/artifact/org.apache.oltu.oauth2/org.apache.oltu.oauth2.client/1.0.2 Apache 2.0
|
||||
org.apache.oltu.oauth2.common 1.0.2 https://mvnrepository.com/artifact/org.apache.oltu.oauth2/org.apache.oltu.oauth2.common/1.0.2 Apache 2.0
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2106,3 +2106,15 @@ Dameng DmJdbcDriver18 NOTICE
|
|||
|
||||
Dameng DmJdbcDriver18
|
||||
Copyright 2000-2022 Dameng Group Holding Ltd.
|
||||
|
||||
=========================================================================
|
||||
|
||||
Oltu NOTICE
|
||||
|
||||
=========================================================================
|
||||
|
||||
Apache Oltu
|
||||
Copyright 2010-2017 The Apache Software Foundation
|
||||
|
||||
This product includes software developed by
|
||||
The Apache Software Foundation (http://www.apache.org/).
|
||||
|
|
|
|||
|
|
@ -0,0 +1,202 @@
|
|||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 1999-2005 The Apache Software Foundation
|
||||
|
||||
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.
|
||||
|
|
@ -0,0 +1,202 @@
|
|||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 1999-2005 The Apache Software Foundation
|
||||
|
||||
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.
|
||||
|
|
@ -0,0 +1,202 @@
|
|||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
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.
|
||||
|
|
@ -0,0 +1,202 @@
|
|||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
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.
|
||||
|
|
@ -90,7 +90,7 @@ registry:
|
|||
|
||||
security:
|
||||
authentication:
|
||||
# Authentication types (supported types: PASSWORD,LDAP)
|
||||
# Authentication types (supported types: PASSWORD,LDAP,CASDOOR_SSO)
|
||||
type: PASSWORD
|
||||
# IF you set type `LDAP`, below config will be effective
|
||||
ldap:
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -21,5 +21,6 @@ export default {
|
|||
userName_tips: 'Please enter your username',
|
||||
userPassword: 'Password',
|
||||
userPassword_tips: 'Please enter your password',
|
||||
login: 'Login'
|
||||
login: 'Login',
|
||||
ssoLogin: 'SSO Login'
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,5 +21,6 @@ export default {
|
|||
userName_tips: '请输入用户名',
|
||||
userPassword: '密码',
|
||||
userPassword_tips: '请输入密码',
|
||||
login: '登录'
|
||||
login: '登录',
|
||||
ssoLogin: '单点登录'
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,3 +25,10 @@ export function login(data: LoginReq): any {
|
|||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function ssoLoginUrl(): any {
|
||||
return axios({
|
||||
url: '/login/sso',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { defineComponent, getCurrentInstance, toRefs, withKeys } from 'vue'
|
||||
import {defineComponent, getCurrentInstance, onMounted, toRefs, withKeys} from 'vue'
|
||||
import styles from './index.module.scss'
|
||||
import {
|
||||
NInput,
|
||||
|
|
@ -31,6 +31,7 @@ import { useLogin } from './use-login'
|
|||
import { useLocalesStore } from '@/store/locales/locales'
|
||||
import { useThemeStore } from '@/store/theme/theme'
|
||||
import cookies from 'js-cookie'
|
||||
import {ssoLoginUrl} from "@/service/modules/login";
|
||||
|
||||
const login = defineComponent({
|
||||
name: 'login',
|
||||
|
|
@ -51,6 +52,23 @@ const login = defineComponent({
|
|||
|
||||
cookies.set('language', localesStore.getLocales, { path: '/' })
|
||||
|
||||
onMounted(async () => {
|
||||
const ssoLoginUrlRes = await ssoLoginUrl()
|
||||
state.loginForm.ssoLoginUrl = ssoLoginUrlRes
|
||||
if (state.loginForm.ssoLoginUrl) {
|
||||
const url = new URL(window.location.href)
|
||||
let ssoState = url.searchParams.get('state')
|
||||
let ssoCode = url.searchParams.get('code')
|
||||
if (ssoState && ssoCode) {
|
||||
state.loginForm.userName = ssoState
|
||||
state.loginForm.userPassword = ssoCode
|
||||
handleLogin()
|
||||
}
|
||||
} else {
|
||||
state.loginForm.ssoLoginUrl = ''
|
||||
}
|
||||
})
|
||||
|
||||
return {
|
||||
t,
|
||||
handleChange,
|
||||
|
|
@ -80,7 +98,7 @@ const login = defineComponent({
|
|||
<div class={styles.logo}>
|
||||
<div class={styles['logo-img']} />
|
||||
</div>
|
||||
<div class={styles['form-model']}>
|
||||
<div class={styles['form-model']} v-show={this.loginForm.ssoLoginUrl.length === 0}>
|
||||
<NForm rules={this.rules} ref='loginFormRef'>
|
||||
<NFormItem
|
||||
label={this.t('login.userName')}
|
||||
|
|
@ -127,6 +145,19 @@ const login = defineComponent({
|
|||
{this.t('login.login')}
|
||||
</NButton>
|
||||
</div>
|
||||
<div class={styles['form-model']} v-show={this.loginForm.ssoLoginUrl.length !== 0}>
|
||||
<a href={this.loginForm.ssoLoginUrl} style="text-decoration:none">
|
||||
<NButton
|
||||
class='btn-login-sso'
|
||||
round
|
||||
type='info'
|
||||
style={{width: '100%', marginTop: '30px'}}
|
||||
onClick={this.handleLogin}
|
||||
>
|
||||
{this.t('login.ssoLogin')}
|
||||
</NButton>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -26,7 +26,8 @@ export function useForm() {
|
|||
loginFormRef: ref(),
|
||||
loginForm: {
|
||||
userName: '',
|
||||
userPassword: ''
|
||||
userPassword: '',
|
||||
ssoLoginUrl: ''
|
||||
},
|
||||
rules: {
|
||||
userName: {
|
||||
|
|
|
|||
|
|
@ -161,6 +161,7 @@ joda-time-2.10.13.jar
|
|||
jpam-1.1.jar
|
||||
jsch-0.1.55.jar
|
||||
json-1.8.jar
|
||||
json-20140107.jar
|
||||
json-path-2.7.0.jar
|
||||
json-smart-2.4.8.jar
|
||||
json-utils-2.17.282.jar
|
||||
|
|
@ -245,6 +246,7 @@ netty-transport-classes-epoll-4.1.79.Final.jar
|
|||
netty-transport-native-epoll-4.1.53.Final.jar
|
||||
netty-transport-native-unix-common-4.1.53.Final.jar
|
||||
nimbus-jose-jwt-9.8.1.jar
|
||||
nimbus-jose-jwt-9.10.jar
|
||||
okhttp-2.7.5.jar
|
||||
okhttp-3.14.9.jar
|
||||
okio-1.17.2.jar
|
||||
|
|
@ -476,4 +478,8 @@ sshd-core-2.8.0.jar
|
|||
jcl-over-slf4j-1.7.36.jar
|
||||
databend-jdbc-0.0.7.jar
|
||||
kyuubi-hive-jdbc-shaded-1.7.0.jar
|
||||
casdoor-java-sdk-1.11.0.jar
|
||||
casdoor-spring-boot-starter-1.6.0.jar
|
||||
org.apache.oltu.oauth2.client-1.0.2.jar
|
||||
org.apache.oltu.oauth2.common-1.0.2.jar
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue