Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add comment #13083

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
c648249
Merge pull request #2964 from alibaba/develop
yanlinly Jun 5, 2020
5e53396
Merge pull request #3295 from alibaba/develop
KomachiSion Jul 10, 2020
a341b65
Merge pull request #3519 from alibaba/develop
KomachiSion Aug 4, 2020
c0ffb1d
Merge pull request #4119 from alibaba/develop
KomachiSion Nov 2, 2020
b9a842c
fix: 修复参数类型注释及单词拼写错误 (#4413)
xuande Dec 7, 2020
023f50c
Revert "fix: 修复参数类型注释及单词拼写错误 (#4413)" (#4417)
KomachiSion Dec 7, 2020
1d88d5d
Merge pull request #4696 from alibaba/develop
KomachiSion Jan 14, 2021
a18c27c
Merge pull request #4704 from alibaba/develop
KomachiSion Jan 14, 2021
11be620
Merge pull request #5532 from alibaba/develop
KomachiSion Apr 29, 2021
1fac5c8
Merge pull request #6052 from alibaba/develop
KomachiSion Jun 11, 2021
5a4d433
Merge pull request #6494 from alibaba/develop
KomachiSion Jul 28, 2021
8e9f718
Merge pull request #7657 from alibaba/develop
KomachiSion Jan 18, 2022
b584531
Merge pull request #8279 from alibaba/develop
KomachiSion Apr 29, 2022
41859be
Merge pull request #8902 from alibaba/develop
KomachiSion Aug 8, 2022
2eb7f73
Merge pull request #9335 from alibaba/develop
KomachiSion Oct 17, 2022
38faeea
Merge pull request #9707 from alibaba/develop
KomachiSion Dec 14, 2022
cb0422e
Merge pull request #10126 from alibaba/develop
KomachiSion Mar 17, 2023
285d39a
[ISSUE#10208] Remove DefaultSettingPropertySource.java and add some u…
KomachiSion Mar 28, 2023
3b0fda2
[ISSUE#10153] Add auth state into /state api and add announcement api…
KomachiSion Mar 27, 2023
9162c51
[fix]🐛nacos login page && notice config (#10262)
abuexclusive Apr 3, 2023
0f43ea9
Build console main.js. (#10264)
KomachiSion Apr 3, 2023
e31f830
Don't stopping startup for illegal token.secret.key when auth.enabled…
KomachiSion Apr 3, 2023
9539087
Don't stopping startup for illegal token.secret.key when auth.enabled…
KomachiSion Apr 6, 2023
6c4c41c
Upgrade to 2.2.2
KomachiSion Apr 6, 2023
50d313b
取消默认openssl (#10276)
shiyiyue1102 Apr 7, 2023
d2e16a3
Fix dynamic change token to illegal value will use old token.
KomachiSion Apr 11, 2023
6080b01
HessianSerializer add whitelist. (#10542)
KomachiSion May 25, 2023
bf37a8a
[ISSUE #10318]fix import bug (#10319)
985492783 Apr 14, 2023
ca788b7
Upgrade to 2.2.3
KomachiSion May 25, 2023
3d43954
Fix unit test.
KomachiSion May 25, 2023
bb6c070
For checkstyle.
KomachiSion May 25, 2023
bbeb069
1. notify thread change to one thread to avoid potential ClassLoader …
shiyiyue1102 May 26, 2023
7ddb334
fix naming memory leak (#10606)
shiyiyue1102 Jun 7, 2023
17adce2
[ISSUE #10598] Fix nacos-client get the wrong index of the nacos serv…
1em0n9527 Jun 14, 2023
6be55c0
replace nacos cache with guava cache (#10674)
shiyiyue1102 Jun 20, 2023
45e155f
Upgrade to 2.2.4
KomachiSion Jun 20, 2023
93ded23
init
Feb 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

<name>nacos-api ${project.version}</name>
<url>https://nacos.io</url>
<description>Nacos api pom.xml file</description>
<build>
<plugins>
<!-- reuse when you need to update grpc model -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import com.alibaba.nacos.common.utils.StringUtils;
import com.alibaba.nacos.plugin.auth.constant.Constants;
import com.alibaba.nacos.sys.env.EnvUtil;
import com.alibaba.nacos.sys.module.ModuleState;
import com.alibaba.nacos.sys.module.ModuleStateHolder;
import com.alibaba.nacos.sys.utils.PropertiesUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -179,6 +181,11 @@ public void onEvent(ServerConfigChangeEvent event) {
.getProperty(Constants.Auth.NACOS_CORE_AUTH_ENABLE_USER_AGENT_AUTH_WHITE, Boolean.class, false);
nacosAuthSystemType = EnvUtil.getProperty(Constants.Auth.NACOS_CORE_AUTH_SYSTEM_TYPE, "");
refreshPluginProperties();
ModuleStateHolder.getInstance().getModuleState(AuthModuleStateBuilder.AUTH_MODULE)
.ifPresent(moduleState -> {
ModuleState temp = new AuthModuleStateBuilder().build();
moduleState.getStates().putAll(temp.getStates());
});
} catch (Exception e) {
LOGGER.warn("Upgrade auth config from env failed, use old value", e);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright 1999-2023 Alibaba Group Holding Ltd.
*
* 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.
*/

package com.alibaba.nacos.auth.config;

import com.alibaba.nacos.plugin.auth.spi.server.AuthPluginManager;
import com.alibaba.nacos.plugin.auth.spi.server.AuthPluginService;
import com.alibaba.nacos.sys.module.ModuleState;
import com.alibaba.nacos.sys.module.ModuleStateBuilder;
import com.alibaba.nacos.sys.utils.ApplicationUtils;

import java.util.Optional;

/**
* Module state builder for auth module.
*
* @author xiweng.yy
*/
public class AuthModuleStateBuilder implements ModuleStateBuilder {

public static final String AUTH_MODULE = "auth";

public static final String AUTH_ENABLED = "auth_enabled";

public static final String LOGIN_PAGE_ENABLED = "login_page_enabled";

public static final String AUTH_SYSTEM_TYPE = "auth_system_type";

@Override
public ModuleState build() {
ModuleState result = new ModuleState(AUTH_MODULE);
AuthConfigs authConfigs = ApplicationUtils.getBean(AuthConfigs.class);
result.newState(AUTH_ENABLED, authConfigs.isAuthEnabled());
result.newState(LOGIN_PAGE_ENABLED, isLoginPageEnabled(authConfigs));
result.newState(AUTH_SYSTEM_TYPE, authConfigs.getNacosAuthSystemType());
return result;
}

private Boolean isLoginPageEnabled(AuthConfigs authConfigs) {
Optional<AuthPluginService> authPluginService = AuthPluginManager.getInstance()
.findAuthServiceSpiImpl(authConfigs.getNacosAuthSystemType());
return authPluginService.map(AuthPluginService::isLoginEnabled).orElse(false);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#
# Copyright 1999-2023 Alibaba Group Holding Ltd.
#
# 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.
#

com.alibaba.nacos.auth.config.AuthModuleStateBuilder
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Copyright 1999-2023 Alibaba Group Holding Ltd.
*
* 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.
*/

package com.alibaba.nacos.auth.config;

import com.alibaba.nacos.sys.module.ModuleState;
import com.alibaba.nacos.sys.utils.ApplicationUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.context.ConfigurableApplicationContext;

import static com.alibaba.nacos.auth.config.AuthModuleStateBuilder.AUTH_ENABLED;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.mockito.Mockito.when;

@RunWith(MockitoJUnitRunner.class)
public class AuthModuleStateBuilderTest {

@Mock
private ConfigurableApplicationContext context;

@Mock
private AuthConfigs authConfigs;

@Before
public void setUp() throws Exception {
when(context.getBean(AuthConfigs.class)).thenReturn(authConfigs);
ApplicationUtils.injectContext(context);
when(authConfigs.getNacosAuthSystemType()).thenReturn("nacos");
}

@After
public void tearDown() throws Exception {
}

@Test
public void testBuild() {
ModuleState actual = new AuthModuleStateBuilder().build();
assertFalse((Boolean) actual.getStates().get(AUTH_ENABLED));
assertFalse((Boolean) actual.getStates().get("login_page_enabled"));
assertEquals("nacos", actual.getStates().get("auth_system_type"));
}
}
1 change: 1 addition & 0 deletions client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

<name>nacos-client ${project.version}</name>
<url>https://nacos.io</url>
<description>Nacos client pom.xml file</description>

<dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,15 @@ public static CredentialService getInstance() {

public static CredentialService getInstance(String appName) {
String key = appName != null ? appName : IdentifyConstants.NO_APP_NAME;
CredentialService instance = INSTANCES.get(key);
if (instance != null) {
return instance;
}
instance = new CredentialService(appName);
CredentialService previous = INSTANCES.putIfAbsent(key, instance);
if (previous != null) {
instance = previous;
if (INSTANCES.get(key) == null) {
synchronized (CredentialService.INSTANCES) {
if (INSTANCES.get(key) == null) {
CredentialService instance = new CredentialService(appName);
INSTANCES.putIfAbsent(key, instance);
}
}
}
return instance;
return INSTANCES.get(key);
}

public static CredentialService freeInstance() {
Expand Down
Loading
Loading