token

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: 6 Imported by: 0

Documentation

Overview

Package token 은 Nullus 가 직접 발급하는 세션 토큰을 다룬다.

IdP(OIDC)와 별개의 경로다. IdP 가 죽어도 들어갈 수단이 있어야 하므로 ID/PW 로 인증한 사용자에게 이 토큰을 준다. 검증 주체가 우리이므로 issuer 를 우리 이름으로 찍어 두고, 미들웨어가 그 값을 보고 어느 검증기로 보낼지 정한다.

Index

Constants

View Source
const LocalIssuer = "nullus-local"

LocalIssuer 는 우리가 발급한 토큰에 찍는 issuer 다. Keycloak 이 발급한 토큰과 구분하는 유일한 표식이므로 IdP 의 issuer 와 겹치지 않아야 한다.

Variables

This section is empty.

Functions

func IssuerOf

func IssuerOf(raw string) string

IssuerOf 는 서명을 확인하지 않고 issuer 만 읽는다.

어느 검증기로 보낼지 고르는 용도일 뿐이므로 이 값을 신뢰하면 안 된다 — 실제 판단은 뒤따르는 Verify 가 한다.

Types

type Claims

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

Claims 는 토큰이 실어 나르는 사용자 정보다. 미들웨어가 이 값으로 admindomain.User 를 만들어 컨텍스트에 넣는다.

type LocalIssuerService

type LocalIssuerService struct {
	// contains filtered or unexported fields
}

func NewLocalIssuer

func NewLocalIssuer(secret string, ttl time.Duration) *LocalIssuerService

func (*LocalIssuerService) Enabled

func (s *LocalIssuerService) Enabled() bool

Enabled 는 서명키가 있어 발급·검증이 가능한지 알려준다.

func (*LocalIssuerService) Issue

func (s *LocalIssuerService) Issue(c Claims) (string, error)

func (*LocalIssuerService) Verify

func (s *LocalIssuerService) Verify(raw string) (Claims, error)

type SessionIssuerAdapter

type SessionIssuerAdapter struct {
	// contains filtered or unexported fields
}

SessionIssuerAdapter 는 LocalIssuerService 를 auth 유스케이스의 포트에 맞춘다.

매핑이 하나라도 빠지면 로그인은 되는데 권한이 없거나 조직이 비어 보이는, 원인을 찾기 어려운 상태가 된다.

func NewSessionIssuer

func NewSessionIssuer(svc *LocalIssuerService) SessionIssuerAdapter

func (SessionIssuerAdapter) Issue

Jump to

Keyboard shortcuts

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