Skip to content

Commit

Permalink
added kerberos config
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilal Al committed Sep 5, 2024
1 parent bf9f600 commit 739a9ac
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public class HTTPKerberosAuthIntercepterTest {

@Test
public void testBasicFlow() throws Exception {
System.setProperty("java.security.krb5.conf", "src/test/resources/krb5.conf");

HTTPKerberosAuthInterceptor kerberosAuthInterceptor = mock(HTTPKerberosAuthInterceptor.class);
LoginContext loginContext = PowerMockito.mock(LoginContext.class);
when(kerberosAuthInterceptor.getLoginContext(any())).thenReturn((loginContext));
Expand All @@ -47,7 +49,7 @@ public void testBasicFlow() throws Exception {
subject.getPrivateCredentials().add(new KerberosPrincipal("name"));

doCallRealMethod().when(kerberosAuthInterceptor).getClientPrincipalName();
assertThat(kerberosAuthInterceptor.getClientPrincipalName(), is(equalTo("bilal@EXAMPLE.COM"))) ;
assertThat(kerberosAuthInterceptor.getClientPrincipalName(), is(equalTo("bilal@ATHENA.MIT.EDU"))) ;
verify(loginContext, times(2)).getSubject();

when(kerberosAuthInterceptor.buildAuthorizationHeader(any())).thenReturn("secured-token");
Expand Down
37 changes: 37 additions & 0 deletions client/src/test/resources/krb5.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

[libdefaults]
kdc_realm = ATHENA.MIT.EDU
default_realm = ATHENA.MIT.EDU
kdc_tcp_port = 88
kdc_udp_port = 88
dns_lookup_realm = false
dns_lookup_kdc = false
udp_preference_limit = 1

[logging]
default = FILE:/var/logs/krb5kdc.log

[realms]
ATHENA.MIT.EDU = {
# kdc = 10.12.4.76:88
# kdc = tcp/10.12.4.76:88
# kdc = tcp/192.168.1.19:88
kdc = 192.168.1.19:88
}

0 comments on commit 739a9ac

Please sign in to comment.