Skip to content

Commit

Permalink
feat: rename digest authorize to authorize dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
emiago committed Dec 1, 2024
1 parent bdcca90 commit 445170e
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions digest_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,6 @@ func NewDigestServer() *DigestAuthServer {
return t
}

func (s *DigestAuthServer) Authorize(d *DialogServerSession, auth DigestAuth) error {
if auth.Realm == "" {
auth.Realm = "sipgo"
}

// https://www.rfc-editor.org/rfc/rfc2617#page-6
req := d.InviteRequest
res, err := s.AuthorizeRequest(req, auth)

return errors.Join(err, d.WriteResponse(res))
}

var (
ErrDigestAuthNoChallenge = errors.New("no challenge")
ErrDigestAuthBadCreds = errors.New("bad credentials")
Expand Down Expand Up @@ -121,6 +109,17 @@ func (s *DigestAuthServer) AuthorizeRequest(req *sip.Request, auth DigestAuth) (
return sip.NewResponseFromRequest(req, sip.StatusOK, "OK", nil), nil
}

func (s *DigestAuthServer) AuthorizeDialog(d *DialogServerSession, auth DigestAuth) error {
if auth.Realm == "" {
auth.Realm = "sipgo"
}

// https://www.rfc-editor.org/rfc/rfc2617#page-6
req := d.InviteRequest
res, err := s.AuthorizeRequest(req, auth)
return errors.Join(err, d.WriteResponse(res))
}

func generateNonce() (string, error) {
nonceBytes := make([]byte, 32)
_, err := rand.Read(nonceBytes)
Expand Down

0 comments on commit 445170e

Please sign in to comment.