0%

认证与授权

认证与授权

  • Authentication(认证)
    • 用户的用户名和密码是否能通过检验。
  • Authorizantion(授权)
    • 用户是否被允许访问服务或资源。

nsswitch&pam

nsswitch-提供名称解析

network service switch 网络服务转换

/etc/nsswitch.conf

库文件路径/usr/lib[64]/libnss*

说白了就是名称解析,nss定义了以何种方式,何种途径,何种顺序来查找特定信息

返回机制

  • SUCCESS
    • service ok,name found
  • NOTFOUND
    • service ok,name not found
  • UNAVAIL
    • service not available
  • TRYAGAIN
    • temporary service failure-临时故障
返回了success,不继续使用其他查找方式

返回动作

  • return
    • 返回
  • continue
    • 继续

查找方式

  • files
  • nis/nisplus
  • dns
  • db
服务名: 查找方式 返回机制 更多查找方式

passwd: nis [NOTFOUND=return] files


pam-提供认证

Pluggable Authentication Module 可插入式认证模块

/etc/pam.d/service

一个服务框架,用于认证功能,其他服务依赖于此机制,如果在nsswitch中使用了pam认证方式,pam就能使用特定的库来实现认证功能,通过配置文件对认证过程实现配置

type -类型/组

  • account
  • auth
  • password
  • session

control-控制

根据返回值进行处理
  • required-需求
    • 一票否决,必须满足
    • 无论是否通过检查,都继续检查
  • requisite-必须的
    • 真正的一票否决,必须满足
    • 只要检查不通过,就不用继续检查后面了,直接返回
  • sufficient-充分条件
    • 一票通过
    • 如果没通过,不干涉后续检查
  • optional-可选
    • 无所谓的选项
  • include-移权给其他文件

另一种控制方式

value1=action1 value2=action2 ……

value-返回值

1
success、open_err、symbol_err、service_err、 system_err、buf_err、perm_denied、auth_err、cred_insufficient、authinfo_unavail、user_unknown、maxtries、new_authtok_reqd、acct_expired、 session_err、cred_unavail、cred_expired、cred_err、no_module_data、conv_err、 authtok_err、authtok_recover_err、authtok_lock_busy、authtok_disable_aging、 try_again、ignore、abort、authtok_expired、module_unknown、bad_item和default

actions-动作/动作

  • ok
    • 当前检查通过,继续检查
  • done
    • 一票通过,不继续检查,返回最终结果
  • bad
    • 当前检察失败,继续检查
  • die
    • 一票否决,不继续检查,返回最终结果
  • ignore
    • 忽略
  • reset
    • 忽略所有结果,重新继续
1
2
type	control		module_name 	module_parameter
auth requisite pam_successd_if.so uid < 500 quit
恰饭,恰饭