MCPcopy Create free account
hub / github.com/apache/mesos / authenticate

Method authenticate

3rdparty/libprocess/src/authenticator.cpp:84–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82
83
84Future<AuthenticationResult> BasicAuthenticatorProcess::authenticate(
85 const Request& request)
86{
87 AuthenticationResult unauthorized;
88 unauthorized.unauthorized =
89 Unauthorized({"Basic realm=\"" + realm_ + "\""});
90
91 Option<string> credentials = request.headers.get("Authorization");
92
93 if (credentials.isNone()) {
94 return unauthorized;
95 }
96
97 vector<string> components = strings::split(credentials.get(), " ");
98
99 if (components.size() != 2 || components[0] != "Basic") {
100 return unauthorized;
101 }
102
103 Try<string> decoded = base64::decode(components[1]);
104
105 if (decoded.isError()) {
106 return unauthorized;
107 }
108
109 vector<string> credential = strings::split(decoded.get(), ":");
110
111 if (credential.size() != 2 ||
112 !credentials_.contains(credential[0]) ||
113 credentials_.at(credential[0]) != credential[1]) {
114 return unauthorized;
115 }
116
117 AuthenticationResult authenticated;
118 authenticated.principal = Principal(credential[0]);
119 return authenticated;
120}
121
122
123BasicAuthenticator::BasicAuthenticator(

Callers 1

_consumeMethod · 0.45

Calls 11

UnauthorizedClass · 0.85
splitFunction · 0.85
atMethod · 0.80
decodeFunction · 0.70
dispatchFunction · 0.70
PrincipalClass · 0.50
getMethod · 0.45
isNoneMethod · 0.45
sizeMethod · 0.45
isErrorMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected