summaryrefslogtreecommitdiff
path: root/internal/oidc/client_credentials.go
blob: 72d360f2935e604d30204679f6e41f4bc55a520d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package oidc

import (
	"context"

	oauthelia2 "authelia.com/provider/oauth2"

	"github.com/authelia/authelia/v4/internal/configuration/schema"
)

// ClientSecretDigest decorates the *schema.PasswordDigest with the relevant functions to implement oauth2.ClientSecret.
type ClientSecretDigest struct {
	*schema.PasswordDigest
}

// Compare decorates the *schema.PasswordDigest's implementation to satisfy oauth2.ClientSecret's Compare function.
func (d *ClientSecretDigest) Compare(ctx context.Context, rawSecret []byte) (err error) {
	if d.PasswordDigest == nil || d.PasswordDigest.Digest == nil {
		return oauthelia2.ErrClientSecretNotRegistered
	}

	if d.MatchBytes(rawSecret) {
		return nil
	}

	return errClientSecretMismatch
}