bankid

package
v0.0.0-...-14bad61 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const LATEST_VERSION = "6.0"
View Source
const SESSION_TIMEOUT = 30

Variables

This section is empty.

Functions

func IsMobileUserAgent

func IsMobileUserAgent(userAgent string) bool

Types

type AuthRequest

type AuthRequest struct {
	EndUserIp             string                   `json:"endUserIp"`
	UserVisibleData       string                   `json:"userVisibleData,omitempty"`
	UserNonVisibleData    string                   `json:"userNonVisibleData,omitempty"`
	UserVisibleDataFormat string                   `json:"userVisibleDataFormat,omitempty"`
	Requirement           *AuthRequestRequirements `json:"requirement,omitempty"`
}

type AuthRequestRequirements

type AuthRequestRequirements struct {
	PinCode             bool            `json:"pinCode,omitempty"`
	Mrtd                bool            `json:"mrtd,omitempty"`
	CardReader          CardReaderClass `json:"cardReader,omitempty"`
	PersonalNumber      string          `json:"personalNumber,omitempty"`
	CertificatePolicies []string        `json:"certificatePolicies,omitempty"`
}

type AuthResponse

type AuthResponse struct {
	BankIDResponse
	OrderRef       string `json:"orderRef"`
	AutoStartToken string `json:"autoStartToken"`
	QrStartToken   string `json:"qrStartToken"`
	QrStartSecret  string `json:"qrStartSecret"`
}

type BankIDAuthenticationRequest

type BankIDAuthenticationRequest struct {
	SameDevice     bool
	UserAgent      string
	UserIp         string
	MessageForUser string
	RedirectURL    string
}

type BankIDAuthenticationResponse

type BankIDAuthenticationResponse struct {
	LaunchURL      string `json:"launchUrl,omitempty"`
	QrCodeData     string `json:"qrCodeData,omitempty"`
	Success        bool   `json:"success"`
	Message        string `json:"message,omitempty"`
	TransactionKey string `json:"-"`
}

type BankIDConfig

type BankIDConfig struct {
	Env               BankIDEnvironment `yaml:"env"`
	Version           string            `yaml:"version"`
	CertificateFolder string            `yaml:"certificateFolder"`
	Domain            *string           `yaml:"domain"`
	VisibleMessage    string            `yaml:"visibleMessage"`
}

type BankIDEnvironment

type BankIDEnvironment string
const (
	PRODUCTION BankIDEnvironment = "prod"
	TEST       BankIDEnvironment = "test"
)

type BankIDProvider

type BankIDProvider struct {
	Client *BankIDRP
	Cache  *cache.Cache
}

func NewBankIDProvider

func NewBankIDProvider(config *BankIDConfig) *BankIDProvider

func (*BankIDProvider) Authenticate

func (*BankIDProvider) Cancel

func (provider *BankIDProvider) Cancel(transactionKey string)

func (*BankIDProvider) Status

func (provider *BankIDProvider) Status(transactionKey string) BankIDStatusResponse

type BankIDRP

type BankIDRP struct {
	Client *http.Client
	Config *BankIDConfig
}

func NewBankIDRP

func NewBankIDRP(config *BankIDConfig) (*BankIDRP, error)

func (*BankIDRP) Cancel

func (b *BankIDRP) Cancel(orderRef string)

func (*BankIDRP) DoAuth

func (b *BankIDRP) DoAuth(ar AuthRequest) *AuthResponse

func (*BankIDRP) DoCollection

func (b *BankIDRP) DoCollection(orderRef string) *CollectResponse

func (*BankIDRP) DoPhoneAuth

func (b *BankIDRP) DoPhoneAuth(par PhoneAuthRequest) *AuthResponse

func (*BankIDRP) GenerateLaunchURL

func (b *BankIDRP) GenerateLaunchURL(resp *AuthResponse, returnURL string, appLink bool) string

func (*BankIDRP) GenerateQRData

func (b *BankIDRP) GenerateQRData(resp *AuthResponse) (qrCodeData []string)

func (*BankIDRP) GetAuthUrl

func (b *BankIDRP) GetAuthUrl() string

func (*BankIDRP) GetCancelUrl

func (b *BankIDRP) GetCancelUrl() string

func (*BankIDRP) GetCertPolicyString

func (b *BankIDRP) GetCertPolicyString(policy CertificatePolicy) string

func (*BankIDRP) GetCollectUrl

