package oauth2provider import ( "fmt" "strings" "golang.org/x/xerrors" "github.com/coder/coder/v2/coderd/apikey" "github.com/coder/coder/v2/cryptorand" ) const ( // SecretIdentifier is the prefix added to all generated secrets. SecretIdentifier = "coder" ) // Constants for OAuth2 secret generation const ( secretLength = 40 // Length of the actual secret part displaySecretLength = 6 // Length of visible part in UI (last 6 characters) ) type HashedAppSecret struct { AppSecret // Hashed is the server stored hash(secret,salt,...). Used for verifying a // secret. Hashed []byte } type AppSecret struct { // Formatted contains the secret. This value is owned by the client, not the // server. It is formatted to include the prefix. Formatted string // Secret is the raw secret value. This value should only be known to the client. Secret string // Prefix is the ID of this secret owned by the server. When a client uses a // secret, this is the matching string to do a lookup on the hashed value. We // cannot use the hashed value directly because the server does not store the // salt. Prefix string } // ParseFormattedSecret parses a formatted secret like "coder__