fix : change Spring WebConfig

This commit is contained in:
kms
2022-11-27 18:07:10 +09:00
parent e8247f7521
commit 311ab00234
4 changed files with 38 additions and 31 deletions

View File

@@ -38,27 +38,19 @@ public class WebConfig {
} }
@Bean @Bean
@Order(0) public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
public SecurityFilterChain resources(HttpSecurity http) throws Exception { http.csrf()
http.csrf().disable() .disable()
.requestMatchers((matchers) -> {matchers.antMatchers("/h2-console/**"); .requestMatchers((matchers) -> {
matchers.antMatchers(HttpMethod.GET,"/api/articles/**","/**");}) matchers.antMatchers("/h2-console/**");
matchers.antMatchers(HttpMethod.GET,"/api/articles/**","/**");
matchers.mvcMatchers("/api/users/**");
})
.authorizeHttpRequests((authorize) -> authorize.anyRequest().permitAll()) .authorizeHttpRequests((authorize) -> authorize.anyRequest().permitAll())
.requestCache().disable() .requestCache().disable()
.securityContext().disable() .securityContext().disable()
.sessionManagement().disable() .sessionManagement().disable()
.headers().frameOptions().disable(); .headers().frameOptions().disable()
return http.build();
}
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http.csrf()
.disable()
.authorizeRequests()
.mvcMatchers("/api/users/**").permitAll()
.anyRequest().authenticated()
.and() .and()
.formLogin() .formLogin()
.disable() .disable()

View File

@@ -52,6 +52,7 @@ export default defineComponent({
}) })
onMounted(() => { onMounted(() => {
axios.get(url + "/api/articles/feed",{ axios.get(url + "/api/articles/feed",{
headers:{ headers:{
Authorization : "TOKEN " + token Authorization : "TOKEN " + token

View File

@@ -13,7 +13,9 @@
<i class="ion-heart"></i> {{art.favoritesCount}} <i class="ion-heart"></i> {{art.favoritesCount}}
</button> </button>
</div> </div>
<a href="" class="preview-link"> <a href="javascript:(0)"
class="preview-link"
@click="showArticle(art.slug)">
<h1>{{art.title}}</h1> <h1>{{art.title}}</h1>
<p>{{art.description}}</p> <p>{{art.description}}</p>
<span>Read more...</span> <span>Read more...</span>
@@ -23,7 +25,7 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import {onMounted, reactive, ref, defineComponent} from "vue"; import {onMounted, reactive, ref, defineComponent, watch} from "vue";
import axios from "axios"; import axios from "axios";
import router from "@/router"; import router from "@/router";
@@ -31,7 +33,8 @@ export default defineComponent({
name: "ArticleListGlobal", name: "ArticleListGlobal",
props:{ props:{
isEmpty: Boolean, isEmpty: Boolean,
isLoading: Boolean isLoading: Boolean,
globalList: Boolean,
}, },
setup(props,{emit}) { setup(props,{emit}) {
const url = import.meta.env.VITE_BASE_URL; const url = import.meta.env.VITE_BASE_URL;
@@ -53,14 +56,7 @@ export default defineComponent({
articlesCount: "", articlesCount: "",
}) })
const showProfile = (username: string) => { const getArticles = () => {
router.push({
name: 'Profile',
params: {username: username}
})
}
onMounted(() => {
axios.get(url + "/api/articles") axios.get(url + "/api/articles")
.then(response => { .then(response => {
articles.article = response.data.articles; articles.article = response.data.articles;
@@ -71,8 +67,26 @@ export default defineComponent({
emit("emptied", true); emit("emptied", true);
} }
}); });
}
const showProfile = (username: string) => {
router.push({
name: 'Profile',
params: {username: username}
}) })
return { articles, showProfile } }
const showArticle = (slug: string) =>{
router.push({
name: 'ArticleDetail',
params: {slug: slug}
})
}
onMounted(() => {
getArticles();
})
return { articles, getArticles, showProfile, showArticle }
} }
}) })
</script> </script>

View File

@@ -46,7 +46,6 @@
:value2="isEmpty" :value2="isEmpty"
@loading="onChangeLoading" @loading="onChangeLoading"
@emptied="emptyCheck"> @emptied="emptyCheck">
</article-list-global> </article-list-global>
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
@@ -67,7 +66,7 @@
import articleList from '@/components/ArticleListFeed.vue' import articleList from '@/components/ArticleListFeed.vue'
import articleListGlobal from "@/components/ArticleListGlobal.vue"; import articleListGlobal from "@/components/ArticleListGlobal.vue";
import tagLists from "@/components/TagList.vue"; import tagLists from "@/components/TagList.vue";
import {ref} from "vue"; import {ref, getCurrentInstance, onMounted} from "vue";
import {useStore} from "vuex"; import {useStore} from "vuex";
export default { export default {
name: "TheHome", name: "TheHome",
@@ -91,6 +90,7 @@ export default {
isEmpty.value = val; isEmpty.value = val;
} }
const feedSelect = () => { const feedSelect = () => {
feedActive.value=true; feedActive.value=true;
globalActive.value=false; globalActive.value=false;