forked from handuyishe/dubbo-monitor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Zhiguo.Chen
committed
Aug 24, 2015
1 parent
3a36945
commit 34e3050
Showing
6 changed files
with
120 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/main/java/com/handu/open/dubbo/monitor/config/Security.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* Copyright 2006-2015 handu.com | ||
* | ||
* 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.handu.open.dubbo.monitor.config; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.core.env.Environment; | ||
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; | ||
import org.springframework.security.config.annotation.web.builders.HttpSecurity; | ||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; | ||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; | ||
|
||
|
||
@Configuration | ||
@EnableWebSecurity | ||
public class Security extends WebSecurityConfigurerAdapter { | ||
|
||
@Autowired | ||
Environment env; | ||
|
||
@Autowired | ||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { | ||
auth.inMemoryAuthentication() | ||
.withUser(env.getProperty("manager.username", "root")) | ||
.password(env.getProperty("manager.password", "password")) | ||
.roles("MANAGER"); | ||
} | ||
|
||
protected void configure(HttpSecurity http) throws Exception { | ||
http.csrf().disable() | ||
.authorizeRequests() | ||
.anyRequest().authenticated() | ||
.and() | ||
.httpBasic(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,53 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<web-app> | ||
<display-name>Dubbo monitor</display-name> | ||
|
||
<context-param> | ||
<param-name>log4jConfigLocation</param-name> | ||
<param-value>classpath:log4j.xml</param-value> | ||
</context-param> | ||
<listener> | ||
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class> | ||
</listener> | ||
|
||
<context-param> | ||
<param-name>contextClass</param-name> | ||
<param-value> | ||
org.springframework.web.context.support.AnnotationConfigWebApplicationContext | ||
</param-value> | ||
</context-param> | ||
|
||
<context-param> | ||
<param-name>contextConfigLocation</param-name> | ||
<param-value>com.handu.open.dubbo.monitor.config.MonitorConfig</param-value> | ||
</context-param> | ||
|
||
<listener> | ||
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> | ||
</listener> | ||
|
||
<servlet> | ||
<servlet-name>springServlet</servlet-name> | ||
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> | ||
<init-param> | ||
<param-name>contextConfigLocation</param-name> | ||
<param-value></param-value> | ||
</init-param> | ||
<load-on-startup>1</load-on-startup> | ||
</servlet> | ||
|
||
<servlet-mapping> | ||
<servlet-name>springServlet</servlet-name> | ||
<url-pattern>/</url-pattern> | ||
</servlet-mapping> | ||
<display-name>Dubbo monitor</display-name> | ||
|
||
<context-param> | ||
<param-name>log4jConfigLocation</param-name> | ||
<param-value>classpath:log4j.xml</param-value> | ||
</context-param> | ||
<listener> | ||
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class> | ||
</listener> | ||
|
||
<context-param> | ||
<param-name>contextClass</param-name> | ||
<param-value> | ||
org.springframework.web.context.support.AnnotationConfigWebApplicationContext | ||
</param-value> | ||
</context-param> | ||
|
||
<context-param> | ||
<param-name>contextConfigLocation</param-name> | ||
<param-value>com.handu.open.dubbo.monitor.config.MonitorConfig</param-value> | ||
</context-param> | ||
|
||
<listener> | ||
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> | ||
</listener> | ||
|
||
<servlet> | ||
<servlet-name>springServlet</servlet-name> | ||
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> | ||
<init-param> | ||
<param-name>contextConfigLocation</param-name> | ||
<param-value></param-value> | ||
</init-param> | ||
<load-on-startup>1</load-on-startup> | ||
</servlet> | ||
|
||
<servlet-mapping> | ||
<servlet-name>springServlet</servlet-name> | ||
<url-pattern>/</url-pattern> | ||
</servlet-mapping> | ||
|
||
<filter> | ||
<filter-name>springSecurityFilterChain</filter-name> | ||
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> | ||
</filter> | ||
|
||
<filter-mapping> | ||
<filter-name>springSecurityFilterChain</filter-name> | ||
<url-pattern>/*</url-pattern> | ||
</filter-mapping> | ||
</web-app> |