1from k5test import * 2 3# Test authentication indicators. Load the test preauth module so we 4# can control the indicators asserted. 5testpreauth = os.path.join(buildtop, 'plugins', 'preauth', 'test', 'test.so') 6conf = {'plugins': {'kdcpreauth': {'module': 'test:' + testpreauth}, 7 'clpreauth': {'module': 'test:' + testpreauth}}} 8realm = K5Realm(krb5_conf=conf) 9realm.run([kadminl, 'addprinc', '-randkey', 'service/1']) 10realm.run([kadminl, 'addprinc', '-randkey', 'service/2']) 11realm.run([kadminl, 'modprinc', '+requires_preauth', realm.user_princ]) 12realm.run([kadminl, 'setstr', 'service/1', 'require_auth', 'superstrong']) 13realm.run([kadminl, 'setstr', 'service/2', 'require_auth', 'one two']) 14realm.run([kadminl, 'xst', 'service/1']) 15realm.run([kadminl, 'xst', 'service/2']) 16 17realm.kinit(realm.user_princ, password('user'), 18 ['-X', 'indicators=superstrong']) 19out = realm.run(['./t_srcattrs', 'p:service/1']) 20if ('Attribute auth-indicators Authenticated Complete') not in out: 21 fail('Expected attribute type data not seen') 22# UTF8 "superstrong" 23if '73757065727374726f6e67' not in out: 24 fail('Expected auth indicator not seen in name attributes') 25 26msg = 'gss_init_sec_context: KDC policy rejects request' 27realm.run(['./t_srcattrs', 'p:service/2'], expected_code=1, expected_msg=msg) 28 29realm.kinit(realm.user_princ, password('user'), ['-X', 'indicators=one two']) 30out = realm.run(['./t_srcattrs', 'p:service/2']) 31# Hexadecimal "one" and "two" 32if '6f6e65' not in out or '74776f' not in out: 33 fail('Expected auth indicator not seen in name attributes') 34 35realm.stop() 36 37# Test the FAST encrypted challenge auth indicator. 38kdcconf = {'realms': {'$realm': {'encrypted_challenge_indicator': 'fast'}}} 39realm = K5Realm(kdc_conf=kdcconf) 40realm.run([kadminl, 'modprinc', '+requires_preauth', realm.user_princ]) 41realm.run([kadminl, 'xst', realm.host_princ]) 42realm.kinit(realm.user_princ, password('user')) 43realm.kinit(realm.user_princ, password('user'), ['-T', realm.ccache]) 44out = realm.run(['./t_srcattrs', 'p:' + realm.host_princ]) 45if ('Attribute auth-indicators Authenticated Complete') not in out: 46 fail('Expected attribute type not seen') 47if '66617374' not in out: 48 fail('Expected auth indicator not seen in name attributes') 49 50realm.stop() 51success('GSSAPI auth indicator tests') 52