github.com/greenpau/go-authcrunch@v1.1.4/pkg/authn/enums/operator/operator.go (about)

     1  // Copyright 2022 Paul Greenberg greenpau@outlook.com
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package operator
    16  
    17  import (
    18  	"fmt"
    19  )
    20  
    21  // Type is the type of an operator.
    22  type Type int
    23  
    24  const (
    25  	// Unknown operator signals invalid operator.
    26  	Unknown Type = iota
    27  	// Authenticate operator signals authentication request.
    28  	Authenticate
    29  	// ChangePassword operator signals the changing of password.
    30  	ChangePassword
    31  	// GetPublicKeys operator signals the retrieval of public keys.
    32  	GetPublicKeys
    33  	// GetPublicKey operator signals the retrieval of a single public key.
    34  	GetPublicKey
    35  	// GetAPIKeys operator signals the retrieval of API keys.
    36  	GetAPIKeys
    37  	// GetAPIKey operator signals the retrieval of a single API key.
    38  	GetAPIKey
    39  	// AddKeySSH operator signals the addition of an SSH public key.
    40  	AddKeySSH
    41  	// AddKeyGPG operator signals the addition of an GPG public key.
    42  	AddKeyGPG
    43  	// AddAPIKey operator signals the addition of an API key.
    44  	AddAPIKey
    45  	// DeletePublicKey operator signals the deletion of a public key.
    46  	DeletePublicKey
    47  	// DeleteAPIKey operator signals the deletion of an API key.
    48  	DeleteAPIKey
    49  	// GetMfaTokens operator signals the retrieval of MFA tokens.
    50  	GetMfaTokens
    51  	// GetMfaToken operator signals the retrieval of a single MFA token.
    52  	GetMfaToken
    53  	// AddMfaToken operator signals the addition of an MFA token.
    54  	AddMfaToken
    55  	// DeleteMfaToken operator signals the deletion of an MFA token.
    56  	DeleteMfaToken
    57  	// GetUsers operator signals the retrieval of users.
    58  	GetUsers
    59  	// GetUser operator signals the retrieval of a specific user.
    60  	GetUser
    61  	// AddUser operator signals the addition of a user.
    62  	AddUser
    63  	// DeleteUser operator signals the deletion of a user.
    64  	DeleteUser
    65  	// IdentifyUser operator signals the retrieval of user identity and
    66  	// associated challenges.
    67  	IdentifyUser
    68  	// LookupAPIKey operator signals the retrieval of user identity associated
    69  	// with an API key
    70  	LookupAPIKey
    71  )
    72  
    73  // String returns string representation of an operator.
    74  func (e Type) String() string {
    75  	switch e {
    76  	case Unknown:
    77  		return "Unknown"
    78  	case Authenticate:
    79  		return "Authenticate"
    80  	case ChangePassword:
    81  		return "ChangePassword"
    82  	case GetPublicKeys:
    83  		return "GetPublicKeys"
    84  	case GetPublicKey:
    85  		return "GetPublicKey"
    86  	case AddKeySSH:
    87  		return "AddKeySSH"
    88  	case AddKeyGPG:
    89  		return "AddKeyGPG"
    90  	case DeletePublicKey:
    91  		return "DeletePublicKey"
    92  	case GetMfaTokens:
    93  		return "GetMfaTokens"
    94  	case GetMfaToken:
    95  		return "GetMfaToken"
    96  	case AddMfaToken:
    97  		return "AddMfaToken"
    98  	case DeleteMfaToken:
    99  		return "DeleteMfaToken"
   100  	case GetUsers:
   101  		return "GetUsers"
   102  	case GetUser:
   103  		return "GetUser"
   104  	case AddUser:
   105  		return "AddUser"
   106  	case DeleteUser:
   107  		return "DeleteUser"
   108  	case GetAPIKeys:
   109  		return "GetAPIKeys"
   110  	case GetAPIKey:
   111  		return "GetAPIKey"
   112  	case AddAPIKey:
   113  		return "AddAPIKey"
   114  	case DeleteAPIKey:
   115  		return "DeleteAPIKey"
   116  	case IdentifyUser:
   117  		return "IdentifyUser"
   118  	case LookupAPIKey:
   119  		return "LookupAPIKey"
   120  	}
   121  	return fmt.Sprintf("Type(%d)", int(e))
   122  }