@@ -4,13 +4,23 @@ import (
44 "crypto"
55 "crypto/tls"
66 "crypto/x509"
7+ "net/http"
8+
79 "github.com/go-openapi/runtime"
810 "github.com/go-openapi/strfmt"
911 "github.com/openziti/edge-api/rest_model"
1012 "github.com/openziti/identity"
1113 "github.com/openziti/sdk-golang/ziti/edge/network"
1214 "github.com/openziti/sdk-golang/ziti/sdkinfo"
13- "net/http"
15+ )
16+
17+ type AuthMethod string
18+
19+ const (
20+ AuthMethodCert AuthMethod = "cert"
21+ AuthMethodUpdb AuthMethod = "password"
22+ AuthMethodEmpty AuthMethod = "empty"
23+ AuthMethodJwtExt AuthMethod = "ext-jwt"
1424)
1525
1626// Credentials represents the minimal information needed across all authentication mechanisms to authenticate an identity
@@ -26,7 +36,7 @@ type Credentials interface {
2636 GetCaPool () * x509.CertPool
2737
2838 // Method returns the authentication necessary to complete an authentication request.
29- Method () string
39+ Method () AuthMethod
3040
3141 // AddAuthHeader adds a header for all authentication requests.
3242 AddAuthHeader (key , value string )
@@ -225,8 +235,8 @@ func NewCertCredentials(certs []*x509.Certificate, key crypto.PrivateKey) *CertC
225235 }
226236}
227237
228- func (c * CertCredentials ) Method () string {
229- return "cert"
238+ func (c * CertCredentials ) Method () AuthMethod {
239+ return AuthMethodCert
230240}
231241
232242func (c * CertCredentials ) TlsCerts () []tls.Certificate {
@@ -264,8 +274,8 @@ func (c *IdentityCredentials) GetIdentity() identity.Identity {
264274 return c .Identity
265275}
266276
267- func (c * IdentityCredentials ) Method () string {
268- return "cert"
277+ func (c * IdentityCredentials ) Method () AuthMethod {
278+ return AuthMethodCert
269279}
270280
271281func (c * IdentityCredentials ) GetCaPool () * x509.CertPool {
@@ -301,8 +311,8 @@ func NewJwtCredentials(jwt string) *JwtCredentials {
301311 }
302312}
303313
304- func (c * JwtCredentials ) Method () string {
305- return "ext-jwt"
314+ func (c * JwtCredentials ) Method () AuthMethod {
315+ return AuthMethodJwtExt
306316}
307317
308318func (c * JwtCredentials ) AuthenticateRequest (request runtime.ClientRequest , reg strfmt.Registry ) error {
@@ -330,8 +340,8 @@ type UpdbCredentials struct {
330340 Password string
331341}
332342
333- func (c * UpdbCredentials ) Method () string {
334- return "password"
343+ func (c * UpdbCredentials ) Method () AuthMethod {
344+ return AuthMethodUpdb
335345}
336346
337347// NewUpdbCredentials creates a Credentials instance based on a username/passwords combination.
@@ -354,3 +364,13 @@ func (c *UpdbCredentials) Payload() *rest_model.Authenticate {
354364func (c * UpdbCredentials ) AuthenticateRequest (request runtime.ClientRequest , reg strfmt.Registry ) error {
355365 return c .BaseCredentials .AuthenticateRequest (request , reg )
356366}
367+
368+ var _ Credentials = (* EmptyCredentials )(nil )
369+
370+ type EmptyCredentials struct {
371+ BaseCredentials
372+ }
373+
374+ func (e EmptyCredentials ) Method () AuthMethod {
375+ return AuthMethodEmpty
376+ }
0 commit comments