login

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// List containing the users addresses. Will always contain home, but can
	// also include work and other.
	ScopeAdress = "address"
	// User birth date (BankID verified)
	ScopeBirthDate = "birthDate"
	// User email (verified), the flag "email_verified : true" in the response
	// can be used by merchant to confirm for each request that the email
	// actually is verified
	ScopeEmail = "email"
	// User first, middle and given name (verified with National Population
	// Register)
	ScopeName = "name"
	// 	Verified phone number (verfied - the number used with Vipps)
	ScopePhoneNumber = "phoneNumber"
	// Norwegian national identity number (verified with BankID)
	ScopeNNIN = "nnin"
	// User bank account numbers
	ScopeAccountNumbers = "accountNumbers"
	// Signals that version 2 of the API should be used
	ScopeAPIV2 = "api_version_2"
)

List of possible scopes supported by Vipps Login

Variables

This section is empty.

Functions

This section is empty.

Types

type Claims

type Claims struct {
	Address struct {
		Country   string `json:"country"`
		Street    string `json:"street_address"`
		Type      string `json:"address_type"`
		Formatted string `json:"formatted"`
		Zip       string `json:"postal_code"`
		Region    string `json:"region"`
	} `json:"address"`
	OtherAddress []struct {
		Country   string `json:"country"`
		Street    string `json:"street_address"`
		Type      string `json:"address_type"`
		Formatted string `json:"formatted"`
		Zip       string `json:"postal_code"`
		Region    string `json:"region"`
	} `json:"other_address"`
	NIN           string `json:"nin"`
	PhoneNumber   string `json:"phone_number"`
	Name          string `json:"name"`
	BirthDate     Date   `json:"birthdate"`
	GivenName     string `json:"given_name"`
	FamilyName    string `json:"family_name"`
	Email         string `json:"email"`
	EmailVerified bool   `json:"email_verified"`
	UserID        string `json:"sub"`
}

Claims represents the claims contained in Vipps ID tokens

type Date added in v0.6.0

type Date struct {
	Year  int
	Month time.Month
	Day   int
}

func (*Date) String added in v0.6.0

func (d *Date) String() string

func (*Date) UnmarshalJSON added in v0.6.0

func (d *Date) UnmarshalJSON(bytes []byte) error

type IssuerURL

type IssuerURL string
const (
	IssuerURLTesting    IssuerURL = "https://apitest.vipps.no/access-management-1.0/access/"
	IssuerURLProduction IssuerURL = "https://api.vipps.no/access-management-1.0/access/"
)

type Provider

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

Provider is a convenience wrapper around oidc.Provider tailored to the Vipps Login API

func NewProvider added in v0.6.0

func NewProvider(ctx context.Context, config *ProviderConfig) (*Provider, error)

NewProvider returns a configured Vipps Login Provider.

func (*Provider) AuthCodeURL

func (p *Provider) AuthCodeURL(state string) string

AuthCodeURL returns a URL to OAuth 2.0 provider's consent page that asks for permissions for the configured scopes explicitly

func (*Provider) ExchangeCodeForClaims

func (p *Provider) ExchangeCodeForClaims(ctx context.Context, code string) (*Claims, error)

ExchangeCodeForClaims takes an oauth2 authorization code, exchanges it for a token, and returns the contained ID token's claims, if any

type ProviderConfig added in v0.5.0

type ProviderConfig struct {
	ClientID     string
	ClientSecret string
	IssuerURL    IssuerURL
	RedirectURL  string
	Scopes       []string
}

ProviderConfig represents a configuration for a Provider

Jump to

Keyboard shortcuts

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