0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【SpringSecurity】認証を行うカラムを変更する

Posted at

はじめに

SpringSecurityを使ったログイン機能を作成した際に、SpringSecurityの認証に関してネット上で調べていたら、ほとんどがDBのカラム名が「username」と「password」で行っているものばかりで、どうにか「userid」カラムで認証できないかと思い調べて実装できたのでメモ(簡単に)

結論

AccountRepository.java

-public interface AccountRepository extends JpaRepository<Account, Integer> {

	public Account findByUserid(String userid);
}

これでとりあえずはuseridカラムでの認証可能。
「findBy + カラム名(最初は大文字)」で好きなカラム名にできる。

まだ実装段階なので不具合などの可能性もありますが…

前提

SpringSecurityの実装済み。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?