nicolaa5 / bankid

A repository for authenticating and signing with Swedish BankID

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

🇸🇪 BankID

 Unit Tests

Relying Party (RP) service

To install the CLI app with which to interact with the package

go install github.com/nicolaa5/bankid/cmd/bankid

Who is this repository for?

You can use this repo if you're using BankID in your organization for one of the following purposes:

  • Authenticating users to use your services
  • Signing documents, transactions or payments related to your organization

Test Setup

Important

The personnummer you use for the Test BankID has to be valid. See the following list for Personnummers that are valid

  1. Set up Mobile BankID on your phone (Android/iOS) or the BankID Security Application on your computer with a test configuration
  2. Create a Test BankID at https://demo.bankid.com that are accepted by BankID
  3. Run the CLI program with bankid auth --test in order to test authentication with your Test BankID

Examples

// Provide certificate and URL
b, err := bankid.New(bankid.Config{
    URL: bankid.BankIDURL,
    Certificate: bankid.Certificate{
        Passphrase:     passphrase,
        SSLCertificate: sslCert,
    },
})

// Send authenticate request to BankID
authResponse, err := b.Auth(ctx, bankid.AuthRequest{
    EndUserIP: ip,
    Requirement: &bankid.Requirement{
        PersonalNumber: personNummer,
    },
})

// Poll for the status of the order
collectResponse, err := b.Collect(ctx, bankid.CollectRequest{
    OrderRef: authResponse.OrderRef,
})

fmt.Println(collectResponse)
// Success case
// {
//         "orderRef": "5cc86d87-ded0-43c3-8ce8-7693710a0092",
//         "status": "complete",
//         "completionData": {
//                 "user": {
//                         "personalNumber": "199510221287",
//                         "name": "John Doe",
//                         "givenName": "John",
//                         "surname": "Doe"
//                 },
//                 ...
//         }
//  }

About

A repository for authenticating and signing with Swedish BankID

License:Apache License 2.0


Languages

Language:Go 99.3%Language:Dockerfile 0.7%