heroku - 我的 heroku 应用程序正在请求一个我没有放在那里的密码
问题描述
我不熟悉将应用程序发送到生产的过程,我正在使用 Heroku 免费计划进行测试。今天我去检查我的应用程序,我使用 Spring boot 制作的 API 无法正常工作,并且正在请求我没有做的登录。我的应用程序地址是https://erik-financial-api.herokuapp.com,当你去那里时,它会将你重定向到地址https://erik-financial-api.herokuapp.com/login,其中包含以下内容:
我没有创建此页面,并且没有任何密码(来自我的应用程序或来自我的 Heroku 帐户)可以使用它。这应该只是另一个前端应用程序的 REST API。有谁知道为什么会这样?
这个项目的代码可以在我的 GitHub 上找到https://github.com/esscheffer/financial-api
编辑:这似乎是一个默认的弹簧安全登录页面。我一直在寻找解决方案,但到目前为止都没有。我试过的:
添加
override fun configure(security: HttpSecurity) {
security.httpBasic().disable()
.formLogin().disable()
}
到我的WebSecurityConfigurerAdapter
课。
添加http.httpBasic().disable().formLogin().disable()
到configure
我的ResourceServerConfigurerAdapter
班级。
添加(exclude = [SecurityAutoConfiguration::class])
到@SpringBootApplication
我的应用程序类的卫生。
前 2 次尝试没有删除登录页面,最后一次尝试破坏了应用程序,所有页面都返回 404。请注意,这只发生在我将应用程序部署到 Heroku 时。在本地运行时,我没有此登录页面或任何其他问题。
解决方案
添加一个新的配置类com.scheffer.erik.financial.api.config.SecurityConfig
,在配置方法中,您可以禁用 HTTP 基本身份验证以及基于登录表单的身份验证,如下所示:
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity security) throws Exception {
security
.httpBasic().disable()
.formLogin().disable();
}
}
推荐阅读
- sql - 格式化数据以在 SQL Server 中生成线性回归
- scala - UDF 取两个参数的 spark 数据帧
- css - CSS Flexbox - 具有可滚动内容的浮动可变高度页脚
- android - gradle 无法从 artifactory 解析 .aar
- c# - 在存储过程中插入 DataTable 时重复条目插入
- python - 如何在python中实现适用于N维特征向量的GMM聚类EM算法(期望最大化算法)
- php - 在 Bootstrap 中显示折叠的行
- python - __class__ 实现在 IPython 中是否针对 Python 进行了修改?
- java - 每个 junit 一个实例,而不是每个测试用例每个新实例
- javascript - 计算 ajax 响应的时间并在 SetTimeout 函数中使用该时间