func (b *BankIDRP) GetCollectUrl() string

func (*BankIDRP) GetPhoneAuthUrl

func (b *BankIDRP) GetPhoneAuthUrl() string

type BankIDResponse

type BankIDResponse struct {
	ErrorCode string `json:"errorCode"`
	Details   string `json:"details"`
}

type BankIDStatusResponse

type BankIDStatusResponse struct {
	Message string        `json:"message"`
	Status  CollectStatus `json:"status"`
	Data    interface{}   `json:"data,omitempty"`
}

type BankIDTransaction

type BankIDTransaction struct {
	SameDevice bool
	Mobile     bool
	UserIp     string
	QrCodeData []string
	OrderRef   string
	StartedAt  time.Time
}

type CallInitiator

type CallInitiator string
const (
	UserCallInitiator CallInitiator = "user"
	RPCallInitiator   CallInitiator = "RP"
)

type CancelRequest

type CancelRequest OrderRequest

type CardReaderClass

type CardReaderClass string
const (
	ComputerOrReader CardReaderClass = "class1" // default
	OnlyReader       CardReaderClass = "class2"
)

type CertificatePolicy

type CertificatePolicy string
const (
	OnFile    CertificatePolicy = "1.2.752.78.1.1"
	SmartCard CertificatePolicy = "1.2.752.78.1.2"
	Mobile    CertificatePolicy = "1.2.752.78.1.5"
)

type CollectCompletionData

type CollectCompletionData struct {
	User            CompletionDataUser   `json:"user"`
	Device          CompletionDataDevice `json:"device"`
	BankIdIssueDate string               `json:"bankIdIssueDate"`
	StepUp          CompletionDataStepUp `json:"stepUp"`
	Signature       string               `json:"signature"`
	OcspResponse    string               `json:"ocspResponse"`
}

type CollectRequest

type CollectRequest OrderRequest

type CollectResponse

type CollectResponse struct {
	BankIDResponse
	CollectRequest
	Status         CollectStatus         `json:"status"`
	HintCode       HintCode              `json:"hintCode"`
	CompletionData CollectCompletionData `json:"completionData"`
}

type CollectStatus

type CollectStatus string
const (
	PENDING  CollectStatus = "pending"
	COMPLETE CollectStatus = "complete"
	FAILED   CollectStatus = "failed"
)

type CompletionDataDevice

type CompletionDataDevice struct {
	IpAddress string `json:"ipAddress"`
	UHI       string `json:"uhi"`
}

type CompletionDataStepUp

type CompletionDataStepUp struct {
	Mrtd bool `json:"mrtd"`
}

type CompletionDataUser

type CompletionDataUser struct {
	PersonalNumber string `json:"personalNumber"`
	Name           string `json:"name"`
	GivenName      string `json:"givenName"`
	Surname        string `json:"surname"`
}

type HintCode

type HintCode string
const (
	UNKNOWN                 HintCode = "unknown"
	OUTSTANDING_TRANSACTION HintCode = "outstandingTransaction"
	NO_CLIENT               HintCode = "noClient"
	STARTED                 HintCode = "started"
	USER_MRTD               HintCode = "userMrtd"
	USER_CALL_CONFRIRM      HintCode = "userCallConfirm"
	USER_SIGN               HintCode = "userSign"
	EXPIRED_TRANSACTION     HintCode = "expiredTransaction"
	CERTIFICATE_ERR         HintCode = "certificateErr"
	USER_CANCEL             HintCode = "userCancel"
	CANCELLED               HintCode = "cancelled"
	START_FAILED            HintCode = "startFailed"
	USER_DECLINED_CALL      HintCode = "userDeclinedCall"
)

func (HintCode) GetMessage

func (hc HintCode) GetMessage() string

type OrderRequest

type OrderRequest struct {
	OrderRef string `json:"orderRef"`
}

type PhoneAuthRequest

type PhoneAuthRequest struct {
	PersonalNumber        string                   `json:"personalNumber"`
	CallInitiator         CallInitiator            `json:"callInitiator"`
	UserVisibleData       string                   `json:"userVisibleData,omitempty"`
	UserNonVisibleData    string                   `json:"userNonVisibleData,omitempty"`
	UserVisibleDataFormat string                   `json:"userVisibleDataFormat,omitempty"`
	Requirements          *AuthRequestRequirements `json:"requirement,omitempty"`
}

Jump to

Keyboard shortcuts

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