summaryrefslogtreecommitdiff
path: root/lib/chessh/ssh/server_key.ex
blob: 5252624e46228c4ed0f0b01fe7a8248210e8a76b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
defmodule Chessh.SSH.ServerKey do
  alias Chessh.PlayerSession
  alias Chessh.Auth.KeyAuthenticator

  @behaviour :ssh_server_key_api

  def is_auth_key(key, username, _daemon_options) do
    PlayerSession.player_within_concurrent_sessions_and_satisfies(
      username,
      &KeyAuthenticator.authenticate(&1, key)
    )
  end

  def host_key(algorithm, daemon_options) do
    :ssh_file.host_key(algorithm, daemon_options)
  end
end