Skip to content

Make authcid,authzid,client_nonce readable from server side #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license = "MIT"
name = "scram"
readme = "README.md"
repository = "https://github.com/tomprogrammer/scram"
version = "0.6.0"
version = "0.6.1"

[dependencies]
base64 = "0.13.0"
Expand Down
25 changes: 25 additions & 0 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,21 @@ impl<'a, P: AuthenticationProvider> ServerFirst<'a, P> {
server_first.into_owned(),
)
}

/// The username parsed from client first message that used for authentication.
pub fn authcid(&self) -> &str {
self.authcid
}

/// The username parsed from client first message that used for authorization.
pub fn authzid(&self) -> Option<&str> {
self.authzid
}

/// The nonce value parsed from client first message.
pub fn client_nonce(&self) -> &str {
self.client_nonce
}
}

/// Represents the stage after the server has generated its first response to the client. This
Expand Down Expand Up @@ -273,6 +288,16 @@ impl<'a, P: AuthenticationProvider> ClientFinal<'a, P> {
}
}

/// The username parsed from client first message that used for authentication.
pub fn authcid(&self) -> &str {
self.authcid
}

/// The username parsed from client first message that used for authorization.
pub fn authzid(&self) -> Option<&str> {
self.authzid
}

/// Checks that the gs2header received from the client is the same as the one we've stored
fn verify_header(&self, gs2header: &str) -> bool {
let server_gs2header = base64::encode(self.gs2header.as_bytes());
Expand Down