さわぴかのなんでもノート!

学びのアウトプット!なにについて書くかはわかりません!なんでもノートです!

【今日学んだこと】未経験からエンジニアで転職「5週間目その3」

雨、、、

今日やったこと

  • skype朝礼、終礼with Mさん
  • PCのファイル整理
  • 交通費まとめる
  • 同世代祭りシステムのを進める

できなかったこと

明日やること

  • skype朝礼、終礼with MさんEさん
  • 同世代祭りシステムのを進める
  • 交通費まとめる

今週やること

  • 勉強しつつ同世代祭りシステムのを進める

来週やること

  • 勉強しつつ同世代祭りシステムのを進める

めも

Javaのこと

同世代祭りシステムのを進める

今日の流れ ・ログイン機能かな

・できたらそしたらユーザー側の方作ろう→bosyuライクに

Spring bootで、パスワードをハッシュ化して会員登録 & Spring securityを使って、ログイン機能実装。 - Qiita

ユーザー名のところ、メールアドレスにしたいけど、一旦従ってユーザー名でやってみる

Java - Spring bootにおけるビルド失敗|teratail

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-03-04 11:21:51.299 ERROR 21791 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Field passwordEncoder in com.example.demo.service.RegisterMemberService required a bean of type 'org.springframework.security.crypto.password.PasswordEncoder' that could not be found.

The injection point has the following annotations:
    - @org.springframework.beans.factory.annotation.Autowired(required=true)


Action:

Consider defining a bean of type 'org.springframework.security.crypto.password.PasswordEncoder' in your configuration.

ふえー、ファイルの名前間違ってて読み込めてなかっただけだった悲し

そして色々エラーが出てきたので潰す

org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is 'com/example/demo/mapper/LoginMapper.xml'. Cause: org.apache.ibatis.builder.BuilderException: Wrong namespace. Expected 'com.example.demo.mapper.LoginMapper' but found 'com.examole.demo.domain.mapper.LoginMapper'.

名前がが違う、さっきのだ。examoleになってる。example悲しい

あといくつか変えれてないところあって、直したらだいぶ減った

お、ページ見れたと思ったけど新規登録できないや

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.example.demo.mapper.RegisterMemberMapper.insertMemberInfo] with root cause

There was an unexpected error (type=Internal Server Error, status=500). Invalid bound statement (not found): com.example.demo.mapper.RegisterMemberMapper.insertMemberInfo org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.example.demo.mapper.RegisterMemberMapper.insertMemberInfo

わー これだ

春のセキュリティ:暗号化されたパスワードはBCryptのようには見えません

このサイトより

__bcrypt__ハッシュアルゴリズムでは、毎回、長さ60の異なるハッシュ値が生成されます
$2a$10$LOqePml/koRGsk2YAIOFI.1YNKZg7EsQ5BAIuYP1nWOyYRl21dlne

よくある間違いは、 "password"カラム(usersテーブル)の長さが `password VARCHAR(45)`のように60未満で、一部のデータベースは自動的にデータを切り捨てます。したがって、「エンコードされたパスワードはBCryptのようには見えません」という警告が常に表示されます。

** それを解決するには、 "password"カラムの長さが60以上であることを確認してください。

あとでmigrationのファイル修正する

でもこれ別のだからさっきのは解決してないや

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.example.demo.mapper.RegisterMemberMapper.insertMemberInfo] with root cause

com.example.demo.mapper.RegisterMemberMapper.insertMemberInfo

が悪いのはわかるんだけど

悲しい、insert文書き忘れだった。。。

とりあえずできたけど、ユーザー別の表示しにしなきゃ

f:id:pikahika:20200304140241p:plain

Spring Security 使い方メモ セッション管理 - Qiita

変更のカテゴリのところ直してなかったな

あとログアウトも

セッション管理

ログイン中のユーザ情報を得る

SpringSecurity:ログアウトの実装と、コントローラクラス(Java)でログインユーザ情報を得る SpringBoot/thymeleaf - "BOKU"のITな日常

Spring Security 使い方メモ CSRF - Qiita

あとバリデーションも書けなきゃ、何も入れなくても登録されちゃうw

Spring Boot - Controllerで認証済みのユーザ情報を受け取る - 覚えたら書く

Authentication の取得方法と参照可能な情報 Spring Security 使い方メモ 認証・認可 - Qiita ↑より

Spring Security を構成する重要なクラスの1つに Authentication が存在する。 このクラスには、認証されたユーザーの情報(ユーザー名や付与されている権限の一覧など)が格納されている。

Spring Securityを用いたSpring Boot開発 | エム・フィールド - Tech Blog

6.5. セッション管理 — TERASOLUNA Server Framework for Java (5.x) Development Guideline 5.1.1.RELEASE documentation

6.2. Spring Securityチュートリアル — TERASOLUNA Global Framework Development Guideline 1.0.3.RELEASE documentation

Controllerでログイン済みアカウント情報にアクセスする方法

【Spring】@AuthenticationPrincipal経由でセッションユーザ情報を取得する際のチェック事項 - Ren's blog

Spring Boot Roleメモ(Hishidama's Spring Boot web Role Memo)

理解が追いついてないので、一旦スルーしてユーザー用の方いこ

とりあえず見た目は気にしないでw

f:id:pikahika:20200304174842p:plain

おもて綺麗に作れる気がしない、、、w

とりあえず公開のステータスだけ表示されるようにした

機能としては、検索窓をつけるのと、カテゴリでの絞り込みをできるようにすること。

戻ってやりたいこと

外部キー設定

マイグレーションはあったけどシーダーはないのかな、調べる

セキュリティ的なの何も気にしてないCSRFあたりってどうするんだろ

インデントの整理

Spring Boot でログイン画面 + 一覧画面 + 登録画面の Webアプリケーションを作る ( その10 )( ログイン画面作成3 ) - かんがるーさんの日記

あとで見る

Spring Bootで使われる基本的なアノーテーションと設定の仕組み (1/3):CodeZine(コードジン)

スネークケース、キャメルケースあたり質問しよ

カテゴリのinsert

joinの仕方 done

カテゴリのプルダウンをDBから

あとなぜかログインのところがデフォルトの?が最初に表示されちゃう。多分どっかがうまく切り替わってない