domain

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 31, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package domain 은 인증 바운디드 컨텍스트의 도메인 규칙을 담는다.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidCredentials = errors.New("invalid credentials")

ErrInvalidCredentials 는 이메일과 비밀번호가 맞지 않을 때다.

어느 쪽이 틀렸는지 구분해 알리지 않는다 — 구분하면 어떤 이메일이 가입돼 있는지 알아낼 수 있다.

Functions

func HashPassword

func HashPassword(plaintext string) (string, error)

HashPassword 는 저장용 bcrypt 해시를 만든다. 같은 평문이라도 매번 다른 값이 나온다(salt) — 같은 해시가 나오면 유출 시 같은 비밀번호를 쓰는 계정이 한꺼번에 드러난다.

func ValidatePasswordPolicy

func ValidatePasswordPolicy(plaintext string) error

ValidatePasswordPolicy 는 저장 전에 최소 요건을 확인한다.

func VerifyPassword

func VerifyPassword(hash, plaintext string) error

VerifyPassword 는 저장된 해시와 입력 평문을 대조한다.

해시가 비어 있으면 무엇도 통과시키지 않는다. 비밀번호를 설정하지 않은 계정 (OIDC 전용)이 빈 해시를 갖는데, 여기서 통과시키면 그 계정 전부가 무인증으로 열린다.

Types

type Credential

type Credential struct {
	UserID       string
	Email        string
	Name         string
	Role         string
	OrgID        string
	PasswordHash string
	IsActive     bool
}

Credential 은 ID/PW 로그인에 필요한 사용자 정보다.

PasswordHash 가 비면 비밀번호를 설정하지 않은 계정(OIDC 전용)이고, ID/PW 로는 들어올 수 없다.

func (Credential) CanLogInWithPassword

func (c Credential) CanLogInWithPassword() bool

CanLogInWithPassword 는 ID/PW 경로로 들어올 수 있는 계정인지 알려준다.

func (Credential) Claims

func (c Credential) Claims() SessionClaims

Claims 는 이 자격에 대응하는 세션 클레임을 만든다.

type SessionClaims

type SessionClaims struct {
	UserID string
	Email  string
	Name   string
	Role   string
	OrgID  string
}

SessionClaims 는 로그인 성공 시 세션 토큰에 실을 정보다.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL