[JAVA] Introduction of user authentication

Introduction of user authentication

Basic authentication

User authentication mechanism provided in the HTTP communication standard d5d42271f315066cae86af0e91d3b5cc.png

Introducing Basic Authentication in Rails Applications

app/controllers/application_controller.rb


class ApplicationController < ActionController::Base
  before_action :basic_auth
  (abridgement)

  private

  def basic_auth
    authenticate_or_request_with_http_basic do |username, password|
      username == 'admin' && password == '1111'
    end
  end
end

Set user name and password in environment variables of development environment

macOS is Catalina or later

Terminal


% vim ~/.zshrc

# .After opening zshrc, type "i" to enter insert mode

# .Added the following description inside zshrc
export BASIC_AUTH_USER='admin'
export BASIC_AUTH_PASSWORD='2222'
#After adding the description, press the esc key to exit insert mode and read ":Type wq to save and exit

# .Reload zshrc and enable the defined environment variables
% source ~/.zshrc

MacOS before Mojave

Terminal


$ vim ~/.bash_profile

# .bash_After opening the profile, type "i" to enter insert mode

# .bash_Added the following description inside profile
export BASIC_AUTH_USER='admin'
export BASIC_AUTH_PASSWORD='2222'
#After adding the description, press the esc key to exit insert mode and read ":Type wq to save and exit

# .bash_Reload profile and enable defined environment variables
$ source ~/.bash_profile

Recommended Posts

Introduction of user authentication
Introduction of pay.jp
Introduction of milkode
Implementation of user authentication function using devise (2)
Implementation of user authentication function using devise (1)
Implementation of user authentication function using devise (3)
Introduction of Docker --Part 1--
[Rails] Introduction of PAY.JP
[Rails] Introduction of devise Basics
[Docker] Introduction of basic Docker Instruction
Memorandum [Rails] User authentication Devise
Introduction of javaFX in Eclipse (April 2020)
[Rails] Implementation of user logic deletion
[Rails] Introduction of Rubocop by beginners
[Rails] Implementation of user withdrawal function
From introduction to use of ActiveHash
From introduction to usage of byebug
Summary about the introduction of Device
[Docker] Introduction of basic options (sharing, user, port, CPU / memory) during Docker run
How to implement the email authentication function at the time of user registration
[Ruby on Rails] Introduction of initial data
Introduction memo of automatic test using Jenkins
[In-house study session] Introduction of "Readable Code"
Creating a user authentication function using devise
Personal application production 2 Introduction of WEB fonts
Introduction of Docker Hub and commands Self-learning ①
Introduction of New Generation Java Programming Guide (Java 10)
Output of the book "Introduction to Java"
Introduction and precautions of gem Friendly Id
Introduction of IDOM engineer's development environment (physics)
Introduction and usage explanation of Font Awesome
Introduction of New Generation Java Programming Guide (Java 11)
[Vue.js] Implementation of menu function Vue.js introduction rails6
Introduction of New Generation Java Programming Guide (Java 12)