ContainerImage.Pinniped/internal/oidc/issuerprovider/issuerprovider.go
Andrew Keesler fd6a7f5892
supervisor-oidc: hoist OIDC discovery handler for testing
Signed-off-by: Andrew Keesler <akeesler@vmware.com>
2020-10-06 11:16:57 -04:00

33 lines
718 B
Go

// Copyright 2020 the Pinniped contributors. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Package issuerprovider provides a thread-safe type that can hold on to an OIDC issuer name.
package issuerprovider
import "sync"
// Provider is a type that can hold onto an issuer value, which may be nil.
//
// It is thread-safe.
type Provider struct {
mu sync.RWMutex
issuer *string
}
// New returns an empty Provider, i.e., one that holds a nil issuer.
func New() *Provider {
return &Provider{}
}
func (p *Provider) SetIssuer(issuer *string) {
p.mu.Lock()
defer p.mu.Unlock()
p.issuer = issuer
}
func (p *Provider) GetIssuer() *string {
p.mu.RLock()
defer p.mu.RUnlock()
return p.issuer
}